nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h
2 --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211_crypt.h 2006-06-06 04:58:02.000000000 +0200
3 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h 2008-01-30 17:38:10.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h
24 --- rtl8187_linux_26.1010.0622.2006/beta-8187/ieee80211.h 2006-06-06 04:58:02.000000000 +0200
25 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h 2008-01-30 17:38:10.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile
666 --- rtl8187_linux_26.1010.0622.2006/beta-8187/Makefile 2006-06-06 04:58:00.000000000 +0200
667 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile 2008-01-30 17:38:10.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c
678 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_93cx6.c 2006-06-06 04:58:00.000000000 +0200
679 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c 2008-01-30 17:38:10.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h
690 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_hw.h 2006-06-06 04:58:00.000000000 +0200
691 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h 2008-01-30 17:38:11.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c
702 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.c 2006-06-06 04:58:02.000000000 +0200
703 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c 2008-01-30 17:38:11.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h
771 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225.h 2006-06-06 04:58:00.000000000 +0200
772 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h 2008-01-30 17:38:11.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c
780 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_rtl8225z2.c 2006-06-06 04:58:02.000000000 +0200
781 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c 2008-01-30 17:38:11.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c
1882 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8180_wx.c 2006-06-06 04:58:02.000000000 +0200
1883 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c 2008-01-30 17:38:11.000000000 +0100
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_linux_26.1010.0622.2006/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c
2733 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187_core.c 2006-06-22 07:43:30.000000000 +0200
2734 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c 2008-01-30 17:39:05.000000000 +0100
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,35 +414,44 @@
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 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
3077 rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net);
3078 +#else
3079 + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net);
3080 +#endif
3081 }
3082  
3083  
3084 void rtl8180_proc_module_remove(void)
3085 {
3086 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
3087 remove_proc_entry(RTL8187_MODULE_NAME, proc_net);
3088 +#else
3089 + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net);
3090 +#endif
3091 }
3092  
3093  
3094 void rtl8180_proc_remove_one(struct net_device *dev)
3095 {
3096 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3097 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3098 if (priv->dir_dev) {
3099 // remove_proc_entry("stats-hw", priv->dir_dev);
3100 remove_proc_entry("stats-tx", priv->dir_dev);
3101 @@ -447,9 +468,9 @@
3102 void rtl8180_proc_init_one(struct net_device *dev)
3103 {
3104 struct proc_dir_entry *e;
3105 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3106 - priv->dir_dev = create_proc_entry(dev->name,
3107 - S_IFDIR | S_IRUGO | S_IXUGO,
3108 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3109 + priv->dir_dev = create_proc_entry(dev->name,
3110 + S_IFDIR | S_IRUGO | S_IXUGO,
3111 rtl8180_proc);
3112 if (!priv->dir_dev) {
3113 DMESGE("Unable to initialize /proc/net/rtl8187/%s\n",
3114 @@ -459,7 +480,7 @@
3115 #if 0
3116 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
3117 priv->dir_dev, proc_get_stats_hw, dev);
3118 -
3119 +
3120 if (!e) {
3121 DMESGE("Unable to initialize "
3122 "/proc/net/rtl8187/%s/stats-hw\n",
3123 @@ -468,17 +489,17 @@
3124 #endif
3125 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
3126 priv->dir_dev, proc_get_stats_rx, dev);
3127 -
3128 +
3129 if (!e) {
3130 DMESGE("Unable to initialize "
3131 "/proc/net/rtl8187/%s/stats-rx\n",
3132 dev->name);
3133 }
3134 -
3135 -
3136 +
3137 +
3138 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
3139 priv->dir_dev, proc_get_stats_tx, dev);
3140 -
3141 +
3142 if (!e) {
3143 DMESGE("Unable to initialize "
3144 "/proc/net/rtl8187/%s/stats-tx\n",
3145 @@ -487,27 +508,27 @@
3146 #if 0
3147 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
3148 priv->dir_dev, proc_get_stats_ieee, dev);
3149 -
3150 +
3151 if (!e) {
3152 DMESGE("Unable to initialize "
3153 "/proc/net/rtl8187/%s/stats-ieee\n",
3154 dev->name);
3155 }
3156 -
3157 -
3158 +
3159 +
3160 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
3161 priv->dir_dev, proc_get_stats_ap, dev);
3162 -
3163 +
3164 if (!e) {
3165 DMESGE("Unable to initialize "
3166 "/proc/net/rtl8187/%s/stats-ap\n",
3167 dev->name);
3168 }
3169 #endif
3170 -
3171 +
3172 e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
3173 priv->dir_dev, proc_get_registers, dev);
3174 -
3175 +
3176 if (!e) {
3177 DMESGE("Unable to initialize "
3178 "/proc/net/rtl8187/%s/registers\n",
3179 @@ -523,14 +544,14 @@
3180 {
3181 int i;
3182 u8 *buf =(u8*)buffer;
3183 -
3184 +
3185 printk("ASCII BUFFER DUMP (len: %x):\n",len);
3186 -
3187 +
3188 for(i=0;i<len;i++)
3189 printk("%c",buf[i]);
3190 -
3191 +
3192 printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
3193 -
3194 +
3195 for(i=0;i<len;i++)
3196 printk("%x",buf[i]);
3197  
3198 @@ -539,17 +560,17 @@
3199  
3200 short check_nic_enought_desc(struct net_device *dev, priority_t priority)
3201 {
3202 - struct r8180_priv *priv = ieee80211_priv(dev);
3203 -
3204 - int used = atomic_read((priority == NORM_PRIORITY) ?
3205 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3206 +
3207 + int used = atomic_read((priority == NORM_PRIORITY) ?
3208 &priv->tx_np_pending : &priv->tx_lp_pending);
3209 -
3210 +
3211 return (used < MAX_TX_URB);
3212 }
3213  
3214 void tx_timeout(struct net_device *dev)
3215 {
3216 - struct r8180_priv *priv = ieee80211_priv(dev);
3217 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3218 //rtl8180_commit(dev);
3219 schedule_work(&priv->reset_wq);
3220 //DMESG("TXTIMEOUT");
3221 @@ -561,7 +582,20 @@
3222 {
3223 int i;
3224 for(i=0; i<63; i++)
3225 - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
3226 + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i));
3227 +}
3228 +
3229 +/* this is only for debug */
3230 +void dump_tx_power(struct net_device *dev)
3231 +{
3232 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3233 + int i;
3234 + DMESG("CCK TX-Power (b-mode):");
3235 + for(i=1; i<=14; i++)
3236 + DMESG("Channel %d: %d", i, priv->chtxpwr[i]);
3237 + DMESG("OFDM TX-Power (g-mode):");
3238 + for(i=1; i<=14; i++)
3239 + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]);
3240 }
3241  
3242 /* this is only for debug */
3243 @@ -570,14 +604,14 @@
3244 int i;
3245 int n;
3246 int max=0xff;
3247 -
3248 - DMESG("Dumping NIC register map");
3249 -
3250 +
3251 + DMESG("Dumping NIC register map");
3252 +
3253 for(n=0;n<=max;)
3254 {
3255 - printk( "\nD: %2x> ", n);
3256 + printk( "\nD: %02X> ", n);
3257 for(i=0;i<16 && n<=max;i++,n++)
3258 - printk("%2x ",read_nic_byte(dev,n));
3259 + printk("%02X ",read_nic_byte(dev,n));
3260 }
3261 printk("\n");
3262 }
3263 @@ -589,11 +623,11 @@
3264  
3265 void rtl8180_irq_enable(struct net_device *dev)
3266 {
3267 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3268 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3269 //priv->irq_enabled = 1;
3270 /*
3271 - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
3272 - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
3273 + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
3274 + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
3275 INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
3276 INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
3277 */
3278 @@ -603,7 +637,7 @@
3279  
3280 void rtl8180_irq_disable(struct net_device *dev)
3281 {
3282 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3283 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3284  
3285 write_nic_word(dev,INTA_MASK,0);
3286 force_pci_posting(dev);
3287 @@ -625,115 +659,119 @@
3288  
3289 void rtl8180_update_msr(struct net_device *dev)
3290 {
3291 - struct r8180_priv *priv = ieee80211_priv(dev);
3292 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3293 u8 msr;
3294 -
3295 +
3296 msr = read_nic_byte(dev, MSR);
3297 msr &= ~ MSR_LINK_MASK;
3298 -
3299 +
3300 /* do not change in link_state != WLAN_LINK_ASSOCIATED.
3301 - * msr must be updated if the state is ASSOCIATING.
3302 + * msr must be updated if the state is ASSOCIATING.
3303 * this is intentional and make sense for ad-hoc and
3304 * master (see the create BSS/IBSS func)
3305 */
3306 - if (priv->ieee80211->state == IEEE80211_LINKED){
3307 -
3308 + if (priv->ieee80211->state == IEEE80211_LINKED){
3309 +
3310 if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
3311 msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
3312 else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
3313 msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
3314 else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
3315 msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
3316 -
3317 +
3318 }else
3319 msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
3320 -
3321 +
3322 write_nic_byte(dev, MSR, msr);
3323 }
3324  
3325 void rtl8180_set_chan(struct net_device *dev,short ch)
3326 {
3327 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3328 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3329 u32 tx;
3330 priv->chan=ch;
3331 #if 0
3332 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
3333 + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
3334 priv->ieee80211->iw_mode == IW_MODE_MASTER){
3335 -
3336 - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
3337 +
3338 + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
3339 priv->ieee80211->master_chan = ch;
3340 - rtl8180_update_beacon_ch(dev);
3341 + rtl8180_update_beacon_ch(dev);
3342 }
3343 #endif
3344 -
3345 +
3346 /* this hack should avoid frame TX during channel setting*/
3347 tx = read_nic_dword(dev,TX_CONF);
3348 tx &= ~TX_LOOPBACK_MASK;
3349  
3350 -#ifndef LOOP_TEST
3351 +#ifndef LOOP_TEST
3352 write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
3353 -
3354 priv->rf_set_chan(dev,priv->chan);
3355 mdelay(10);
3356 - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
3357 + write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
3358 #endif
3359 }
3360 +
3361 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3362 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs);
3363 +#else
3364 +void rtl8187_rx_isr(struct urb *rx_urb);
3365 +#endif
3366  
3367  
3368 void rtl8187_rx_urbsubmit(struct net_device *dev, struct urb* rx_urb)
3369 {
3370 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3371 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3372 int err;
3373 -
3374 +
3375 // u8 *rx;
3376 -
3377 +
3378 //DMESG("starting RX");
3379 /*rx = kmalloc(RX_URB_SIZE*sizeof(u8),GFP_ATOMIC);
3380 - if(!rx){
3381 + if(!rx){
3382 DMESGE("unable to allocate RX buffer");
3383 return;
3384 }*/
3385 -
3386 +
3387 usb_fill_bulk_urb(rx_urb,priv->udev,
3388 usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer,
3389 RX_URB_SIZE,rtl8187_rx_isr,dev);
3390 - err = usb_submit_urb(rx_urb, GFP_ATOMIC);
3391 + err = usb_submit_urb(rx_urb, GFP_ATOMIC);
3392 if(err && err != -EPERM){
3393 DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status);
3394 -
3395 +
3396 }
3397 -
3398 +
3399 }
3400  
3401  
3402 void rtl8187_rx_initiate(struct net_device *dev)
3403 {
3404 int i;
3405 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3406 -
3407 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3408 +
3409 if(!priv->rx_urb)
3410 DMESGE("Cannot intiate RX urb mechanism");
3411 - for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3412 + for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3413 rtl8187_rx_urbsubmit(dev,priv->rx_urb[i]);
3414 -
3415 +
3416 }
3417  
3418 void rtl8187_set_rxconf(struct net_device *dev)
3419 {
3420 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3421 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3422 u32 rxconf;
3423 -
3424 +
3425 rxconf=read_nic_dword(dev,RX_CONF);
3426 rxconf = rxconf &~ MAC_FILTER_MASK;
3427 rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
3428 rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
3429 rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
3430 rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
3431 - rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3432 + rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3433  
3434 if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
3435 -
3436 +
3437 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
3438 dev->flags & IFF_PROMISC){
3439 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3440 @@ -741,40 +779,40 @@
3441 rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
3442 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3443 }
3444 -
3445 +
3446 /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
3447 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3448 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3449 }*/
3450 -
3451 +
3452 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
3453 rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
3454 rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
3455 }
3456 -
3457 +
3458 if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
3459 rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
3460 -
3461 -
3462 +
3463 +
3464 rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
3465 rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
3466 -
3467 -
3468 +
3469 +
3470 rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
3471 -
3472 +
3473 rxconf = rxconf &~ MAX_RX_DMA_MASK;
3474 rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
3475 -
3476 +
3477 rxconf = rxconf | RCR_ONLYERLPKT;
3478 -
3479 +
3480 // rxconf = rxconf &~ RCR_CS_MASK;
3481 // rxconf = rxconf | (1<<RCR_CS_SHIFT);
3482  
3483 - write_nic_dword(dev, RX_CONF, rxconf);
3484 -
3485 + write_nic_dword(dev, RX_CONF, rxconf);
3486 +
3487 // V rtl suggested V //
3488 // write_nic_dword(dev, RX_CONF, 0x901ce70e);
3489 -
3490 +
3491 //fix_rx_fifo(dev);
3492 // //set_nic_rxring(dev);
3493 #ifdef DEBUG_RX
3494 @@ -785,23 +823,23 @@
3495 void rtl8180_rx_enable(struct net_device *dev)
3496 {
3497 u8 cmd;
3498 -
3499 -
3500 +
3501 +
3502 rtl8187_rx_initiate(dev);
3503  
3504 - rtl8187_set_rxconf(dev);
3505 + rtl8187_set_rxconf(dev);
3506  
3507 cmd=read_nic_byte(dev,CMD);
3508 write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
3509 #if 0
3510 - /* In rtl8139 driver seems that DMA threshold has to be written
3511 - * after enabling RX, so we rewrite RX_CONFIG register
3512 + /* In rtl8139 driver seems that DMA threshold has to be written
3513 + * after enabling RX, so we rewrite RX_CONFIG register
3514 */
3515 //mdelay(100);
3516 - write_nic_dword(dev, RX_CONF, rxconf);
3517 -
3518 + write_nic_dword(dev, RX_CONF, rxconf);
3519 +
3520 #endif
3521 -
3522 +
3523 }
3524  
3525  
3526 @@ -810,37 +848,37 @@
3527 u8 cmd;
3528 u8 byte;
3529 u32 txconf;
3530 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3531 -
3532 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3533 +
3534 byte = read_nic_byte(dev,CW_CONF);
3535 byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
3536 byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
3537 write_nic_byte(dev, CW_CONF, byte);
3538 -
3539 +
3540 byte = read_nic_byte(dev, TX_AGC_CTL);
3541 byte &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
3542 byte &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
3543 byte &= ~(1<<TX_AGC_CTL_FEEDBACK_ANT);
3544 write_nic_byte(dev, TX_AGC_CTL, byte);
3545 -
3546 +
3547 txconf= read_nic_dword(dev,TX_CONF);
3548 -
3549 +
3550 #if 0
3551 if(priv->card_8185){
3552 -
3553 +
3554 txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
3555 -
3556 +
3557 }else{
3558 -
3559 - if(priv->ieee80211->hw_seq)
3560 +
3561 + if(priv->ieee80211->hw_seq)
3562 txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3563 - else
3564 + else
3565 txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3566 }
3567 #endif
3568  
3569 txconf = txconf &~ TX_LOOPBACK_MASK;
3570 -
3571 +
3572 #ifndef LOOP_TEST
3573 txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
3574 #else
3575 @@ -848,23 +886,26 @@
3576 #endif
3577 txconf = txconf &~ TCR_DPRETRY_MASK;
3578 txconf = txconf &~ TCR_RTSRETRY_MASK;
3579 -
3580 - txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3581 - txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3582 -
3583 +
3584 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3585 + {
3586 + txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3587 + txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3588 + }
3589 +
3590 txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
3591 -
3592 +
3593 txconf = txconf &~ TCR_MXDMA_MASK;
3594 txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
3595 -
3596 +
3597 txconf = txconf | TCR_CWMIN;
3598 txconf = txconf | TCR_DISCW;
3599 txconf = txconf &~ TCR_SWPLCPLEN;
3600 -
3601 +
3602 txconf=txconf | (1<<TX_NOICV_SHIFT);
3603 -
3604 +
3605 write_nic_dword(dev,TX_CONF,txconf);
3606 -
3607 +
3608 // V RTL suggested V //
3609 // write_nic_dword(dev,TX_CONF,0x00e00707);
3610  
3611 @@ -872,9 +913,9 @@
3612 #ifdef DEBUG_TX
3613 DMESG("txconf: %x %x",txconf,read_nic_dword(dev,TX_CONF));
3614 #endif
3615 -
3616 +
3617 cmd=read_nic_byte(dev,CMD);
3618 - write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3619 + write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3620  
3621 // mdelay(100);
3622 //write_nic_dword(dev,TX_CONF,txconf);
3623 @@ -889,18 +930,18 @@
3624 #if 0
3625 void rtl8180_beacon_tx_enable(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 + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3633 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
3634 }
3635  
3636  
3637 void rtl8180_
3638 -_disable(struct net_device *dev)
3639 +_disable(struct net_device *dev)
3640 {
3641 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3642 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3643 priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
3644 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3645 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3646 @@ -914,8 +955,8 @@
3647 {
3648 u8 cmd;
3649 int i;
3650 - struct r8180_priv *priv = ieee80211_priv(dev);
3651 -
3652 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3653 +
3654 cmd=read_nic_byte(dev,CMD);
3655 write_nic_byte(dev, CMD, cmd &~ \
3656 ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT)));
3657 @@ -926,9 +967,9 @@
3658 usb_kill_urb(priv->rx_urb[i]);
3659 }
3660 /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT))
3661 - udelay(10);
3662 + udelay(10);
3663 */
3664 -
3665 +
3666 // if(!priv->rx_skb_complete)
3667 // dev_kfree_skb_any(priv->rx_skb);
3668 }
3669 @@ -939,14 +980,14 @@
3670 #if 0
3671 int i;
3672 u32 *tmp;
3673 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3674 -
3675 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3676 +
3677 priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
3678 - sizeof(u32)*8*count,
3679 + sizeof(u32)*8*count,
3680 &priv->txbeaconringdma);
3681 if (!priv->txbeaconring) return -1;
3682 for (tmp=priv->txbeaconring,i=0;i<count;i++){
3683 - *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3684 + *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3685 /*
3686 *(tmp+2) = (u32)dma_tmp;
3687 *(tmp+3) = bufsize;
3688 @@ -955,7 +996,7 @@
3689 *(tmp+4) = (u32)priv->txbeaconringdma+((i+1)*8*4);
3690 else
3691 *(tmp+4) = (u32)priv->txbeaconringdma;
3692 -
3693 +
3694 tmp=tmp+8;
3695 }
3696 #endif
3697 @@ -965,15 +1006,15 @@
3698  
3699 void rtl8180_reset(struct net_device *dev)
3700 {
3701 -
3702 +
3703 u8 cr;
3704 -
3705 +
3706 /* make sure the analog power is on before
3707 * reset, otherwise reset may fail
3708 */
3709 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3710 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3711 -
3712 +
3713 rtl8180_irq_disable(dev);
3714  
3715 mdelay(200);
3716 @@ -981,19 +1022,19 @@
3717 write_nic_byte_E(dev,0x18,0x11);
3718 write_nic_byte_E(dev,0x18,0x00);
3719 mdelay(200);
3720 -
3721 +
3722 cr=read_nic_byte(dev,CMD);
3723 cr = cr & 2;
3724 cr = cr | (1<<CMD_RST_SHIFT);
3725 write_nic_byte(dev,CMD,cr);
3726 -
3727 +
3728 force_pci_posting(dev);
3729 -
3730 +
3731 mdelay(200);
3732 -
3733 - if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3734 +
3735 + if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3736 DMESGW("Card reset timeout!");
3737 - else
3738 + else
3739 DMESG("Card successfully reset");
3740  
3741 rtl8180_set_mode(dev,EPROM_CMD_LOAD);
3742 @@ -1005,13 +1046,13 @@
3743 */
3744 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3745 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3746 -
3747 +
3748 }
3749  
3750 inline u16 ieeerate2rtlrate(int rate)
3751 {
3752 switch(rate){
3753 - case 10:
3754 + case 10:
3755 return 0;
3756 case 20:
3757 return 1;
3758 @@ -1037,32 +1078,42 @@
3759 return 11;
3760 default:
3761 return 3;
3762 -
3763 +
3764 }
3765 }
3766 static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
3767 inline u16 rtl8180_rate2rate(short rate)
3768 {
3769 if (rate >11) return 0;
3770 - return rtl_rate[rate];
3771 + return rtl_rate[rate];
3772 +}
3773 +
3774 +inline u8 rtl8180_IsWirelessBMode(u16 rate)
3775 +{
3776 + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
3777 + return 1;
3778 + else return 0;
3779 }
3780 -
3781  
3782 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3783 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs)
3784 +#else
3785 +void rtl8187_rx_isr(struct urb *rx_urb)
3786 +#endif
3787 {
3788 struct net_device *dev = (struct net_device*)rx_urb->context;
3789 - struct r8180_priv *priv = ieee80211_priv(dev);
3790 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3791  
3792 priv->rxurb_task = rx_urb;
3793 // DMESGW("David: Rx tasklet start!");
3794 - tasklet_schedule(&priv->irq_rx_tasklet);
3795 + tasklet_schedule(&priv->irq_rx_tasklet);
3796 // DMESGW("=David: Rx tasklet finish!");
3797 }
3798  
3799 #if 0
3800 void rtl8180_tx_queues_stop(struct net_device *dev)
3801 {
3802 - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3803 + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3804 u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3805 dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
3806 dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
3807 @@ -1078,7 +1129,7 @@
3808 {
3809 //FIXME !!
3810 #if 0
3811 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3812 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3813 priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3814 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3815 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3816 @@ -1091,7 +1142,7 @@
3817 {
3818 // FIXME !!
3819 #if 0
3820 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3821 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3822 priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3823 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3824 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3825 @@ -1105,14 +1156,19 @@
3826 */
3827 void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
3828 {
3829 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3830 -
3831 - short morefrag = 0;
3832 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3833 +
3834 + short morefrag = 0;
3835 unsigned long flags;
3836 struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data;
3837  
3838 - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3839 - morefrag = 1;
3840 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1)
3841 + {
3842 + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3843 + {
3844 + morefrag = 1;
3845 + }
3846 + }
3847 // DMESG("%x %x", h->frame_ctl, h->seq_ctl);
3848 /*
3849 * This function doesn't require lock because we make
3850 @@ -1121,24 +1177,29 @@
3851 * the ieee stack, or from the try_wake_queue (again trought
3852 * the ieee stack.
3853 */
3854 - spin_lock_irqsave(&priv->tx_lock,flags);
3855 -
3856 - //DMESG("TX");
3857 - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3858 - DMESG("Error: no TX slot ");
3859 - ieee80211_stop_queue(priv->ieee80211);
3860 - }
3861 -
3862 - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3863 - ieeerate2rtlrate(rate));
3864 -
3865 - priv->stats.txdatapkt++;
3866 -
3867 - if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3868 - ieee80211_stop_queue(priv->ieee80211);
3869 -
3870 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3871 -
3872 +
3873 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0)
3874 + {
3875 + spin_lock_irqsave(&priv->tx_lock,flags);
3876 + //DMESG("TX");
3877 + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3878 + DMESG("Error: no TX slot ");
3879 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3880 + }
3881 + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3882 + ieeerate2rtlrate(rate));
3883 +
3884 + priv->stats.txdatapkt++;
3885 +
3886 + if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3887 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3888 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3889 + }
3890 + else
3891 + {
3892 + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate));
3893 + }
3894 +
3895 }
3896 #if 0
3897 /* This is a rough attempt to TX a frame
3898 @@ -1148,12 +1209,12 @@
3899 */
3900 int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
3901 {
3902 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3903 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3904 int ret;
3905 unsigned long flags;
3906 -
3907 +
3908 spin_lock_irqsave(&priv->tx_lock,flags);
3909 -
3910 +
3911 ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE);
3912 /*
3913 int i;
3914 @@ -1163,9 +1224,9 @@
3915 */
3916 priv->ieee80211->stats.tx_bytes+=skb->len;
3917 priv->ieee80211->stats.tx_packets++;
3918 -
3919 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3920 -
3921 +
3922 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3923 +
3924 dev_kfree_skb_any(skb);
3925 return ret;
3926 }
3927 @@ -1178,7 +1239,7 @@
3928 u16 duration;
3929 u16 drift;
3930 *ext=0;
3931 -
3932 +
3933 switch(rate){
3934 case 0://1mbps
3935 *ext=0;
3936 @@ -1187,7 +1248,7 @@
3937 if(drift ==0 ) break;
3938 duration++;
3939 break;
3940 -
3941 +
3942 case 1://2mbps
3943 *ext=0;
3944 duration = ((len+4)<<4) /0x4;
3945 @@ -1195,40 +1256,44 @@
3946 if(drift ==0 ) break;
3947 duration++;
3948 break;
3949 -
3950 +
3951 case 2: //5.5mbps
3952 *ext=0;
3953 duration = ((len+4)<<4) /0xb;
3954 drift = ((len+4)<<4) % 0xb;
3955 - if(drift ==0 )
3956 + if(drift ==0 )
3957 break;
3958 duration++;
3959 break;
3960 -
3961 +
3962 default:
3963 - case 3://11mbps
3964 + case 3://11mbps
3965 *ext=0;
3966 duration = ((len+4)<<4) /0x16;
3967 drift = ((len+4)<<4) % 0x16;
3968 - if(drift ==0 )
3969 + if(drift ==0 )
3970 break;
3971 duration++;
3972 - if(drift > 6)
3973 + if(drift > 6)
3974 break;
3975 *ext=1;
3976 break;
3977 }
3978 -
3979 +
3980 return duration;
3981 }
3982 #endif
3983  
3984 void rtl8180_try_wake_queue(struct net_device *dev, int pri);
3985  
3986 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3987 void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs)
3988 +#else
3989 +void rtl8187_lptx_isr(struct urb *tx_urb)
3990 +#endif
3991 {
3992 struct net_device *dev = (struct net_device*)tx_urb->context;
3993 - struct r8180_priv *priv = ieee80211_priv(dev);
3994 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3995 if(tx_urb->status == 0)
3996 priv->stats.txlpokint++;
3997 else
3998 @@ -1239,6 +1304,15 @@
3999 rtl8180_try_wake_queue(dev,LOW_PRIORITY);
4000 }
4001  
4002 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
4003 +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs)
4004 +#else
4005 +void rtl8187_lptx_isr_fast(struct urb *tx_urb)
4006 +#endif
4007 +{
4008 + kfree(tx_urb->transfer_buffer);
4009 + usb_free_urb(tx_urb);
4010 +}
4011  
4012 void rtl8187_beacon_stop(struct net_device *dev)
4013 {
4014 @@ -1249,55 +1323,55 @@
4015 if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
4016 (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
4017 write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
4018 - write_nic_byte(dev, MSR, msr);
4019 + write_nic_byte(dev, MSR, msr);
4020 }
4021 -
4022 -
4023 +
4024 +
4025 }
4026  
4027  
4028 void rtl8187_net_update(struct net_device *dev)
4029 {
4030  
4031 - struct r8180_priv *priv = ieee80211_priv(dev);
4032 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4033 struct ieee80211_network *net;
4034 net = & priv->ieee80211->current_network;
4035 -
4036 -
4037 +
4038 +
4039 write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]);
4040 write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]);
4041 //for(i=0;i<ETH_ALEN;i++)
4042 // write_nic_byte(dev,BSSID+i,net->bssid[i]);
4043  
4044 rtl8180_update_msr(dev);
4045 -
4046 +
4047 // rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
4048 write_nic_word(dev, AtimWnd, 2);
4049 - write_nic_word(dev, AtimtrItv, 100);
4050 + write_nic_word(dev, AtimtrItv, 100);
4051 write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval);
4052 write_nic_word(dev, BcnIntTime, 100);
4053 -
4054 +
4055  
4056 }
4057  
4058 void rtl8187_beacon_tx(struct net_device *dev)
4059 {
4060  
4061 - struct r8180_priv *priv = ieee80211_priv(dev);
4062 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4063 struct sk_buff *skb;
4064 int i = 0;
4065 -
4066 +
4067 rtl8187_net_update(dev);
4068 -
4069 - skb = ieee80211_get_beacon(priv->ieee80211);
4070 -
4071 -
4072 - if(!skb){
4073 +
4074 + skb = ieee80211_get_beacon_rtl7(priv->ieee80211);
4075 +
4076 +
4077 + if(!skb){
4078 DMESG("not enought memory for allocating beacon");
4079 return;
4080 }
4081 -
4082 -#if 0
4083 +
4084 +#if 0
4085 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){
4086 msleep_interruptible_rtl(HZ/2);
4087 if(i++ > 20){
4088 @@ -1307,7 +1381,7 @@
4089 }
4090 #endif
4091 write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7));
4092 -
4093 +
4094 i=0;
4095 //while(!read_nic_byte(dev,BQREQ & (1<<7)))
4096 while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 )
4097 @@ -1318,16 +1392,20 @@
4098 return ;
4099 }
4100 }
4101 -
4102 +
4103 rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY,
4104 0, priv->ieee80211->basic_rate);
4105 -
4106 +
4107 }
4108  
4109 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
4110 void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs)
4111 +#else
4112 +void rtl8187_nptx_isr(struct urb *tx_urb)
4113 +#endif
4114 {
4115 struct net_device *dev = (struct net_device*)tx_urb->context;
4116 - struct r8180_priv *priv = ieee80211_priv(dev);
4117 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4118 if(tx_urb->status == 0)
4119 priv->stats.txnpokint++;
4120 else
4121 @@ -1339,10 +1417,10 @@
4122 }
4123  
4124  
4125 -/* This function do the real dirty work: it sends a TX command
4126 - * descriptor plus data URB
4127 +/* This function do the real dirty work: it sends a TX command
4128 + * descriptor plus data URB
4129 */
4130 -
4131 +
4132 short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority,
4133 short morefrag, short rate)
4134 {
4135 @@ -1352,12 +1430,12 @@
4136 int pend ;
4137 int status;
4138 struct urb *tx_urb;
4139 - int urb_len;
4140 - struct r8180_priv *priv = ieee80211_priv(dev);
4141 + int urb_len;
4142 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4143 // int rate = ieeerate2rtlrate(priv->ieee80211->rate);
4144  
4145 - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
4146 - /* we are locked here so the two atomic_read and inc are executed without interleaves */
4147 + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
4148 + /* we are locked here so the two atomic_read and inc are executed without interleaves */
4149 if( pend > MAX_TX_URB){
4150 if(priority == NORM_PRIORITY)
4151 priv->stats.txnpdrop++;
4152 @@ -1365,52 +1443,38 @@
4153 priv->stats.txlpdrop++;
4154 return -1;
4155 }
4156 -
4157 -
4158 +
4159 //tx = kmalloc((len + 4*3), GFP_ATOMIC);
4160 urb_len = len + 4*3;
4161 if((0 == urb_len%64)||(0 == urb_len%512)) {
4162 - urb_len += 1;
4163 + urb_len += 1;
4164 }
4165 tx = kmalloc(urb_len, GFP_ATOMIC);
4166 if(!tx) return -ENOMEM;
4167 - //printk(KERN_WARNING "urb_len = %d\n", urb_len);
4168 + //printk(KERN_WARNING "urb_len = %d\n", urb_len);
4169 tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
4170 -
4171 +
4172 if(!tx_urb){
4173 -
4174 +
4175 kfree(tx);
4176 return -ENOMEM;
4177 }
4178 -
4179 +
4180 memcpy(tx+3,txbuf,len);
4181 tx[0] = 0;
4182 tx[0] |= len & 0xfff;
4183 tx[0] |= (1<<15);
4184 -
4185 -// if(priv->shortpre)
4186 -// tx[0] |= (1<<16);
4187 -
4188 - //if(len > priv->rts_threshold){
4189 -// tx[0] |= (1<<23); //ENABLE RTS
4190 -// tx[0] |= (1<<18); //ENABLE CTS
4191 - //}
4192 +
4193 if(morefrag) tx[0] |= (1<<17);
4194 tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
4195 tx[0] |= (rate << 24);
4196 tx[1] = 0;
4197 -
4198 -// duration = rtl8180_len2duration(len,
4199 -// rate,&ext);
4200 -// tx[1] |= (duration & 0x7fff) <<16;
4201 -// if(ext) tx[1] |= (1<<31);
4202  
4203 -
4204 // tx[2] = 0x303020;
4205 tx[2] = 3; // CW min
4206 tx[2] |= (7<<4); //CW max
4207 tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim
4208 -
4209 +
4210 // printk("%x\n%x\n",tx[0],tx[1]);
4211  
4212 #ifdef DUMP_TX
4213 @@ -1421,7 +1485,7 @@
4214 printk("---------------\n");
4215 #endif
4216  
4217 -
4218 +
4219 /* FIXME check what EP is for low/norm PRI */
4220 usb_fill_bulk_urb(tx_urb,priv->udev,
4221 usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx,
4222 @@ -1438,54 +1502,97 @@
4223 }
4224 }
4225  
4226 -
4227 +/* This function do the real dirty work: it sends a TX command
4228 + * descriptor plus data URB (fast)
4229 + */
4230 +
4231 +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate)
4232 +{
4233 + u32 *tx;
4234 + int status;
4235 + struct urb *tx_urb;
4236 + int urb_len;
4237 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4238 +
4239 + urb_len = len + 4*3;
4240 + if((0 == urb_len%64)||(0 == urb_len%512)) {
4241 + urb_len += 1;
4242 + }
4243 + tx = kmalloc(urb_len, GFP_ATOMIC);
4244 + if(!tx) return -ENOMEM;
4245 +
4246 + tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
4247 +
4248 + if(!tx_urb){
4249 + kfree(tx);
4250 + return -ENOMEM;
4251 + }
4252 +
4253 + memcpy(tx+3,txbuf,len);
4254 + tx[0] = (len & 0xfff) + 0x8000;
4255 + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
4256 + tx[0] |= (rate << 24);
4257 + tx[1] = 0;
4258 + tx[2] = 2931;
4259 +
4260 + /* FIXME check what EP is for low/norm PRI */
4261 + usb_fill_bulk_urb(tx_urb,priv->udev,
4262 + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev);
4263 + status = usb_submit_urb(tx_urb, GFP_ATOMIC);
4264 + if (!status){
4265 + return 0;
4266 + }else{
4267 + return -1;
4268 + }
4269 +}
4270 +
4271  
4272 void rtl8180_irq_rx_tasklet(struct r8180_priv * priv);
4273  
4274  
4275 short rtl8187_usb_initendpoints(struct net_device *dev)
4276 {
4277 - struct r8180_priv *priv = ieee80211_priv(dev);
4278 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4279 int i;
4280 -
4281 +
4282 priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL);
4283 -
4284 +
4285 for(i=0;i<MAX_RX_URB;i++){
4286 priv->rx_urb[i] = usb_alloc_urb(0,GFP_KERNEL);
4287 - if(!priv->rx_urb[i])
4288 + if(!priv->rx_urb[i])
4289 goto destroy;
4290 -
4291 +
4292 priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
4293 - if(!priv->rx_urb[i]->transfer_buffer)
4294 + if(!priv->rx_urb[i]->transfer_buffer)
4295 goto destroy1;
4296 -
4297 +
4298 priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
4299 }
4300 -
4301 +
4302 return 0;
4303 -
4304 +
4305 destroy1:
4306 usb_free_urb(priv->rx_urb[i]);
4307 -
4308 +
4309 destroy:
4310 while (--i >= 0){
4311 kfree(priv->rx_urb[i]->transfer_buffer);
4312 usb_free_urb(priv->rx_urb[i]);
4313 }
4314 -
4315 +
4316 kfree(priv->rx_urb);
4317 -
4318 +
4319 priv->rx_urb = NULL;
4320 DMESGE("Endpoint Alloc Failure");
4321 return -ENOMEM;
4322 -
4323 +
4324 }
4325  
4326 void rtl8187_usb_deleteendpoints(struct net_device *dev)
4327 {
4328 - struct r8180_priv *priv = ieee80211_priv(dev);
4329 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4330 int i;
4331 -
4332 +
4333 if(priv->rx_urb){
4334 for(i=0;i<MAX_RX_URB;i++){
4335 usb_kill_urb(priv->rx_urb[i]);
4336 @@ -1494,9 +1601,9 @@
4337 }
4338 kfree(priv->rx_urb);
4339 priv->rx_urb = NULL;
4340 -
4341 +
4342 }
4343 -
4344 +
4345 }
4346  
4347  
4348 @@ -1505,16 +1612,16 @@
4349 int i;
4350 u16 word;
4351 int basic_rate,min_rr_rate,max_rr_rate;
4352 -
4353 -// struct r8180_priv *priv = ieee80211_priv(dev);
4354 -
4355 - //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
4356 +
4357 +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4358 +
4359 + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) &&
4360 // priv->ieee80211->state == IEEE80211_LINKED){
4361 basic_rate = ieeerate2rtlrate(240);
4362 min_rr_rate = ieeerate2rtlrate(60);
4363 max_rr_rate = ieeerate2rtlrate(240);
4364 -
4365 -//
4366 +
4367 +//
4368 // }else{
4369 // basic_rate = ieeerate2rtlrate(20);
4370 // min_rr_rate = ieeerate2rtlrate(10);
4371 @@ -1526,21 +1633,21 @@
4372  
4373 word = read_nic_word(dev, BRSR);
4374 word &= ~BRSR_MBR_8185;
4375 -
4376 +
4377  
4378 for(i=0;i<=basic_rate;i++)
4379 word |= (1<<i);
4380  
4381 write_nic_word(dev, BRSR, word);
4382 - //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
4383 + DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
4384 }
4385  
4386  
4387 void rtl8187_link_change(struct net_device *dev)
4388 {
4389 // int i;
4390 -
4391 - struct r8180_priv *priv = ieee80211_priv(dev);
4392 +
4393 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4394 //write_nic_word(dev, BintrItv, net->beacon_interval);
4395 rtl8187_net_update(dev);
4396 /*update timing params*/
4397 @@ -1553,24 +1660,24 @@
4398  
4399 short rtl8180_init(struct net_device *dev)
4400 {
4401 -
4402 - struct r8180_priv *priv = ieee80211_priv(dev);
4403 +
4404 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4405 int i, j;
4406 u16 word;
4407 - int ch;
4408 + int ch, chans;
4409 //u16 version;
4410 - //u8 hw_version;
4411 - //u8 config3;
4412 -
4413 + u8 hw_version;
4414 + u8 config3;
4415 +
4416 //FIXME: these constants are placed in a bad pleace.
4417  
4418 // priv->txbuffsize = 1024;
4419 // priv->txringcount = 32;
4420 // priv->rxbuffersize = 1024;
4421 -// priv->rxringcount = 32;
4422 +// priv->rxringcount = 32;
4423 // priv->txbeaconcount = 3;
4424 // priv->rx_skb_complete = 1;
4425 - //priv->txnp_pending.ispending=0;
4426 + //priv->txnp_pending.ispending=0;
4427 /* ^^ the SKB does not containt a partial RXed
4428 * packet (is empty)
4429 */
4430 @@ -1580,15 +1687,24 @@
4431 return -1;
4432 }
4433 ch=channels;
4434 + chans=0;
4435 + for (i=1; i<=14; i++) {
4436 + if( (u8)(ch & 0x01) ) chans++;
4437 + ch >>= 1;
4438 + }
4439 + DMESG("Enabling %d channels.", chans);
4440 + ch=channels;
4441 // set channels 1..14 allowed in given locale
4442 for (i=1; i<=14; i++) {
4443 (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
4444 ch >>= 1;
4445 }
4446 //memcpy(priv->stats,0,sizeof(struct Stats));
4447 -
4448 +
4449 //priv->irq_enabled=0;
4450 -
4451 +
4452 + priv->dev = dev;
4453 +
4454 // priv->stats.rxdmafail=0;
4455 priv->stats.txrdu=0;
4456 // priv->stats.rxrdu=0;
4457 @@ -1612,33 +1728,37 @@
4458 // priv->stats.txbeaconerr=0;
4459 priv->stats.txlperr=0;
4460 priv->stats.txlpokint=0;
4461 -
4462 +
4463 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4464 -
4465 +
4466 priv->retry_rts = DEFAULT_RETRY_RTS;
4467 priv->retry_data = DEFAULT_RETRY_DATA;
4468 priv->ieee80211->rate = 110; //11 mbps
4469 priv->ieee80211->short_slot = 1;
4470 - priv->ieee80211->mode = IEEE_G;
4471 + priv->ieee80211->mode = IEEE_G|IEEE_B;
4472 priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
4473 spin_lock_init(&priv->tx_lock);
4474 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
4475 INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev);
4476 +#else
4477 + INIT_WORK(&priv->reset_wq, rtl8180_restart);
4478 +#endif
4479 sema_init(&priv->wx_sem,1);
4480 tasklet_init(&priv->irq_rx_tasklet,
4481 (void(*)(unsigned long))rtl8180_irq_rx_tasklet,
4482 (unsigned long)priv);
4483  
4484 - //priv->ieee80211->func =
4485 + //priv->ieee80211->func =
4486 // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL);
4487 //memset(priv->ieee80211->func, 0,
4488 // sizeof(struct ieee80211_helper_functions));
4489 - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4490 + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4491 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4492 - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4493 - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4494 + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4495 + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4496 IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
4497 /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE;
4498 -
4499 +
4500 priv->ieee80211->active_scan = 1;
4501 priv->ieee80211->rate = 110; //11 mbps
4502 priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
4503 @@ -1655,51 +1775,51 @@
4504 priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume;
4505 //priv->ieee80211->start_send_beacons = NULL;
4506 //priv->ieee80211->stop_send_beacons = NULL;
4507 -
4508 +
4509 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
4510 -
4511 +
4512 priv->card_8185 = 2;
4513 priv->phy_ver = 2;
4514 priv->card_type = USB;
4515 -
4516 +
4517 #if 0
4518 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4519 -
4520 +
4521 switch (hw_version){
4522 case HW_VERID_R8185_ABC:
4523 - DMESG("MAC controller is a RTL8185 b/g");
4524 + DMESG("MAC controller is a RTL8185 b/g");
4525 priv->card_8185 = 1;
4526 /* you should not find a card with 8225 PHY ver < C*/
4527 priv->phy_ver = 2;
4528 break;
4529 -
4530 +
4531 case HW_VERID_R8185_D:
4532 - DMESG("MAC controller is a RTL8185 b/g (V. D)");
4533 + DMESG("MAC controller is a RTL8185 b/g (V. D)");
4534 priv->card_8185 = 2;
4535 /* you should not find a card with 8225 PHY ver < C*/
4536 priv->phy_ver = 2;
4537 break;
4538 -
4539 +
4540 case HW_VERID_R8180_ABCD:
4541 DMESG("MAC controller is a RTL8180");
4542 priv->card_8185 = 0;
4543 break;
4544 -
4545 +
4546 case HW_VERID_R8180_F:
4547 DMESG("MAC controller is a RTL8180 (v. F)");
4548 priv->card_8185 = 0;
4549 break;
4550 -
4551 +
4552 default:
4553 DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
4554 priv->card_8185 = 0;
4555 break;
4556 }
4557 -
4558 -
4559 +
4560 +
4561 /* you should not found any 8185 Ver B Card */
4562 priv->card_8185_Bversion = 0;
4563 -
4564 +
4565 config3 = read_nic_byte(dev, CONFIG3);
4566 if(config3 & 0x8){
4567 priv->card_type = CARDBUS;
4568 @@ -1715,13 +1835,19 @@
4569 #endif
4570 priv->enable_gpio0 = 0;
4571  
4572 -
4573 +
4574 + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4575 + config3 = read_nic_byte(dev, CONFIG3);
4576 +
4577 + DMESG("MAC chip version: %02X", hw_version);
4578 + DMESG("Card type: %02X", config3);
4579 +
4580 /* commented out just because we already do
4581 this when resetting the card
4582 andrea 20050924
4583 */
4584 #if 0
4585 -
4586 +
4587 u8 txcr, txreg50;
4588 u32 txreg54, txreg60;
4589  
4590 @@ -1757,8 +1883,8 @@
4591 // DMESG("<<txcr:%x>>", txcr);
4592  
4593 #endif
4594 -
4595 - /*the eeprom type is stored in RCR register bit #6 */
4596 +
4597 + /*the eeprom type is stored in RCR register bit #6 */
4598 if (RCR_9356SEL & read_nic_dword(dev, RCR)){
4599 priv->epromtype=EPROM_93c56;
4600 DMESG("Reported EEPROM chip is a 93c56 (2Kbit)");
4601 @@ -1766,58 +1892,73 @@
4602 priv->epromtype=EPROM_93c46;
4603 DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
4604 }
4605 -
4606 +
4607 dev->get_stats = rtl8180_stats;
4608 -
4609 +
4610 dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
4611 dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
4612 dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
4613 dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
4614 dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
4615 dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
4616 -
4617 +
4618 DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr));
4619 -
4620 +
4621 for(i=1,j=0; i<6; i+=2,j++){
4622 -
4623 +
4624 word = eprom_read(dev,EPROM_TXPW0 + j);
4625 priv->chtxpwr[i]=word & 0xf;
4626 priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4;
4627 priv->chtxpwr[i+1]=(word & 0xf00)>>8;
4628 priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12;
4629 }
4630 -
4631 +
4632 for(i=1,j=0; i<4; i+=2,j++){
4633 -
4634 +
4635 word = eprom_read(dev,EPROM_TXPW1 + j);
4636 priv->chtxpwr[i+6]=word & 0xf;
4637 priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4;
4638 priv->chtxpwr[i+6+1]=(word & 0xf00)>>8;
4639 priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12;
4640 }
4641 -
4642 +
4643 for(i=1,j=0; i<4; i+=2,j++){
4644 -
4645 +
4646 word = eprom_read(dev,EPROM_TXPW2 + j);
4647 priv->chtxpwr[i+6+4]=word & 0xf;
4648 priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4;
4649 priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8;
4650 priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12;
4651 }
4652 -
4653 -
4654 +
4655 +
4656 priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID);
4657 -
4658 +
4659 +#ifdef DEBUG_TX_POWER
4660 + dump_tx_power(dev);
4661 +#endif
4662 +
4663 + DMESG("RF Chip ID: %02X", priv->rf_chip);
4664 +
4665 word = eprom_read(dev,EPROM_TXPW_BASE);
4666 priv->cck_txpwr_base = word & 0xf;
4667 priv->ofdm_txpwr_base = (word>>4) & 0xf;
4668 -
4669 +
4670 + priv->txpwr_max = 0;
4671 + for(i=1; i<15; i++)
4672 + {
4673 + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i];
4674 + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i];
4675 + priv->chtxpwr_orig[i] = priv->chtxpwr[i];
4676 + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i];
4677 + }
4678 +
4679 /* check RF frontend chipset */
4680 -
4681 +
4682 switch (priv->rf_chip) {
4683 -
4684 +
4685 case EPROM_RFCHIPID_RTL8225U:
4686 -
4687 +
4688 DMESG("Card reports RF frontend Realtek 8225");
4689 DMESGW("This driver has EXPERIMENTAL support for this chipset.");
4690 DMESGW("use it with care and at your own risk and");
4691 @@ -1834,28 +1975,28 @@
4692 DMESG("This seems a legacy 1st version radio");
4693 }
4694 priv->rf_close = rtl8225_rf_close;
4695 -
4696 +
4697 priv->max_sens = RTL8225_RF_MAX_SENS;
4698 priv->sens = RTL8225_RF_DEF_SENS;
4699 break;
4700 -
4701 +
4702 default:
4703 DMESGW("Unknown RF module %x",priv->rf_chip);
4704 DMESGW("Exiting...");
4705 return -1;
4706 -
4707 +
4708 }
4709 -
4710 +
4711 // DMESG("Energy threshold: %x",priv->cs_treshold);
4712 DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7);
4713 //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2));
4714 -
4715 - if(rtl8187_usb_initendpoints(dev)!=0){
4716 +
4717 + if(rtl8187_usb_initendpoints(dev)!=0){
4718 DMESG("Endopoints initialization failed");
4719 return -ENOMEM;
4720 }
4721 -#if 0
4722 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4723 +#if 0
4724 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4725 return -ENOMEM;
4726  
4727 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4728 @@ -1869,16 +2010,16 @@
4729 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4730 TX_LOWPRIORITY_RING_ADDR))
4731 return -ENOMEM;
4732 -
4733 -
4734 +
4735 +
4736 if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount))
4737 return -ENOMEM;
4738 #endif
4739 -
4740 +
4741  
4742 #ifdef DEBUG_EPROM
4743 dump_eprom(dev);
4744 -#endif
4745 +#endif
4746 return 0;
4747  
4748 }
4749 @@ -1898,7 +2039,7 @@
4750 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4751  
4752 conf3 = read_nic_byte(dev, CONFIG3);
4753 - write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4754 + write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4755  
4756 write_nic_dword(dev, ANAPARAM2, a);
4757  
4758 @@ -1918,23 +2059,23 @@
4759  
4760 conf3 = read_nic_byte(dev, CONFIG3);
4761 write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4762 -
4763 +
4764 write_nic_dword(dev, ANAPARAM, a);
4765  
4766 conf3 = read_nic_byte(dev, CONFIG3);
4767 write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
4768  
4769 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4770 -
4771 +
4772 }
4773  
4774  
4775 void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
4776 {
4777 - write_nic_byte(dev, TX_ANTENNA, ant);
4778 + write_nic_byte(dev, TX_ANTENNA, ant);
4779 force_pci_posting(dev);
4780 mdelay(1);
4781 -}
4782 +}
4783  
4784  
4785 void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data)
4786 @@ -1942,26 +2083,26 @@
4787 //u8 phyr;
4788 u32 phyw;
4789 // int i;
4790 -
4791 +
4792 adr |= 0x80;
4793 -
4794 +
4795 phyw= ((data<<8) | adr);
4796 -
4797 -
4798 -
4799 - // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4800 +
4801 +
4802 +
4803 + // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4804 write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24));
4805 write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16));
4806 write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8));
4807 write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) ));
4808  
4809 //read_nic_dword(dev, PHY_ADR);
4810 -#if 0
4811 +#if 0
4812 for(i=0;i<10;i++){
4813 write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw);
4814 phyr = read_nic_byte(dev, PHY_READ);
4815 if(phyr == (data&0xff)) break;
4816 -
4817 +
4818 }
4819 #endif
4820 /* this is ok to fail when we write AGC table. check for AGC table might be
4821 @@ -1988,60 +2129,60 @@
4822  
4823 void rtl8180_adapter_start(struct net_device *dev)
4824 {
4825 - struct r8180_priv *priv = ieee80211_priv(dev);
4826 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4827 //u32 anaparam;
4828 //u8 config3;
4829 -
4830 +
4831 //rtl8180_rtx_disable(dev);
4832 rtl8180_reset(dev);
4833  
4834 write_nic_byte(dev,0x85,0);
4835 write_nic_byte(dev,0x91,0);
4836 -
4837 +
4838 /* light blink! */
4839 write_nic_byte(dev,0x85,4);
4840 write_nic_byte(dev,0x91,1);
4841 write_nic_byte(dev,0x90,0);
4842 -
4843 +
4844 priv->irq_mask = 0xffff;
4845 /*
4846 priv->dma_poll_mask = 0;
4847 priv->dma_poll_mask|= (1<<TX_DMA_STOP_BEACON_SHIFT);
4848 -*/
4849 +*/
4850 // rtl8180_beacon_tx_disable(dev);
4851 -
4852 +
4853 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4854 write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]);
4855 write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff );
4856  
4857 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4858 rtl8180_update_msr(dev);
4859 -
4860 +
4861 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4862 -
4863 +
4864 write_nic_word(dev,0xf4,0xffff);
4865 write_nic_byte(dev,
4866 - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4867 + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4868  
4869 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4870 -
4871 - write_nic_dword(dev,INT_TIMEOUT,0);
4872 +
4873 + write_nic_dword(dev,INT_TIMEOUT,0);
4874  
4875 #ifdef DEBUG_REGISTERS
4876 - rtl8180_dump_reg(dev);
4877 + rtl8180_dump_reg(dev);
4878 #endif
4879 -
4880 -
4881 - write_nic_byte(dev, WPA_CONFIG, 0);
4882 +
4883 +
4884 + write_nic_byte(dev, WPA_CONFIG, 0);
4885  
4886 write_nic_byte(dev, RATE_FALLBACK, 0x81);
4887 rtl8187_set_rate(dev);
4888 -
4889 - priv->rf_init(dev);
4890 +
4891 + priv->rf_init(dev);
4892  
4893 if(priv->rf_set_sens != NULL)
4894 - priv->rf_set_sens(dev,priv->sens);
4895 -
4896 + priv->rf_set_sens(dev,priv->sens);
4897 +
4898 write_nic_word(dev,0x5e,1);
4899  
4900 #if 1
4901 @@ -2054,13 +2195,13 @@
4902 write_nic_byte(dev, 0xff, 0x60);
4903  
4904 write_nic_word(dev,0x5e,0);
4905 -
4906 -
4907 +
4908 +
4909 rtl8180_irq_enable(dev);
4910 /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY));
4911 -
4912 +
4913 DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY));
4914 -
4915 +
4916 DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY));
4917 if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK");
4918 if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK");
4919 @@ -2077,8 +2218,8 @@
4920 void rtl8180_start_tx_beacon(struct net_device *dev)
4921 {
4922 int i;
4923 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
4924 - u16 word;
4925 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
4926 + u16 word;
4927 DMESG("Enabling beacon TX");
4928 //write_nic_byte(dev, 0x42,0xe6);// TCR
4929 //rtl8180_init_beacon(dev);
4930 @@ -2091,41 +2232,41 @@
4931 //write_nic_word(dev,0x7a,0);
4932 //write_nic_word(dev,0x7a,0x8000);
4933  
4934 -
4935 +
4936 word = read_nic_word(dev, BcnItv);
4937 word &= ~BcnItv_BcnItv; // clear Bcn_Itv
4938 write_nic_word(dev, BcnItv, word);
4939  
4940 - write_nic_word(dev, AtimWnd,
4941 + write_nic_word(dev, AtimWnd,
4942 read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd);
4943 -
4944 +
4945 word = read_nic_word(dev, BintrItv);
4946 word &= ~BintrItv_BintrItv;
4947 -
4948 - //word |= priv->ieee80211->beacon_interval *
4949 +
4950 + //word |= priv->ieee80211->beacon_interval *
4951 // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
4952 // FIXME:FIXME check if correct ^^ worked with 0x3e8;
4953 -
4954 +
4955 write_nic_word(dev, BintrItv, word);
4956 -
4957 +
4958 //write_nic_word(dev,0x2e,0xe002);
4959 //write_nic_dword(dev,0x30,0xb8c7832e);
4960 for(i=0; i<ETH_ALEN; i++)
4961 write_nic_byte(dev, BSSID+i, priv->ieee80211->beacon_cell_ssid[i]);
4962 -
4963 +
4964 // rtl8180_update_msr(dev);
4965  
4966 -
4967 +
4968 //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
4969 -
4970 +
4971 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4972 -
4973 +
4974 rtl8180_irq_enable(dev);
4975 -
4976 +
4977 /* VV !!!!!!!!!! VV*/
4978 /*
4979 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
4980 - write_nic_byte(dev,0x9d,0x00);
4981 + write_nic_byte(dev,0x9d,0x00);
4982 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4983 */
4984 }
4985 @@ -2135,137 +2276,138 @@
4986 ***************************************************************************/
4987 static struct net_device_stats *rtl8180_stats(struct net_device *dev)
4988 {
4989 - struct r8180_priv *priv = ieee80211_priv(dev);
4990 -
4991 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4992 +
4993 return &priv->ieee80211->stats;
4994 }
4995  
4996  
4997 int _rtl8180_up(struct net_device *dev)
4998 {
4999 - struct r8180_priv *priv = ieee80211_priv(dev);
5000 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5001  
5002 priv->up=1;
5003 -
5004 - //DMESG("Bringing up iface");
5005 +
5006 +// DMESG("Bringing up iface");
5007  
5008 rtl8180_adapter_start(dev);
5009 -
5010 rtl8180_rx_enable(dev);
5011 -
5012 rtl8180_tx_enable(dev);
5013 -
5014 - ieee80211_softmac_start_protocol(priv->ieee80211);
5015 -
5016 - ieee80211_reset_queue(priv->ieee80211);
5017 + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211);
5018 + ieee80211_reset_queue_rtl7(priv->ieee80211);
5019 if(!netif_queue_stopped(dev))
5020 netif_start_queue(dev);
5021 else
5022 netif_wake_queue(dev);
5023 -
5024 return 0;
5025 }
5026  
5027  
5028 int rtl8180_open(struct net_device *dev)
5029 {
5030 - struct r8180_priv *priv = ieee80211_priv(dev);
5031 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5032 int ret;
5033 -
5034 +
5035 down(&priv->wx_sem);
5036 +
5037 ret = rtl8180_up(dev);
5038 up(&priv->wx_sem);
5039 return ret;
5040 -
5041 +
5042 }
5043  
5044  
5045 int rtl8180_up(struct net_device *dev)
5046 {
5047 - struct r8180_priv *priv = ieee80211_priv(dev);
5048 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5049  
5050 if (priv->up == 1) return -1;
5051 -
5052 +
5053 return _rtl8180_up(dev);
5054 }
5055  
5056  
5057 int rtl8180_close(struct net_device *dev)
5058 {
5059 - struct r8180_priv *priv = ieee80211_priv(dev);
5060 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5061 int ret;
5062 -
5063 +
5064 down(&priv->wx_sem);
5065 -
5066 +
5067 ret = rtl8180_down(dev);
5068 -
5069 +
5070 up(&priv->wx_sem);
5071 -
5072 +
5073 return ret;
5074  
5075 }
5076  
5077 int rtl8180_down(struct net_device *dev)
5078 {
5079 - struct r8180_priv *priv = ieee80211_priv(dev);
5080 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5081  
5082 if (priv->up == 0) return -1;
5083 -
5084 +
5085 priv->up=0;
5086  
5087 /* FIXME */
5088 if (!netif_queue_stopped(dev))
5089 netif_stop_queue(dev);
5090 -
5091 +
5092 rtl8180_rtx_disable(dev);
5093 rtl8180_irq_disable(dev);
5094  
5095 - ieee80211_softmac_stop_protocol(priv->ieee80211);
5096 -
5097 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
5098 +
5099 return 0;
5100 }
5101  
5102  
5103 void rtl8180_commit(struct net_device *dev)
5104 {
5105 - struct r8180_priv *priv = ieee80211_priv(dev);
5106 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5107  
5108 if (priv->up == 0) return ;
5109 -
5110 - ieee80211_softmac_stop_protocol(priv->ieee80211);
5111 -
5112 +
5113 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
5114 +
5115 rtl8180_irq_disable(dev);
5116 rtl8180_rtx_disable(dev);
5117 _rtl8180_up(dev);
5118 }
5119  
5120 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
5121 +void rtl8180_restart(struct work_struct *work)
5122 +{
5123 + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
5124 + struct net_device *dev = priv->dev;
5125 +#else
5126 void rtl8180_restart(struct net_device *dev)
5127 {
5128 - struct r8180_priv *priv = ieee80211_priv(dev);
5129 -
5130 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5131 +#endif
5132 down(&priv->wx_sem);
5133 -
5134 rtl8180_commit(dev);
5135 -
5136 +
5137 up(&priv->wx_sem);
5138 }
5139  
5140 static void r8180_set_multicast(struct net_device *dev)
5141 {
5142 - struct r8180_priv *priv = ieee80211_priv(dev);
5143 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5144 short promisc;
5145  
5146 //down(&priv->wx_sem);
5147 -
5148 +
5149 /* FIXME FIXME */
5150 -
5151 +
5152 promisc = (dev->flags & IFF_PROMISC) ? 1:0;
5153 -
5154 +
5155 if (promisc != priv->promisc)
5156 // rtl8180_commit(dev);
5157 -
5158 +
5159 priv->promisc = promisc;
5160 -
5161 +
5162 //schedule_work(&priv->reset_wq);
5163 //up(&priv->wx_sem);
5164 }
5165 @@ -2273,17 +2415,17 @@
5166  
5167 int r8180_set_mac_adr(struct net_device *dev, void *mac)
5168 {
5169 - struct r8180_priv *priv = ieee80211_priv(dev);
5170 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5171 struct sockaddr *addr = mac;
5172 -
5173 +
5174 down(&priv->wx_sem);
5175 -
5176 +
5177 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
5178 -
5179 +
5180 schedule_work(&priv->reset_wq);
5181 -
5182 +
5183 up(&priv->wx_sem);
5184 -
5185 +
5186 return 0;
5187 }
5188  
5189 @@ -2291,16 +2433,18 @@
5190 /* based on ipw2200 driver */
5191 int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5192 {
5193 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5194 -
5195 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5196 + struct iwreq *wrq;
5197 + int ret;
5198 +
5199 down(&priv->wx_sem);
5200 -
5201 - struct iwreq *wrq = (struct iwreq *)rq;
5202 -
5203 - int ret=-1;
5204 +
5205 + wrq = (struct iwreq *)rq;
5206 +
5207 + ret=-1;
5208 switch (cmd) {
5209 case RTL_IOCTL_WPA_SUPPLICANT:
5210 - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
5211 + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data);
5212 break;
5213  
5214 default:
5215 @@ -2309,7 +2453,7 @@
5216 }
5217  
5218 up(&priv->wx_sem);
5219 -
5220 +
5221 return ret;
5222 }
5223  
5224 @@ -2320,10 +2464,11 @@
5225 struct net_device *dev = (struct net_device*)rx_urb->context;
5226 int status,len,flen;
5227 struct sk_buff *skb;
5228 - u32 *desc;
5229 -
5230 + u8 *desc;
5231 + u8 signal,quality,rate;
5232 +
5233 //DMESG("rtl8187_rx_isr");
5234 -
5235 +
5236 struct ieee80211_rx_stats stats = {
5237 .signal = 0,
5238 .noise = -98,
5239 @@ -2332,43 +2477,109 @@
5240 .freq = IEEE80211_24GHZ_BAND,
5241 };
5242  
5243 +
5244 //DMESG("RX %d ",rx_urb->status);
5245 status = rx_urb->status;
5246 if(status == 0){
5247 -
5248 +
5249 len = rx_urb->actual_length;
5250 - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
5251 + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
5252 len -= 4*4;/* 4 dword and 4 byte CRC */
5253 -
5254 +#if 0
5255 desc = (u32*)(rx_urb->transfer_buffer + len);
5256 -
5257 +
5258 flen = desc[0] & 0xfff;
5259 -
5260 +
5261 if( flen <= rx_urb->actual_length){
5262 -
5263 - stats.signal = (desc[1] & 0x7f00)>>8;
5264 - stats.noise = desc[1] &0xff;
5265 - stats.rate = desc[0] >> 20 & 0xf;
5266 +
5267 + //stats.signal = (desc[1] & 0x7f00)>>8;
5268 + //stats.noise = desc[1] &0xff;
5269 + signal=(desc[1]& (0xff0000))>>16;
5270 + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
5271 +
5272 + quality=(desc[1] & (0xff));
5273 +
5274 + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20;
5275 + // printk(KERN_INFO "rate is %d!\n",rate);
5276 + stats.rate = rtl8180_rate2rate(rate);
5277 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
5278 + //stats.rate = desc[0] >> 20 & 0xf;
5279 stats.mac_time[0] = desc[2];
5280 stats.mac_time[1] = desc[3];
5281 +#endif
5282 +
5283 + desc = rx_urb->transfer_buffer + len;
5284 +
5285 + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff);
5286 +
5287 + if( flen <= rx_urb->actual_length){
5288 + //stats.signal = (desc[1] & 0x7f00)>>8;
5289 + //stats.noise = desc[1] &0xff;
5290 + signal=(desc[6]& 0xfe)>>1;
5291 + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
5292 +
5293 + quality=desc[4] & 0xff;
5294 +
5295 + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4;
5296 + rate=(desc[2] & 0xf0)>>4;
5297 + // printk(KERN_INFO "rate is %d!\n",rate);
5298 + stats.rate = rtl8180_rate2rate(rate);
5299 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
5300 + //stats.rate = desc[0] >> 20 & 0xf;
5301 + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24);
5302 + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24);
5303 +
5304 +
5305 + //calculate link quality begin
5306 + if(!rtl8180_IsWirelessBMode(stats.rate) )
5307 + { // OFDM rate.
5308 + if(signal>90)
5309 + signal=90;
5310 + else if(signal<25)
5311 + signal=25;
5312 + signal = (90-signal)*100/65;
5313 + }
5314 + else
5315 + { // CCK rate.
5316 + if(signal>95)
5317 + signal = 95;
5318 + else if(signal<30)
5319 + signal = 30;
5320 + signal =(95-signal )*100/65;
5321 + }
5322 + priv->wstats.qual.level = signal;
5323 + // printk(KERN_INFO "signal is %d!\n",signal);
5324 + if(quality > 64)
5325 + priv ->wstats.qual.qual = 0;
5326 + else
5327 + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest,
5328 + //and this value only appear when STA is associated to AP or
5329 + // STA is in IBSS mode
5330 + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual);
5331 + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual;
5332 + priv->wstats.qual.updated = 7;
5333 + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR)
5334 + {
5335 + stats.signal = priv->wstats.qual.level;
5336 + stats.noise = priv->wstats.qual.noise;
5337 + }
5338 + //calculate link quality end
5339 skb = dev_alloc_skb(flen-4);
5340 - //skb_reserve(skb,2);
5341 - if(skb){
5342 + if(skb){
5343 memcpy(skb_put(skb,flen-4),
5344 rx_urb->transfer_buffer,flen -4);
5345 -
5346 +
5347 #ifdef DUMP_RX
5348 int i;
5349 for(i=0;i<flen-4;i++)
5350 printk("%2x ",((u8*)(rx_urb->transfer_buffer))[i]);
5351 printk("------RATE %x:w---------------\n",stats.rate);
5352 -
5353 +
5354 #endif
5355 priv->stats.rxok++;
5356 // priv->rxskb = skb;
5357 // priv->tempstats = &stats;
5358 -
5359 - if(!ieee80211_rx(priv->ieee80211,
5360 + if(!ieee80211_rx_rtl7(priv->ieee80211,
5361 skb, &stats))
5362 dev_kfree_skb_any(skb);
5363 }
5364 @@ -2376,9 +2587,8 @@
5365 }else{
5366 priv->stats.rxstaterr++;
5367 priv->ieee80211->stats.rx_errors++;
5368 -
5369 }
5370 -
5371 +
5372 if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb);
5373 else DMESG("RX process aborted due to explicit shutdown");
5374 }
5375 @@ -2396,20 +2606,22 @@
5376 struct r8180_priv *priv= NULL;
5377 struct usb_device *udev = interface_to_usbdev(intf);
5378  
5379 -//printk("===> rtl8187_usb_probe()\n");
5380 -
5381 - dev = alloc_ieee80211(sizeof(struct r8180_priv));
5382 -
5383 +//printk("===> rtl8187_usb_probe()\n");
5384 +
5385 + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv));
5386 +
5387 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
5388 SET_MODULE_OWNER(dev);
5389 - usb_set_intfdata(intf, dev);
5390 -
5391 +#endif
5392 + usb_set_intfdata(intf, dev);
5393 +
5394 SET_NETDEV_DEV(dev, &intf->dev);
5395  
5396 - priv = ieee80211_priv(dev);
5397 + priv = ieee80211_priv_rtl7(dev);
5398 priv->ieee80211 = netdev_priv(dev);
5399 -
5400 +
5401 priv->udev=udev;
5402 -
5403 +
5404 dev->open = rtl8180_open;
5405 dev->stop = rtl8180_close;
5406 //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit;
5407 @@ -2418,41 +2630,46 @@
5408 dev->do_ioctl = rtl8180_ioctl;
5409 dev->set_multicast_list = r8180_set_multicast;
5410 dev->set_mac_address = r8180_set_mac_adr;
5411 +#if WIRELESS_EXT >= 12
5412 +#if WIRELESS_EXT < 17
5413 dev->get_wireless_stats = r8180_get_wireless_stats;
5414 +#endif
5415 + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def;
5416 +#endif
5417 dev->type=ARPHRD_ETHER;
5418 -
5419 +
5420 if (dev_alloc_name(dev, ifname) < 0){
5421 DMESG("Oops: devname already taken! Trying wlan%%d...\n");
5422 ifname = "wlan%d";
5423 dev_alloc_name(dev, ifname);
5424 }
5425 -
5426 +
5427 // dev->open=rtl8180_init;
5428 -
5429 - if(rtl8180_init(dev)!=0){
5430 +
5431 + if(rtl8180_init(dev)!=0){
5432 DMESG("Initialization failed");
5433 goto fail;
5434 }
5435 -
5436 +
5437 netif_carrier_off(dev);
5438 netif_stop_queue(dev);
5439 -
5440 +
5441 register_netdev(dev);
5442 -
5443 +
5444 rtl8180_proc_init_one(dev);
5445 -
5446 -
5447 +
5448 +
5449 DMESG("Driver probe completed\n");
5450 - return 0;
5451 + return 0;
5452 +
5453  
5454 -
5455 fail:
5456 - free_ieee80211(dev);
5457 -
5458 + free_ieee80211_rtl7(dev);
5459 +
5460 DMESG("wlan driver load failed\n");
5461 -
5462 +
5463 return -ENODEV;
5464 -
5465 +
5466 }
5467  
5468  
5469 @@ -2461,13 +2678,13 @@
5470 struct r8180_priv *priv;
5471 struct net_device *dev = usb_get_intfdata(intf);
5472 if(dev){
5473 -
5474 +
5475 unregister_netdev(dev);
5476 -
5477 - priv=ieee80211_priv(dev);
5478 -
5479 +
5480 + priv=ieee80211_priv_rtl7(dev);
5481 +
5482 rtl8180_proc_remove_one(dev);
5483 -
5484 +
5485 rtl8180_down(dev);
5486 priv->rf_close(dev);
5487 //rtl8180_rtx_disable(dev);
5488 @@ -2478,12 +2695,12 @@
5489  
5490 }
5491 // pci_disable_device(pdev);
5492 - free_ieee80211(dev);
5493 + free_ieee80211_rtl7(dev);
5494 DMESG("wlan driver removed\n");
5495 }
5496  
5497  
5498 -static int __init rtl8187_usb_module_init(void)
5499 +static int __init rtl8187_usb_module_init_rtl7(void)
5500 {
5501 printk(KERN_INFO "\nLinux kernel driver for RTL8187 \
5502 based WLAN cards\n");
5503 @@ -2495,7 +2712,7 @@
5504 }
5505  
5506  
5507 -static void __exit rtl8187_usb_module_exit(void)
5508 +static void __exit rtl8187_usb_module_exit_rtl7(void)
5509 {
5510 usb_deregister(&rtl8187_usb_driver);
5511  
5512 @@ -2508,14 +2725,14 @@
5513 {
5514 unsigned long flags;
5515 short enough_desc;
5516 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5517 -
5518 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5519 +
5520 spin_lock_irqsave(&priv->tx_lock,flags);
5521 enough_desc = check_nic_enought_desc(dev,pri);
5522 - spin_unlock_irqrestore(&priv->tx_lock,flags);
5523 -
5524 + spin_unlock_irqrestore(&priv->tx_lock,flags);
5525 +
5526 if(enough_desc)
5527 - ieee80211_wake_queue(priv->ieee80211);
5528 + ieee80211_wake_queue_rtl7(priv->ieee80211);
5529 }
5530  
5531  
5532 @@ -2523,5 +2740,5 @@
5533 /***************************************************************************
5534 ------------------- module init / exit stubs ----------------
5535 ****************************************************************************/
5536 -module_init(rtl8187_usb_module_init);
5537 -module_exit(rtl8187_usb_module_exit);
5538 +module_init(rtl8187_usb_module_init_rtl7);
5539 +module_exit(rtl8187_usb_module_exit_rtl7);
5540 diff -Naur rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h
5541 --- rtl8187_linux_26.1010.0622.2006/beta-8187/r8187.h 2006-06-06 08:48:10.000000000 +0200
5542 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h 2008-01-30 17:38:11.000000000 +0100
5543 @@ -1,17 +1,17 @@
5544 -/*
5545 +/*
5546 This is part of rtl8187 OpenSource driver.
5547 - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
5548 + Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
5549 Released under the terms of GPL (General Public Licence)
5550 -
5551 - Parts of this driver are based on the GPL part of the
5552 +
5553 + Parts of this driver are based on the GPL part of the
5554 official realtek driver
5555 -
5556 - Parts of this driver are based on the rtl8180 driver skeleton
5557 +
5558 + Parts of this driver are based on the rtl8180 driver skeleton
5559 from Patric Schenke & Andres Salomon
5560 -
5561 +
5562 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
5563 -
5564 - We want to tanks the Authors of those projects and the Ndiswrapper
5565 +
5566 + We want to tanks the Authors of those projects and the Ndiswrapper
5567 project Authors.
5568 */
5569  
5570 @@ -26,7 +26,6 @@
5571  
5572 #include <linux/module.h>
5573 #include <linux/kernel.h>
5574 -#include <linux/config.h>
5575 #include <linux/init.h>
5576 #include <linux/ioport.h>
5577 #include <linux/sched.h>
5578 @@ -47,6 +46,12 @@
5579 #include <asm/io.h>
5580 #include <asm/semaphore.h>
5581  
5582 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5583 +#include <linux/config.h>
5584 +#else
5585 +#include <linux/autoconf.h>
5586 +#endif
5587 +
5588 #include "ieee80211.h"
5589  
5590 #define EPROM_93c46 0
5591 @@ -68,7 +73,7 @@
5592 {
5593 struct buffer *next;
5594 u32 *buf;
5595 -
5596 +
5597 } buffer;
5598  
5599 #if 0
5600 @@ -123,18 +128,18 @@
5601 short epromtype;
5602 int irq;
5603 struct ieee80211_device *ieee80211;
5604 -
5605 +
5606 short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */
5607 short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */
5608 short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
5609 short enable_gpio0;
5610 enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type;
5611 short hw_plcp_len;
5612 -
5613 +
5614 // spinlock_t irq_lock;
5615 // spinlock_t irq_th_lock;
5616 spinlock_t tx_lock;
5617 -
5618 +
5619 u16 irq_mask;
5620 // short irq_enabled;
5621 struct net_device *dev;
5622 @@ -143,13 +148,17 @@
5623 short max_sens;
5624 u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
5625 u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
5626 + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used
5627 + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used
5628 u8 cck_txpwr_base;
5629 u8 ofdm_txpwr_base;
5630 + u8 txpwr_max;
5631 u8 challow[15]; //channels from 1 to 14, 0 not used
5632 short up;
5633 short crcmon; //if 1 allow bad crc frame reception in monitor mode
5634 -// short prism_hdr;
5635 -
5636 + short prism_hdr;
5637 + short fasttx;
5638 +
5639 // struct timer_list scan_timer;
5640 /*short scanpending;
5641 short stopscan;*/
5642 @@ -158,7 +167,7 @@
5643 //u8 active_scan_num;
5644 struct semaphore wx_sem;
5645 // short hw_wep;
5646 -
5647 +
5648 // short digphy;
5649 // short antb;
5650 // short diversity;
5651 @@ -171,31 +180,31 @@
5652 void (*rf_close)(struct net_device *dev);
5653 void (*rf_init)(struct net_device *dev);
5654 //short rate;
5655 - short promisc;
5656 + short promisc;
5657 /*stats*/
5658 struct Stats stats;
5659 struct iw_statistics wstats;
5660 struct proc_dir_entry *dir_dev;
5661 -
5662 +
5663 /*RX stuff*/
5664 // u32 *rxring;
5665 // u32 *rxringtail;
5666 // dma_addr_t rxringdma;
5667 struct urb **rx_urb;
5668 -
5669 +
5670 //struct buffer *rxbuffer;
5671 //struct buffer *rxbufferhead;
5672 //int rxringcount;
5673 //u16 rxbuffersize;
5674 -
5675 - //struct sk_buff *rx_skb;
5676 +
5677 + //struct sk_buff *rx_skb;
5678  
5679 //short rx_skb_complete;
5680  
5681 //u32 rx_prevlen;
5682 atomic_t tx_lp_pending;
5683 atomic_t tx_np_pending;
5684 -#if 0
5685 +#if 0
5686 /*TX stuff*/
5687 u32 *txlpring;
5688 u32 *txhpring;
5689 @@ -225,7 +234,7 @@
5690 struct urb *rxurb_task;
5691 // u8 dma_poll_mask;
5692 //short tx_suspend;
5693 -
5694 +
5695 /* adhoc/master mode stuff */
5696 #if 0
5697 u32 *txbeacontail;
5698 @@ -239,22 +248,23 @@
5699 //u16 master_beaconinterval;
5700 // u32 master_beaconsize;
5701 //u16 beacon_interval;
5702 -
5703 +
5704 u8 retry_data;
5705 u8 retry_rts;
5706 -
5707 +
5708 struct work_struct reset_wq;
5709 -
5710 +
5711 }r8180_priv;
5712  
5713  
5714 -typedef enum{
5715 +typedef enum{
5716 LOW_PRIORITY ,
5717 - NORM_PRIORITY
5718 + NORM_PRIORITY
5719 } priority_t;
5720  
5721  
5722 short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate);
5723 +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate);
5724  
5725 u8 read_nic_byte(struct net_device *dev, int x);
5726 u8 read_nic_byte_E(struct net_device *dev, int x);
5727 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c
5728 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.c 2006-06-06 04:57:56.000000000 +0200
5729 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c 2008-01-30 17:38:11.000000000 +0100
5730 @@ -11,7 +11,6 @@
5731 *
5732 */
5733  
5734 -#include <linux/config.h>
5735 #include <linux/version.h>
5736 #include <linux/module.h>
5737 #include <linux/init.h>
5738 @@ -19,6 +18,12 @@
5739 #include <asm/string.h>
5740 #include <asm/errno.h>
5741  
5742 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5743 +#include <linux/config.h>
5744 +#else
5745 +#include <linux/autoconf.h>
5746 +#endif
5747 +
5748 #include "ieee80211.h"
5749  
5750 MODULE_AUTHOR("Jouni Malinen");
5751 @@ -38,7 +43,7 @@
5752  
5753 static struct ieee80211_crypto *hcrypt;
5754  
5755 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
5756 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee,
5757 int force)
5758 {
5759 struct list_head *ptr, *n;
5760 @@ -61,13 +66,13 @@
5761 }
5762 }
5763  
5764 -void ieee80211_crypt_deinit_handler(unsigned long data)
5765 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data)
5766 {
5767 struct ieee80211_device *ieee = (struct ieee80211_device *)data;
5768 unsigned long flags;
5769  
5770 spin_lock_irqsave(&ieee->lock, flags);
5771 - ieee80211_crypt_deinit_entries(ieee, 0);
5772 + ieee80211_crypt_deinit_entries_rtl7(ieee, 0);
5773 if (!list_empty(&ieee->crypt_deinit_list)) {
5774 printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
5775 "deletion list\n", ieee->dev->name);
5776 @@ -78,7 +83,7 @@
5777  
5778 }
5779  
5780 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
5781 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
5782 struct ieee80211_crypt_data **crypt)
5783 {
5784 struct ieee80211_crypt_data *tmp;
5785 @@ -103,7 +108,7 @@
5786 spin_unlock_irqrestore(&ieee->lock, flags);
5787 }
5788  
5789 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
5790 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
5791 {
5792 unsigned long flags;
5793 struct ieee80211_crypto_alg *alg;
5794 @@ -128,7 +133,7 @@
5795 return 0;
5796 }
5797  
5798 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
5799 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
5800 {
5801 unsigned long flags;
5802 struct list_head *ptr;
5803 @@ -159,7 +164,7 @@
5804 }
5805  
5806  
5807 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
5808 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name)
5809 {
5810 unsigned long flags;
5811 struct list_head *ptr;
5812 @@ -186,13 +191,13 @@
5813 }
5814  
5815  
5816 -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
5817 -static void ieee80211_crypt_null_deinit(void *priv) {}
5818 +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; }
5819 +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {}
5820  
5821 static struct ieee80211_crypto_ops ieee80211_crypt_null = {
5822 .name = "NULL",
5823 - .init = ieee80211_crypt_null_init,
5824 - .deinit = ieee80211_crypt_null_deinit,
5825 + .init = ieee80211_crypt_null_init_rtl7,
5826 + .deinit = ieee80211_crypt_null_deinit_rtl7,
5827 .encrypt_mpdu = NULL,
5828 .decrypt_mpdu = NULL,
5829 .encrypt_msdu = NULL,
5830 @@ -205,7 +210,7 @@
5831 };
5832  
5833  
5834 -static int __init ieee80211_crypto_init(void)
5835 +static int __init ieee80211_crypto_init_rtl7(void)
5836 {
5837 int ret = -ENOMEM;
5838  
5839 @@ -217,7 +222,7 @@
5840 INIT_LIST_HEAD(&hcrypt->algs);
5841 spin_lock_init(&hcrypt->lock);
5842  
5843 - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
5844 + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null);
5845 if (ret < 0) {
5846 kfree(hcrypt);
5847 hcrypt = NULL;
5848 @@ -227,7 +232,7 @@
5849 }
5850  
5851  
5852 -static void __exit ieee80211_crypto_deinit(void)
5853 +static void __exit ieee80211_crypto_deinit_rtl7(void)
5854 {
5855 struct list_head *ptr, *n;
5856  
5857 @@ -247,13 +252,13 @@
5858 kfree(hcrypt);
5859 }
5860  
5861 -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
5862 -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
5863 -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
5864 -
5865 -EXPORT_SYMBOL(ieee80211_register_crypto_ops);
5866 -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
5867 -EXPORT_SYMBOL(ieee80211_get_crypto_ops);
5868 +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7);
5869 +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7);
5870 +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7);
5871 +
5872 +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7);
5873 +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7);
5874 +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7);
5875  
5876 -module_init(ieee80211_crypto_init);
5877 -module_exit(ieee80211_crypto_deinit);
5878 +module_init(ieee80211_crypto_init_rtl7);
5879 +module_exit(ieee80211_crypto_deinit_rtl7);
5880 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c
5881 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_ccmp.c 2006-06-06 04:58:00.000000000 +0200
5882 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2008-01-30 17:38:11.000000000 +0100
5883 @@ -9,7 +9,6 @@
5884 * more details.
5885 */
5886  
5887 -#include <linux/config.h>
5888 #include <linux/version.h>
5889 #include <linux/module.h>
5890 #include <linux/init.h>
5891 @@ -22,11 +21,22 @@
5892 #include <asm/string.h>
5893 #include <linux/wireless.h>
5894  
5895 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5896 +#include <linux/config.h>
5897 +#else
5898 +#include <linux/autoconf.h>
5899 +#endif
5900 +
5901 #include "ieee80211.h"
5902  
5903  
5904 #include <linux/crypto.h>
5905 -#include <asm/scatterlist.h>
5906 +
5907 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
5908 + #include <asm/scatterlist.h>
5909 +#else
5910 + #include <linux/scatterlist.h>
5911 +#endif
5912  
5913 MODULE_AUTHOR("Jouni Malinen");
5914 MODULE_DESCRIPTION("Host AP crypt: CCMP");
5915 @@ -51,7 +61,11 @@
5916  
5917 int key_idx;
5918  
5919 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5920 struct crypto_tfm *tfm;
5921 +#else
5922 + struct crypto_cipher *tfm;
5923 +#endif
5924  
5925 /* scratch buffers for virt_to_page() (crypto API) */
5926 u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
5927 @@ -59,7 +73,8 @@
5928 u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
5929 };
5930  
5931 -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
5932 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5933 +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm,
5934 const u8 pt[16], u8 ct[16])
5935 {
5936 struct scatterlist src, dst;
5937 @@ -74,8 +89,15 @@
5938  
5939 crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
5940 }
5941 +#else
5942 +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm,
5943 + const u8 pt[16], u8 ct[16])
5944 +{
5945 + crypto_cipher_encrypt_one(tfm, ct, pt);
5946 +}
5947 +#endif
5948  
5949 -static void * ieee80211_ccmp_init(int key_idx)
5950 +static void * ieee80211_ccmp_init_rtl7(int key_idx)
5951 {
5952 struct ieee80211_ccmp_data *priv;
5953  
5954 @@ -85,19 +107,33 @@
5955 memset(priv, 0, sizeof(*priv));
5956 priv->key_idx = key_idx;
5957  
5958 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5959 priv->tfm = crypto_alloc_tfm("aes", 0);
5960 if (priv->tfm == NULL) {
5961 printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
5962 "crypto API aes\n");
5963 goto fail;
5964 }
5965 +#else
5966 + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
5967 + if (IS_ERR(priv->tfm)) {
5968 + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
5969 + "crypto API aes\n");
5970 + priv->tfm = NULL;
5971 + goto fail;
5972 + }
5973 +#endif
5974  
5975 return priv;
5976  
5977 fail:
5978 if (priv) {
5979 if (priv->tfm)
5980 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5981 crypto_free_tfm(priv->tfm);
5982 +#else
5983 + crypto_free_cipher(priv->tfm);
5984 +#endif
5985 kfree(priv);
5986 }
5987  
5988 @@ -105,16 +141,20 @@
5989 }
5990  
5991  
5992 -static void ieee80211_ccmp_deinit(void *priv)
5993 +static void ieee80211_ccmp_deinit_rtl7(void *priv)
5994 {
5995 struct ieee80211_ccmp_data *_priv = priv;
5996 if (_priv && _priv->tfm)
5997 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
5998 crypto_free_tfm(_priv->tfm);
5999 +#else
6000 + crypto_free_cipher(_priv->tfm);
6001 +#endif
6002 kfree(priv);
6003 }
6004  
6005  
6006 -static inline void xor_block(u8 *b, u8 *a, size_t len)
6007 +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len)
6008 {
6009 int i;
6010 for (i = 0; i < len; i++)
6011 @@ -122,7 +162,11 @@
6012 }
6013  
6014  
6015 -static void ccmp_init_blocks(struct crypto_tfm *tfm,
6016 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6017 +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm,
6018 +#else
6019 +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm,
6020 +#endif
6021 struct ieee80211_hdr *hdr,
6022 u8 *pn, size_t dlen, u8 *b0, u8 *auth,
6023 u8 *s0)
6024 @@ -186,18 +230,18 @@
6025 }
6026  
6027 /* Start with the first block and AAD */
6028 - ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
6029 - xor_block(auth, aad, AES_BLOCK_LEN);
6030 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
6031 - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
6032 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
6033 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth);
6034 + xor_block_rtl7(auth, aad, AES_BLOCK_LEN);
6035 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
6036 + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
6037 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
6038 b0[0] &= 0x07;
6039 b0[14] = b0[15] = 0;
6040 - ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
6041 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0);
6042 }
6043  
6044  
6045 -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6046 +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6047 {
6048 struct ieee80211_ccmp_data *key = priv;
6049 int data_len, i, blocks, last, len;
6050 @@ -237,7 +281,7 @@
6051 *pos++ = key->tx_pn[0];
6052  
6053 hdr = (struct ieee80211_hdr *) skb->data;
6054 - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
6055 + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
6056  
6057 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
6058 last = data_len % AES_BLOCK_LEN;
6059 @@ -245,13 +289,13 @@
6060 for (i = 1; i <= blocks; i++) {
6061 len = (i == blocks && last) ? last : AES_BLOCK_LEN;
6062 /* Authentication */
6063 - xor_block(b, pos, len);
6064 - ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
6065 + xor_block_rtl7(b, pos, len);
6066 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b);
6067 /* Encryption, with counter */
6068 b0[14] = (i >> 8) & 0xff;
6069 b0[15] = i & 0xff;
6070 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
6071 - xor_block(pos, e, len);
6072 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e);
6073 + xor_block_rtl7(pos, e, len);
6074 pos += len;
6075 }
6076  
6077 @@ -262,7 +306,7 @@
6078 }
6079  
6080  
6081 -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6082 +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6083 {
6084 struct ieee80211_ccmp_data *key = priv;
6085 u8 keyidx, *pos;
6086 @@ -326,8 +370,8 @@
6087 return -4;
6088 }
6089  
6090 - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
6091 - xor_block(mic, b, CCMP_MIC_LEN);
6092 + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b);
6093 + xor_block_rtl7(mic, b, CCMP_MIC_LEN);
6094  
6095 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
6096 last = data_len % AES_BLOCK_LEN;
6097 @@ -337,11 +381,11 @@
6098 /* Decrypt, with counter */
6099 b0[14] = (i >> 8) & 0xff;
6100 b0[15] = i & 0xff;
6101 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
6102 - xor_block(pos, b, len);
6103 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b);
6104 + xor_block_rtl7(pos, b, len);
6105 /* Authentication */
6106 - xor_block(a, pos, len);
6107 - ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
6108 + xor_block_rtl7(a, pos, len);
6109 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a);
6110 pos += len;
6111 }
6112  
6113 @@ -365,11 +409,15 @@
6114 }
6115  
6116  
6117 -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
6118 +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6119 {
6120 struct ieee80211_ccmp_data *data = priv;
6121 int keyidx;
6122 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6123 struct crypto_tfm *tfm = data->tfm;
6124 +#else
6125 + struct crypto_cipher *tfm = data->tfm;
6126 +#endif
6127  
6128 keyidx = data->key_idx;
6129 memset(data, 0, sizeof(*data));
6130 @@ -396,7 +444,7 @@
6131 }
6132  
6133  
6134 -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
6135 +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6136 {
6137 struct ieee80211_ccmp_data *data = priv;
6138  
6139 @@ -420,7 +468,7 @@
6140 }
6141  
6142  
6143 -static char * ieee80211_ccmp_print_stats(char *p, void *priv)
6144 +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv)
6145 {
6146 struct ieee80211_ccmp_data *ccmp = priv;
6147 p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
6148 @@ -437,34 +485,34 @@
6149 }
6150  
6151  
6152 -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
6153 +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = {
6154 .name = "CCMP",
6155 - .init = ieee80211_ccmp_init,
6156 - .deinit = ieee80211_ccmp_deinit,
6157 - .encrypt_mpdu = ieee80211_ccmp_encrypt,
6158 - .decrypt_mpdu = ieee80211_ccmp_decrypt,
6159 + .init = ieee80211_ccmp_init_rtl7,
6160 + .deinit = ieee80211_ccmp_deinit_rtl7,
6161 + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7,
6162 + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7,
6163 .encrypt_msdu = NULL,
6164 .decrypt_msdu = NULL,
6165 - .set_key = ieee80211_ccmp_set_key,
6166 - .get_key = ieee80211_ccmp_get_key,
6167 - .print_stats = ieee80211_ccmp_print_stats,
6168 + .set_key = ieee80211_ccmp_set_key_rtl7,
6169 + .get_key = ieee80211_ccmp_get_key_rtl7,
6170 + .print_stats = ieee80211_ccmp_print_stats_rtl7,
6171 .extra_prefix_len = CCMP_HDR_LEN,
6172 .extra_postfix_len = CCMP_MIC_LEN,
6173 .owner = THIS_MODULE,
6174 };
6175  
6176  
6177 -static int __init ieee80211_crypto_ccmp_init(void)
6178 +static int __init ieee80211_crypto_ccmp_init_rtl7(void)
6179 {
6180 - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
6181 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
6182 }
6183  
6184  
6185 -static void __exit ieee80211_crypto_ccmp_exit(void)
6186 +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void)
6187 {
6188 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
6189 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
6190 }
6191  
6192  
6193 -module_init(ieee80211_crypto_ccmp_init);
6194 -module_exit(ieee80211_crypto_ccmp_exit);
6195 +module_init(ieee80211_crypto_ccmp_init_rtl7);
6196 +module_exit(ieee80211_crypto_ccmp_exit_rtl7);
6197 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h
6198 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt.h 2006-06-06 04:58:00.000000000 +0200
6199 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h 2008-01-30 17:38:11.000000000 +0100
6200 @@ -75,12 +75,12 @@
6201 atomic_t refcnt;
6202 };
6203  
6204 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
6205 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
6206 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
6207 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
6208 -void ieee80211_crypt_deinit_handler(unsigned long);
6209 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
6210 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
6211 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
6212 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name);
6213 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int);
6214 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long);
6215 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
6216 struct ieee80211_crypt_data **crypt);
6217  
6218 #endif
6219 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c
6220 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_tkip.c 2006-06-06 04:57:54.000000000 +0200
6221 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c 2008-01-30 17:39:05.000000000 +0100
6222 @@ -9,7 +9,6 @@
6223 * more details.
6224 */
6225  
6226 -#include <linux/config.h>
6227 #include <linux/version.h>
6228 #include <linux/module.h>
6229 #include <linux/init.h>
6230 @@ -21,13 +20,24 @@
6231 #include <linux/if_arp.h>
6232 #include <asm/string.h>
6233  
6234 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6235 +#include <linux/config.h>
6236 +#else
6237 +#include <linux/autoconf.h>
6238 +#endif
6239 +
6240 #include "ieee80211.h"
6241  
6242 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
6243 + #include <asm/scatterlist.h>
6244 +#else
6245 + #include <linux/scatterlist.h>
6246 +#endif
6247  
6248 #include <linux/crypto.h>
6249 -#include <asm/scatterlist.h>
6250 #include <linux/crc32.h>
6251  
6252 +
6253 MODULE_AUTHOR("Jouni Malinen");
6254 MODULE_DESCRIPTION("Host AP crypt: TKIP");
6255 MODULE_LICENSE("GPL");
6256 @@ -55,14 +65,21 @@
6257  
6258 int key_idx;
6259  
6260 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6261 struct crypto_tfm *tfm_arc4;
6262 struct crypto_tfm *tfm_michael;
6263 +#else
6264 + struct crypto_blkcipher *rx_tfm_arc4;
6265 + struct crypto_blkcipher *tx_tfm_arc4;
6266 + struct crypto_hash *rx_tfm_michael;
6267 + struct crypto_hash *tx_tfm_michael;
6268 +#endif
6269  
6270 /* scratch buffers for virt_to_page() (crypto API) */
6271 u8 rx_hdr[16], tx_hdr[16];
6272 };
6273  
6274 -static void * ieee80211_tkip_init(int key_idx)
6275 +static void * ieee80211_tkip_init_rtl7(int key_idx)
6276 {
6277 struct ieee80211_tkip_data *priv;
6278  
6279 @@ -72,28 +89,74 @@
6280 memset(priv, 0, sizeof(*priv));
6281 priv->key_idx = key_idx;
6282  
6283 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6284 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
6285 if (priv->tfm_arc4 == NULL) {
6286 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6287 "crypto API arc4\n");
6288 goto fail;
6289 }
6290 -
6291 priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
6292 if (priv->tfm_michael == NULL) {
6293 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6294 "crypto API michael_mic\n");
6295 goto fail;
6296 }
6297 +#else
6298 + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6299 + if (IS_ERR(priv->tx_tfm_arc4)) {
6300 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6301 + "crypto API arc4\n");
6302 + priv->tx_tfm_arc4 = NULL;
6303 + goto fail;
6304 + }
6305 +
6306 + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
6307 + CRYPTO_ALG_ASYNC);
6308 + if (IS_ERR(priv->tx_tfm_michael)) {
6309 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6310 + "crypto API michael_mic\n");
6311 + priv->tx_tfm_michael = NULL;
6312 + goto fail;
6313 + }
6314 +
6315 + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6316 + if (IS_ERR(priv->rx_tfm_arc4)) {
6317 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6318 + "crypto API arc4\n");
6319 + priv->rx_tfm_arc4 = NULL;
6320 + goto fail;
6321 + }
6322 +
6323 + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
6324 + CRYPTO_ALG_ASYNC);
6325 + if (IS_ERR(priv->rx_tfm_michael)) {
6326 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
6327 + "crypto API michael_mic\n");
6328 + priv->rx_tfm_michael = NULL;
6329 + goto fail;
6330 + }
6331 +#endif
6332  
6333 return priv;
6334  
6335 fail:
6336 if (priv) {
6337 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6338 if (priv->tfm_michael)
6339 crypto_free_tfm(priv->tfm_michael);
6340 if (priv->tfm_arc4)
6341 crypto_free_tfm(priv->tfm_arc4);
6342 +#else
6343 + if (priv->tx_tfm_michael)
6344 + crypto_free_hash(priv->tx_tfm_michael);
6345 + if (priv->tx_tfm_arc4)
6346 + crypto_free_blkcipher(priv->tx_tfm_arc4);
6347 + if (priv->rx_tfm_michael)
6348 + crypto_free_hash(priv->rx_tfm_michael);
6349 + if (priv->rx_tfm_arc4)
6350 + crypto_free_blkcipher(priv->rx_tfm_arc4);
6351 +#endif
6352 kfree(priv);
6353 }
6354  
6355 @@ -101,13 +164,26 @@
6356 }
6357  
6358  
6359 -static void ieee80211_tkip_deinit(void *priv)
6360 +static void ieee80211_tkip_deinit_rtl7(void *priv)
6361 {
6362 struct ieee80211_tkip_data *_priv = priv;
6363 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6364 if (_priv && _priv->tfm_michael)
6365 crypto_free_tfm(_priv->tfm_michael);
6366 if (_priv && _priv->tfm_arc4)
6367 crypto_free_tfm(_priv->tfm_arc4);
6368 +#else
6369 + if (_priv) {
6370 + if (_priv->tx_tfm_michael)
6371 + crypto_free_hash(_priv->tx_tfm_michael);
6372 + if (_priv->tx_tfm_arc4)
6373 + crypto_free_blkcipher(_priv->tx_tfm_arc4);
6374 + if (_priv->rx_tfm_michael)
6375 + crypto_free_hash(_priv->rx_tfm_michael);
6376 + if (_priv->rx_tfm_arc4)
6377 + crypto_free_blkcipher(_priv->rx_tfm_arc4);
6378 + }
6379 +#endif
6380 kfree(priv);
6381 }
6382  
6383 @@ -200,7 +276,7 @@
6384  
6385 #define PHASE1_LOOP_COUNT 8
6386  
6387 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
6388 +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
6389 {
6390 int i, j;
6391  
6392 @@ -222,7 +298,7 @@
6393 }
6394  
6395  
6396 -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
6397 +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
6398 u16 IV16)
6399 {
6400 /* Make temporary area overlap WEP seed so that the final copy can be
6401 @@ -268,7 +344,7 @@
6402 #endif
6403 }
6404  
6405 -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6406 +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6407 {
6408 struct ieee80211_tkip_data *tkey = priv;
6409 int len;
6410 @@ -276,6 +352,9 @@
6411 struct ieee80211_hdr *hdr;
6412 u32 crc;
6413 struct scatterlist sg;
6414 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6415 + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
6416 +#endif
6417  
6418 if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
6419 skb->len < hdr_len)
6420 @@ -283,11 +362,11 @@
6421  
6422 hdr = (struct ieee80211_hdr *) skb->data;
6423 if (!tkey->tx_phase1_done) {
6424 - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
6425 + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2,
6426 tkey->tx_iv32);
6427 tkey->tx_phase1_done = 1;
6428 }
6429 - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
6430 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
6431  
6432 len = skb->len - hdr_len;
6433 pos = skb_push(skb, 8);
6434 @@ -310,11 +389,23 @@
6435 icv[2] = crc >> 16;
6436 icv[3] = crc >> 24;
6437  
6438 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6439 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
6440 +#else
6441 + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
6442 +#endif
6443 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
6444 sg.page = virt_to_page(pos);
6445 sg.offset = offset_in_page(pos);
6446 sg.length = len + 4;
6447 +#else
6448 + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos));
6449 +#endif
6450 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6451 crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4);
6452 +#else
6453 + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
6454 +#endif
6455  
6456 tkey->tx_iv16++;
6457 if (tkey->tx_iv16 == 0) {
6458 @@ -325,7 +416,7 @@
6459 return 0;
6460 }
6461  
6462 -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6463 +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6464 {
6465 struct ieee80211_tkip_data *tkey = priv;
6466 u8 rc4key[16];
6467 @@ -337,6 +428,9 @@
6468 u32 crc;
6469 struct scatterlist sg;
6470 int plen;
6471 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6472 + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
6473 +#endif
6474  
6475 if (skb->len < hdr_len + 8 + 4)
6476 return -1;
6477 @@ -382,18 +476,30 @@
6478 }
6479  
6480 if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
6481 - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
6482 + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
6483 tkey->rx_phase1_done = 1;
6484 }
6485 - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
6486 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16);
6487  
6488 plen = skb->len - hdr_len - 12;
6489  
6490 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6491 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
6492 +#else
6493 + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
6494 +#endif
6495 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
6496 sg.page = virt_to_page(pos);
6497 sg.offset = offset_in_page(pos);
6498 sg.length = plen + 4;
6499 +#else
6500 + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos));
6501 +#endif
6502 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6503 crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);
6504 +#else
6505 + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4);
6506 +#endif
6507  
6508 crc = ~crc32_le(~0, pos, plen);
6509 icv[0] = crc;
6510 @@ -427,33 +533,59 @@
6511 return keyidx;
6512 }
6513  
6514 -
6515 -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
6516 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6517 +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
6518 u8 *data, size_t data_len, u8 *mic)
6519 {
6520 struct scatterlist sg[2];
6521  
6522 if (tkey->tfm_michael == NULL) {
6523 +#else
6524 +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr,
6525 + u8 *data, size_t data_len, u8 *mic)
6526 +{
6527 + struct hash_desc desc;
6528 + struct scatterlist sg[2];
6529 +
6530 + if (tfm_michael == NULL) {
6531 +#endif
6532 printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
6533 return -1;
6534 }
6535 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
6536 sg[0].page = virt_to_page(hdr);
6537 sg[0].offset = offset_in_page(hdr);
6538 sg[0].length = 16;
6539 +#else
6540 + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr));
6541 +#endif
6542  
6543 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
6544 sg[1].page = virt_to_page(data);
6545 sg[1].offset = offset_in_page(data);
6546 sg[1].length = data_len;
6547 +#else
6548 + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data));
6549 +#endif
6550  
6551 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6552 crypto_digest_init(tkey->tfm_michael);
6553 crypto_digest_setkey(tkey->tfm_michael, key, 8);
6554 crypto_digest_update(tkey->tfm_michael, sg, 2);
6555 crypto_digest_final(tkey->tfm_michael, mic);
6556  
6557 return 0;
6558 +#else
6559 + if (crypto_hash_setkey(tfm_michael, key, 8))
6560 + return -1;
6561 +
6562 + desc.tfm = tfm_michael;
6563 + desc.flags = 0;
6564 + return crypto_hash_digest(&desc, sg, data_len + 16, mic);
6565 +#endif
6566 }
6567  
6568 -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
6569 +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr)
6570 {
6571 struct ieee80211_hdr *hdr11;
6572  
6573 @@ -483,7 +615,7 @@
6574 }
6575  
6576  
6577 -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
6578 +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6579 {
6580 struct ieee80211_tkip_data *tkey = priv;
6581 u8 *pos;
6582 @@ -495,18 +627,24 @@
6583 return -1;
6584 }
6585  
6586 - michael_mic_hdr(skb, tkey->tx_hdr);
6587 + michael_mic_hdr_rtl7(skb, tkey->tx_hdr);
6588 pos = skb_put(skb, 8);
6589 - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
6590 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6591 + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr,
6592 + skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
6593 + return -1;
6594 +#else
6595 + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
6596 skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
6597 return -1;
6598 +#endif
6599  
6600 return 0;
6601 }
6602  
6603  
6604 #if WIRELESS_EXT >= 18
6605 -static void ieee80211_michael_mic_failure(struct net_device *dev,
6606 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6607 struct ieee80211_hdr *hdr,
6608 int keyidx)
6609 {
6610 @@ -527,7 +665,7 @@
6611 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
6612 }
6613 #elif WIRELESS_EXT >= 15
6614 -static void ieee80211_michael_mic_failure(struct net_device *dev,
6615 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6616 struct ieee80211_hdr *hdr,
6617 int keyidx)
6618 {
6619 @@ -543,7 +681,7 @@
6620 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
6621 }
6622 #else /* WIRELESS_EXT >= 15 */
6623 -static inline void ieee80211_michael_mic_failure(struct net_device *dev,
6624 +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
6625 struct ieee80211_hdr *hdr,
6626 int keyidx)
6627 {
6628 @@ -551,7 +689,7 @@
6629 #endif /* WIRELESS_EXT >= 15 */
6630  
6631  
6632 -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
6633 +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx,
6634 int hdr_len, void *priv)
6635 {
6636 struct ieee80211_tkip_data *tkey = priv;
6637 @@ -560,10 +698,16 @@
6638 if (!tkey->key_set)
6639 return -1;
6640  
6641 - michael_mic_hdr(skb, tkey->rx_hdr);
6642 - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
6643 + michael_mic_hdr_rtl7(skb, tkey->rx_hdr);
6644 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6645 + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr,
6646 + skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
6647 + return -1;
6648 +#else
6649 + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
6650 skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
6651 return -1;
6652 +#endif
6653 if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
6654 struct ieee80211_hdr *hdr;
6655 hdr = (struct ieee80211_hdr *) skb->data;
6656 @@ -572,7 +716,7 @@
6657 skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
6658 keyidx);
6659 if (skb->dev)
6660 - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
6661 + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx);
6662 tkey->dot11RSNAStatsTKIPLocalMICFailures++;
6663 return -1;
6664 }
6665 @@ -588,18 +732,33 @@
6666 }
6667  
6668  
6669 -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
6670 +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6671 {
6672 struct ieee80211_tkip_data *tkey = priv;
6673 int keyidx;
6674 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6675 struct crypto_tfm *tfm = tkey->tfm_michael;
6676 struct crypto_tfm *tfm2 = tkey->tfm_arc4;
6677 +#else
6678 + struct crypto_hash *tfm = tkey->tx_tfm_michael;
6679 + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
6680 + struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
6681 + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
6682 +#endif
6683  
6684 keyidx = tkey->key_idx;
6685 memset(tkey, 0, sizeof(*tkey));
6686 tkey->key_idx = keyidx;
6687 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6688 tkey->tfm_michael = tfm;
6689 tkey->tfm_arc4 = tfm2;
6690 +#else
6691 + tkey->tx_tfm_michael = tfm;
6692 + tkey->tx_tfm_arc4 = tfm2;
6693 + tkey->rx_tfm_michael = tfm3;
6694 + tkey->rx_tfm_arc4 = tfm4;
6695 +#endif
6696 +
6697 if (len == TKIP_KEY_LEN) {
6698 memcpy(tkey->key, key, TKIP_KEY_LEN);
6699 tkey->key_set = 1;
6700 @@ -618,7 +777,7 @@
6701 }
6702  
6703  
6704 -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
6705 +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6706 {
6707 struct ieee80211_tkip_data *tkey = priv;
6708  
6709 @@ -648,7 +807,7 @@
6710 }
6711  
6712  
6713 -static char * ieee80211_tkip_print_stats(char *p, void *priv)
6714 +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv)
6715 {
6716 struct ieee80211_tkip_data *tkip = priv;
6717 p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
6718 @@ -675,34 +834,34 @@
6719 }
6720  
6721  
6722 -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
6723 +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = {
6724 .name = "TKIP",
6725 - .init = ieee80211_tkip_init,
6726 - .deinit = ieee80211_tkip_deinit,
6727 - .encrypt_mpdu = ieee80211_tkip_encrypt,
6728 - .decrypt_mpdu = ieee80211_tkip_decrypt,
6729 - .encrypt_msdu = ieee80211_michael_mic_add,
6730 - .decrypt_msdu = ieee80211_michael_mic_verify,
6731 - .set_key = ieee80211_tkip_set_key,
6732 - .get_key = ieee80211_tkip_get_key,
6733 - .print_stats = ieee80211_tkip_print_stats,
6734 + .init = ieee80211_tkip_init_rtl7,
6735 + .deinit = ieee80211_tkip_deinit_rtl7,
6736 + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7,
6737 + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7,
6738 + .encrypt_msdu = ieee80211_michael_mic_add_rtl7,
6739 + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7,
6740 + .set_key = ieee80211_tkip_set_key_rtl7,
6741 + .get_key = ieee80211_tkip_get_key_rtl7,
6742 + .print_stats = ieee80211_tkip_print_stats_rtl7,
6743 .extra_prefix_len = 4 + 4, /* IV + ExtIV */
6744 .extra_postfix_len = 8 + 4, /* MIC + ICV */
6745 .owner = THIS_MODULE,
6746 };
6747  
6748  
6749 -static int __init ieee80211_crypto_tkip_init(void)
6750 +static int __init ieee80211_crypto_tkip_init_rtl7(void)
6751 {
6752 - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
6753 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
6754 }
6755  
6756  
6757 -static void __exit ieee80211_crypto_tkip_exit(void)
6758 +static void __exit ieee80211_crypto_tkip_exit_rtl7(void)
6759 {
6760 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
6761 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
6762 }
6763  
6764  
6765 -module_init(ieee80211_crypto_tkip_init);
6766 -module_exit(ieee80211_crypto_tkip_exit);
6767 +module_init(ieee80211_crypto_tkip_init_rtl7);
6768 +module_exit(ieee80211_crypto_tkip_exit_rtl7);
6769 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c
6770 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_crypt_wep.c 2006-06-06 04:57:54.000000000 +0200
6771 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c 2008-01-30 17:39:05.000000000 +0100
6772 @@ -9,7 +9,6 @@
6773 * more details.
6774 */
6775  
6776 -#include <linux/config.h>
6777 #include <linux/version.h>
6778 #include <linux/module.h>
6779 #include <linux/init.h>
6780 @@ -18,13 +17,24 @@
6781 #include <linux/skbuff.h>
6782 #include <asm/string.h>
6783  
6784 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6785 +#include <linux/config.h>
6786 +#else
6787 +#include <linux/autoconf.h>
6788 +#endif
6789 +
6790 #include "ieee80211.h"
6791  
6792  
6793 #include <linux/crypto.h>
6794 -#include <asm/scatterlist.h>
6795 #include <linux/crc32.h>
6796  
6797 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
6798 + #include <asm/scatterlist.h>
6799 +#else
6800 + #include <linux/scatterlist.h>
6801 +#endif
6802 +
6803 MODULE_AUTHOR("Jouni Malinen");
6804 MODULE_DESCRIPTION("Host AP crypt: WEP");
6805 MODULE_LICENSE("GPL");
6806 @@ -36,11 +46,16 @@
6807 u8 key[WEP_KEY_LEN + 1];
6808 u8 key_len;
6809 u8 key_idx;
6810 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6811 struct crypto_tfm *tfm;
6812 +#else
6813 + struct crypto_blkcipher *rx_tfm;
6814 + struct crypto_blkcipher *tx_tfm;
6815 +#endif
6816 };
6817  
6818  
6819 -static void * prism2_wep_init(int keyidx)
6820 +static void * prism2_wep_init_rtl7(int keyidx)
6821 {
6822 struct prism2_wep_data *priv;
6823  
6824 @@ -50,13 +65,30 @@
6825 memset(priv, 0, sizeof(*priv));
6826 priv->key_idx = keyidx;
6827  
6828 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6829 priv->tfm = crypto_alloc_tfm("arc4", 0);
6830 if (priv->tfm == NULL) {
6831 printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6832 "crypto API arc4\n");
6833 goto fail;
6834 }
6835 +#else
6836 + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6837 + if (IS_ERR(priv->tx_tfm)) {
6838 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6839 + "crypto API arc4\n");
6840 + priv->tx_tfm = NULL;
6841 + goto fail;
6842 + }
6843  
6844 + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
6845 + if (IS_ERR(priv->rx_tfm)) {
6846 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
6847 + "crypto API arc4\n");
6848 + priv->rx_tfm = NULL;
6849 + goto fail;
6850 + }
6851 +#endif
6852 /* start WEP IV from a random value */
6853 get_random_bytes(&priv->iv, 4);
6854  
6855 @@ -64,19 +96,35 @@
6856  
6857 fail:
6858 if (priv) {
6859 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6860 if (priv->tfm)
6861 crypto_free_tfm(priv->tfm);
6862 +#else
6863 + if (priv->tx_tfm)
6864 + crypto_free_blkcipher(priv->tx_tfm);
6865 + if (priv->rx_tfm)
6866 + crypto_free_blkcipher(priv->rx_tfm);
6867 +#endif
6868 kfree(priv);
6869 }
6870 return NULL;
6871 }
6872  
6873  
6874 -static void prism2_wep_deinit(void *priv)
6875 +static void prism2_wep_deinit_rtl7(void *priv)
6876 {
6877 struct prism2_wep_data *_priv = priv;
6878 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
6879 if (_priv && _priv->tfm)
6880 crypto_free_tfm(_priv->tfm);
6881 +#else
6882 + if (_priv) {
6883 + if (_priv->tx_tfm)
6884 + crypto_free_blkcipher(_priv->tx_tfm);
6885 + if (_priv->rx_tfm)
6886 + crypto_free_blkcipher(_priv->rx_tfm);
6887 + }
6888 +#endif
6889 kfree(priv);
6890 }
6891  
6892 @@ -87,13 +135,16 @@
6893 *
6894 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
6895 */
6896 -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
6897 +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6898 {
6899 struct prism2_wep_data *wep = priv;
6900 u32 crc, klen, len;
6901 u8 key[WEP_KEY_LEN + 3];
6902 u8 *pos, *icv;
6903 struct scatterlist sg;
6904 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6905 + struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
6906 +#endif
6907  
6908 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
6909 skb->len < hdr_len)
6910 @@ -134,13 +185,25 @@
6911 icv[2] = crc >> 16;
6912 icv[3] = crc >> 24;
6913  
6914 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6915 crypto_cipher_setkey(wep->tfm, key, klen);
6916 +#else
6917 + crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
6918 +#endif
6919 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
6920 sg.page = virt_to_page(pos);
6921 sg.offset = offset_in_page(pos);
6922 sg.length = len + 4;
6923 - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
6924 +#else
6925 + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos));
6926 +#endif
6927  
6928 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6929 + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
6930 return 0;
6931 +#else
6932 + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
6933 +#endif
6934 }
6935  
6936  
6937 @@ -151,13 +214,16 @@
6938 * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
6939 * failure. If frame is OK, IV and ICV will be removed.
6940 */
6941 -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
6942 +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
6943 {
6944 struct prism2_wep_data *wep = priv;
6945 u32 crc, klen, plen;
6946 u8 key[WEP_KEY_LEN + 3];
6947 u8 keyidx, *pos, icv[4];
6948 struct scatterlist sg;
6949 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
6950 + struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
6951 +#endif
6952  
6953 if (skb->len < hdr_len + 8)
6954 return -1;
6955 @@ -178,11 +244,26 @@
6956 /* Apply RC4 to data and compute CRC32 over decrypted data */
6957 plen = skb->len - hdr_len - 8;
6958  
6959 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6960 crypto_cipher_setkey(wep->tfm, key, klen);
6961 +#else
6962 + crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
6963 +#endif
6964 +
6965 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
6966 sg.page = virt_to_page(pos);
6967 sg.offset = offset_in_page(pos);
6968 sg.length = plen + 4;
6969 +#else
6970 + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos));
6971 +#endif
6972 +
6973 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
6974 crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
6975 +#else
6976 + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
6977 + return -7;
6978 +#endif
6979  
6980 crc = ~crc32_le(~0, pos, plen);
6981 icv[0] = crc;
6982 @@ -203,7 +284,7 @@
6983 }
6984  
6985  
6986 -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
6987 +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
6988 {
6989 struct prism2_wep_data *wep = priv;
6990  
6991 @@ -217,7 +298,7 @@
6992 }
6993  
6994  
6995 -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
6996 +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
6997 {
6998 struct prism2_wep_data *wep = priv;
6999  
7000 @@ -230,7 +311,7 @@
7001 }
7002  
7003  
7004 -static char * prism2_wep_print_stats(char *p, void *priv)
7005 +static char * prism2_wep_print_stats_rtl7(char *p, void *priv)
7006 {
7007 struct prism2_wep_data *wep = priv;
7008 p += sprintf(p, "key[%d] alg=WEP len=%d\n",
7009 @@ -239,34 +320,34 @@
7010 }
7011  
7012  
7013 -static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
7014 +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = {
7015 .name = "WEP",
7016 - .init = prism2_wep_init,
7017 - .deinit = prism2_wep_deinit,
7018 - .encrypt_mpdu = prism2_wep_encrypt,
7019 - .decrypt_mpdu = prism2_wep_decrypt,
7020 + .init = prism2_wep_init_rtl7,
7021 + .deinit = prism2_wep_deinit_rtl7,
7022 + .encrypt_mpdu = prism2_wep_encrypt_rtl7,
7023 + .decrypt_mpdu = prism2_wep_decrypt_rtl7,
7024 .encrypt_msdu = NULL,
7025 .decrypt_msdu = NULL,
7026 - .set_key = prism2_wep_set_key,
7027 - .get_key = prism2_wep_get_key,
7028 - .print_stats = prism2_wep_print_stats,
7029 + .set_key = prism2_wep_set_key_rtl7,
7030 + .get_key = prism2_wep_get_key_rtl7,
7031 + .print_stats = prism2_wep_print_stats_rtl7,
7032 .extra_prefix_len = 4, /* IV */
7033 .extra_postfix_len = 4, /* ICV */
7034 .owner = THIS_MODULE,
7035 };
7036  
7037  
7038 -static int __init ieee80211_crypto_wep_init(void)
7039 +static int __init ieee80211_crypto_wep_init_rtl7(void)
7040 {
7041 - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
7042 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
7043 }
7044  
7045  
7046 -static void __exit ieee80211_crypto_wep_exit(void)
7047 +static void __exit ieee80211_crypto_wep_exit_rtl7(void)
7048 {
7049 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
7050 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
7051 }
7052  
7053  
7054 -module_init(ieee80211_crypto_wep_init);
7055 -module_exit(ieee80211_crypto_wep_exit);
7056 +module_init(ieee80211_crypto_wep_init_rtl7);
7057 +module_exit(ieee80211_crypto_wep_exit_rtl7);
7058 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h
7059 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211.h 2006-06-06 04:57:56.000000000 +0200
7060 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h 2008-01-30 17:38:11.000000000 +0100
7061 @@ -120,7 +120,7 @@
7062 static inline unsigned long msleep_interruptible_rtl(unsigned int msecs)
7063 {
7064 unsigned long timeout = MSECS(msecs) + 1;
7065 -
7066 +
7067 while (timeout) {
7068 set_current_state(TASK_UNINTERRUPTIBLE);
7069 timeout = schedule_timeout(timeout);
7070 @@ -156,6 +156,22 @@
7071 struct list_head list;
7072 };
7073  
7074 +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
7075 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
7076 + * (from linux-wlan-ng) */
7077 +struct linux_wlan_ng_val {
7078 + u32 did;
7079 + u16 status, len;
7080 + u32 data;
7081 +} __attribute__ ((packed));
7082 +
7083 +struct linux_wlan_ng_prism_hdr {
7084 + u32 msgcode, msglen;
7085 + char devname[16];
7086 + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
7087 + noise, rate, istx, frmlen;
7088 +} __attribute__ ((packed));
7089 +
7090 struct ieee80211_hdr {
7091 u16 frame_ctl;
7092 u16 duration_id;
7093 @@ -798,7 +814,7 @@
7094  
7095 /* the card is not linked at all */
7096 IEEE80211_NOLINK = 0,
7097 -
7098 +
7099 /* IEEE80211_ASSOCIATING* are for BSS client mode
7100 * the driver shall not perform RX filtering unless
7101 * the state is LINKED.
7102 @@ -806,31 +822,31 @@
7103 * defaults to NOLINK for ALL the other states (including
7104 * LINKED_SCANNING)
7105 */
7106 -
7107 +
7108 /* the association procedure will start (wq scheduling)*/
7109 IEEE80211_ASSOCIATING,
7110 IEEE80211_ASSOCIATING_RETRY,
7111 -
7112 +
7113 /* the association procedure is sending AUTH request*/
7114 IEEE80211_ASSOCIATING_AUTHENTICATING,
7115 -
7116 +
7117 /* the association procedure has successfully authentcated
7118 * and is sending association request
7119 */
7120 IEEE80211_ASSOCIATING_AUTHENTICATED,
7121 -
7122 +
7123 /* the link is ok. the card associated to a BSS or linked
7124 * to a ibss cell or acting as an AP and creating the bss
7125 */
7126 IEEE80211_LINKED,
7127 -
7128 +
7129 /* same as LINKED, but the driver shall apply RX filter
7130 * rules as we are in NO_LINK mode. As the card is still
7131 * logically linked, but it is doing a syncro site survey
7132 * then it will be back to LINKED state.
7133 */
7134 IEEE80211_LINKED_SCANNING,
7135 -
7136 +
7137 };
7138  
7139 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
7140 @@ -840,14 +856,14 @@
7141  
7142  
7143 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
7144 -extern inline int is_multicast_ether_addr(const u8 *addr)
7145 +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
7146 {
7147 return ((addr[0] != 0xff) && (0x01 & addr[0]));
7148 }
7149 #endif
7150  
7151 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
7152 -extern inline int is_broadcast_ether_addr(const u8 *addr)
7153 +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
7154 {
7155 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
7156 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
7157 @@ -870,7 +886,7 @@
7158 struct net_device_stats stats;
7159 struct ieee80211_stats ieee_stats;
7160 struct ieee80211_softmac_stats softmac_stats;
7161 -
7162 +
7163 /* Probe / Beacon management */
7164 struct list_head network_free_list;
7165 struct list_head network_list;
7166 @@ -881,7 +897,7 @@
7167 int iw_mode; /* operating mode (IW_MODE_*) */
7168  
7169 spinlock_t lock;
7170 -
7171 +
7172 int tx_headroom; /* Set to size of any additional room needed at front
7173 * of allocated Tx SKBs */
7174 u32 config;
7175 @@ -924,11 +940,11 @@
7176 * ad-hoc is a mixture ;-).
7177 * Note that in infrastructure mode, even when not associated,
7178 * fields bssid and essid may be valid (if wpa_set and essid_set
7179 - * are true) as thy carry the value set by the user via iwconfig
7180 + * are true) as thy carry the value set by the user via iwconfig
7181 */
7182 struct ieee80211_network current_network;
7183  
7184 -
7185 +
7186 enum ieee80211_state state;
7187  
7188 int short_slot;
7189 @@ -936,33 +952,33 @@
7190 int modulation; /* CCK, OFDM */
7191 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
7192 int abg_true; /* ABG flag */
7193 -
7194 - /* used for forcing the ibss workqueue to terminate
7195 +
7196 + /* used for forcing the ibss workqueue to terminate
7197 * without wait for the syncro scan to terminate
7198 */
7199 - short sync_scan_hurryup;
7200 -
7201 + short sync_scan_hurryup;
7202 +
7203 /* map of allowed channels. 0 is dummy */
7204 // FIXME: remeber to default to a basic channel plan depending of the PHY type
7205 int channel_map[MAX_CHANNEL_NUMBER+1];
7206 -
7207 +
7208 int rate; /* current rate */
7209 int basic_rate;
7210 //FIXME: pleace callback, see if redundant with softmac_features
7211 short active_scan;
7212 -
7213 +
7214 /* this contains flags for selectively enable softmac support */
7215 u16 softmac_features;
7216 -
7217 +
7218 /* if the sequence control field is not filled by HW */
7219 u16 seq_ctrl;
7220 -
7221 +
7222 /* association procedure transaction sequence number */
7223 u16 associate_seq;
7224 -
7225 +
7226 /* AID for RTXed association responses */
7227 u16 assoc_id;
7228 -
7229 +
7230 /* power save mode related*/
7231 short ps;
7232 short sta_sleep;
7233 @@ -970,147 +986,153 @@
7234 struct tasklet_struct ps_task;
7235 u32 ps_th;
7236 u32 ps_tl;
7237 -
7238 +
7239 short raw_tx;
7240 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
7241 short queue_stop;
7242 short scanning;
7243 short proto_started;
7244 -
7245 +
7246 struct semaphore wx_sem;
7247 struct semaphore scan_sem;
7248 -
7249 - spinlock_t mgmt_tx_lock;
7250 +
7251 + spinlock_t mgmt_tx_lock;
7252 spinlock_t beacon_lock;
7253  
7254 short beacon_txing;
7255  
7256 short wap_set;
7257 short ssid_set;
7258 -
7259 +
7260 /* for discarding duplicated packets in IBSS */
7261 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
7262 -
7263 +
7264 /* for discarding duplicated packets in BSS */
7265 u16 last_seq_num;
7266 u16 last_frag_num;
7267 unsigned long last_packet_time;
7268 -
7269 +
7270 /* for PS mode */
7271 unsigned long last_rx_ps_time;
7272 -
7273 +
7274 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
7275 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
7276 int mgmt_queue_head;
7277 int mgmt_queue_tail;
7278 -
7279 -
7280 +
7281 +
7282 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
7283 struct tx_pending_t tx_pending;
7284 -
7285 +
7286 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
7287 struct timer_list associate_timer;
7288  
7289 /* used if IEEE_SOFTMAC_BEACONS is set */
7290 struct timer_list beacon_timer;
7291 -
7292 +
7293 struct work_struct associate_complete_wq;
7294 +
7295 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
7296 + struct delayed_work associate_retry_wq;
7297 + struct delayed_work softmac_scan_wq;
7298 +#else
7299 struct work_struct associate_retry_wq;
7300 + struct work_struct softmac_scan_wq;
7301 +#endif
7302 struct work_struct start_ibss_wq;
7303 struct work_struct associate_procedure_wq;
7304 - struct work_struct softmac_scan_wq;
7305 struct work_struct wx_sync_scan_wq;
7306 -
7307 +
7308 struct workqueue_struct *wq;
7309 /* Callback functions */
7310 void (*set_security)(struct net_device *dev,
7311 struct ieee80211_security *sec);
7312 -
7313 +
7314 /* Used to TX data frame by using txb structs.
7315 * this is not used if in the softmac_features
7316 * is set the flag IEEE_SOFTMAC_TX_QUEUE
7317 */
7318 int (*hard_start_xmit)(struct ieee80211_txb *txb,
7319 struct net_device *dev);
7320 -
7321 +
7322 int (*reset_port)(struct net_device *dev);
7323  
7324 - /* Softmac-generated frames (mamagement) are TXed via this
7325 - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
7326 - * not set. As some cards may have different HW queues that
7327 + /* Softmac-generated frames (mamagement) are TXed via this
7328 + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
7329 + * not set. As some cards may have different HW queues that
7330 * one might want to use for data and management frames
7331 * the option to have two callbacks might be useful.
7332 * This fucntion can't sleep.
7333 */
7334 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
7335 struct net_device *dev);
7336 -
7337 +
7338 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
7339 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
7340 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
7341 * then also management frames are sent via this callback.
7342 * This function can't sleep.
7343 - */
7344 + */
7345 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
7346 struct net_device *dev,int rate);
7347  
7348 /* stops the HW queue for DATA frames. Useful to avoid
7349 * waste time to TX data frame when we are reassociating
7350 * This function can sleep.
7351 - */
7352 + */
7353 void (*data_hard_stop)(struct net_device *dev);
7354 -
7355 +
7356 /* OK this is complementar to data_poll_hard_stop */
7357 void (*data_hard_resume)(struct net_device *dev);
7358 -
7359 +
7360 /* ask to the driver to retune the radio .
7361 * This function can sleep. the driver should ensure
7362 * the radio has been swithced before return.
7363 */
7364 void (*set_chan)(struct net_device *dev,short ch);
7365 -
7366 +
7367 /* These are not used if the ieee stack takes care of
7368 - * scanning (IEEE_SOFTMAC_SCAN feature set).
7369 + * scanning (IEEE_SOFTMAC_SCAN feature set).
7370 * In this case only the set_chan is used.
7371 *
7372 * The syncro version is similar to the start_scan but
7373 * does not return until all channels has been scanned.
7374 - * this is called in user context and should sleep,
7375 + * this is called in user context and should sleep,
7376 * it is called in a work_queue when swithcing to ad-hoc mode
7377 - * or in behalf of iwlist scan when the card is associated
7378 - * and root user ask for a scan.
7379 + * or in behalf of iwlist scan when the card is associated
7380 + * and root user ask for a scan.
7381 * the fucntion stop_scan should stop both the syncro and
7382 * background scanning and can sleep.
7383 - * The fucntion start_scan should initiate the background
7384 + * The fucntion start_scan should initiate the background
7385 * scanning and can't sleep.
7386 - */
7387 + */
7388 void (*scan_syncro)(struct net_device *dev);
7389 void (*start_scan)(struct net_device *dev);
7390 void (*stop_scan)(struct net_device *dev);
7391 -
7392 +
7393 /* indicate the driver that the link state is changed
7394 * for example it may indicate the card is associated now.
7395 - * Driver might be interested in this to apply RX filter
7396 - * rules or simply light the LINK led
7397 + * Driver might be interested in this to apply RX filter
7398 + * rules or simply light the LINK led
7399 */
7400 void (*link_change)(struct net_device *dev);
7401 -
7402 +
7403 /* these two function indicates to the HW when to start
7404 - * and stop to send beacons. This is used when the
7405 + * and stop to send beacons. This is used when the
7406 * IEEE_SOFTMAC_BEACONS is not set. For now the
7407 * stop_send_bacons is NOT guaranteed to be called only
7408 * after start_send_beacons.
7409 */
7410 void (*start_send_beacons) (struct net_device *dev);
7411 void (*stop_send_beacons) (struct net_device *dev);
7412 -
7413 +
7414 /* power save mode related */
7415 void (*sta_wake_up) (struct net_device *dev);
7416 void (*ps_request_tx_ack) (struct net_device *dev);
7417 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
7418 short (*ps_is_queue_empty) (struct net_device *dev);
7419 -
7420 -
7421 +
7422 +
7423 /* This must be the last item so that it points to the data
7424 * allocated beyond this structure by alloc_ieee80211 */
7425 u8 priv[0];
7426 @@ -1148,18 +1170,18 @@
7427 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
7428  
7429 /* Generate beacons. The stack will enqueue beacons
7430 - * to the card
7431 - */
7432 + * to the card
7433 + */
7434 #define IEEE_SOFTMAC_BEACONS (1<<6)
7435  
7436  
7437  
7438 -extern inline void *ieee80211_priv(struct net_device *dev)
7439 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
7440 {
7441 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
7442 }
7443  
7444 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
7445 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
7446 {
7447 /* Single white space is for Linksys APs */
7448 if (essid_len == 1 && essid[0] == ' ')
7449 @@ -1175,7 +1197,7 @@
7450 return 1;
7451 }
7452  
7453 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
7454 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
7455 {
7456 /*
7457 * It is possible for both access points and our device to support
7458 @@ -1201,7 +1223,7 @@
7459 return 0;
7460 }
7461  
7462 -extern inline int ieee80211_get_hdrlen(u16 fc)
7463 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
7464 {
7465 int hdrlen = 24;
7466  
7467 @@ -1229,140 +1251,144 @@
7468  
7469  
7470 /* ieee80211.c */
7471 -extern void free_ieee80211(struct net_device *dev);
7472 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
7473 +extern void free_ieee80211_rtl7(struct net_device *dev);
7474 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
7475  
7476 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
7477 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
7478  
7479 /* ieee80211_tx.c */
7480  
7481 -extern int ieee80211_encrypt_fragment(
7482 +extern int ieee80211_encrypt_fragment_rtl7(
7483 struct ieee80211_device *ieee,
7484 struct sk_buff *frag,
7485 int hdr_len);
7486 -
7487 -extern int ieee80211_xmit(struct sk_buff *skb,
7488 +
7489 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
7490 struct net_device *dev);
7491 -extern void ieee80211_txb_free(struct ieee80211_txb *);
7492 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
7493  
7494  
7495 /* ieee80211_rx.c */
7496 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
7497 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7498 struct ieee80211_rx_stats *rx_stats);
7499 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
7500 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
7501 struct ieee80211_hdr *header,
7502 struct ieee80211_rx_stats *stats);
7503  
7504 /* ieee80211_wx.c */
7505 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
7506 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
7507 struct iw_request_info *info,
7508 union iwreq_data *wrqu, char *key);
7509 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
7510 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
7511 struct iw_request_info *info,
7512 union iwreq_data *wrqu, char *key);
7513 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
7514 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
7515 struct iw_request_info *info,
7516 union iwreq_data *wrqu, char *key);
7517 /* ieee80211_softmac.c */
7518 -extern short ieee80211_is_54g(struct ieee80211_network net);
7519 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
7520 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
7521 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
7522 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
7523 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
7524 struct ieee80211_rx_stats *rx_stats, u16 type,
7525 u16 stype);
7526 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
7527 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
7528  
7529 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
7530 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
7531 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
7532 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
7533 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
7534 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
7535 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
7536 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
7537 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
7538 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
7539 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
7540 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
7541 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
7542 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
7543 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
7544 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
7545 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
7546 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
7547 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
7548 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
7549 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
7550 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
7551 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
7552 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
7553 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
7554 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
7555 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
7556 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
7557 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
7558 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
7559 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
7560 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
7561 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
7562 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
7563 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
7564 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
7565 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
7566 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
7567 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
7568 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
7569 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
7570 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
7571 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
7572 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
7573 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
7574 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
7575 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
7576 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
7577 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
7578 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
7579  
7580 /* ieee80211_softmac_wx.c */
7581  
7582 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
7583 - struct iw_request_info *info,
7584 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
7585 + struct iw_request_info *info,
7586 union iwreq_data *wrqu, char *ext);
7587 -
7588 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
7589 +
7590 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
7591 struct iw_request_info *info,
7592 union iwreq_data *awrq,
7593 char *extra);
7594 -
7595 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
7596  
7597 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
7598 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
7599 +
7600 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
7601 struct iw_request_info *info,
7602 union iwreq_data *wrqu, char *extra);
7603 -
7604 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
7605 - struct iw_request_info *info,
7606 +
7607 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
7608 + struct iw_request_info *info,
7609 union iwreq_data *wrqu, char *extra);
7610 -
7611 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
7612 +
7613 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7614 union iwreq_data *wrqu, char *b);
7615 -
7616 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
7617 +
7618 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7619 union iwreq_data *wrqu, char *b);
7620 -
7621 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
7622 +
7623 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
7624 struct iw_request_info *a,
7625 union iwreq_data *wrqu, char *extra);
7626 -
7627 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
7628 +
7629 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7630 union iwreq_data *wrqu, char *b);
7631  
7632 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
7633 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7634 union iwreq_data *wrqu, char *b);
7635  
7636 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
7637 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
7638 union iwreq_data *wrqu, char *b);
7639  
7640 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
7641 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
7642 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
7643 +#else
7644 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
7645 +#endif
7646  
7647 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
7648 - struct iw_request_info *info,
7649 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
7650 + struct iw_request_info *info,
7651 union iwreq_data *wrqu, char *extra);
7652 -
7653 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
7654 - struct iw_request_info *info,
7655 +
7656 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
7657 + struct iw_request_info *info,
7658 union iwreq_data *wrqu, char *extra);
7659  
7660 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
7661 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
7662 struct iw_request_info *info,
7663 union iwreq_data *wrqu, char *extra);
7664  
7665 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
7666 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
7667 struct iw_request_info *info,
7668 union iwreq_data *wrqu, char *extra);
7669 -
7670 -extern const long ieee80211_wlan_frequencies[];
7671  
7672 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
7673 +extern const long ieee80211_wlan_frequencies_rtl7[];
7674 +
7675 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
7676 {
7677 ieee->scans++;
7678 }
7679  
7680 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
7681 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
7682 {
7683 return ieee->scans;
7684 }
7685 @@ -1372,7 +1398,7 @@
7686 const char *s = essid;
7687 char *d = escaped;
7688  
7689 - if (ieee80211_is_empty_essid(essid, essid_len)) {
7690 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
7691 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
7692 return escaped;
7693 }
7694 @@ -1390,4 +1416,5 @@
7695 *d = '\0';
7696 return escaped;
7697 }
7698 +
7699 #endif /* IEEE80211_H */
7700 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c
7701 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_module.c 2006-06-06 04:58:00.000000000 +0200
7702 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c 2008-01-30 17:38:11.000000000 +0100
7703 @@ -31,7 +31,6 @@
7704 *******************************************************************************/
7705  
7706 #include <linux/compiler.h>
7707 -#include <linux/config.h>
7708 #include <linux/errno.h>
7709 #include <linux/if_arp.h>
7710 #include <linux/in6.h>
7711 @@ -52,6 +51,12 @@
7712 #include <asm/uaccess.h>
7713 #include <net/arp.h>
7714  
7715 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
7716 +#include <linux/config.h>
7717 +#else
7718 +#include <linux/autoconf.h>
7719 +#endif
7720 +
7721 #include "ieee80211.h"
7722  
7723 MODULE_DESCRIPTION("802.11 data/management/control stack");
7724 @@ -60,7 +65,7 @@
7725  
7726 #define DRV_NAME "ieee80211"
7727  
7728 -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
7729 +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee)
7730 {
7731 if (ieee->networks)
7732 return 0;
7733 @@ -80,7 +85,7 @@
7734 return 0;
7735 }
7736  
7737 -static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
7738 +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee)
7739 {
7740 if (!ieee->networks)
7741 return;
7742 @@ -88,7 +93,7 @@
7743 ieee->networks = NULL;
7744 }
7745  
7746 -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
7747 +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee)
7748 {
7749 int i;
7750  
7751 @@ -99,7 +104,7 @@
7752 }
7753  
7754  
7755 -struct net_device *alloc_ieee80211(int sizeof_priv)
7756 +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv)
7757 {
7758 struct ieee80211_device *ieee;
7759 struct net_device *dev;
7760 @@ -113,17 +118,17 @@
7761 goto failed;
7762 }
7763 ieee = netdev_priv(dev);
7764 - dev->hard_start_xmit = ieee80211_xmit;
7765 + dev->hard_start_xmit = ieee80211_xmit_rtl7;
7766  
7767 ieee->dev = dev;
7768  
7769 - err = ieee80211_networks_allocate(ieee);
7770 + err = ieee80211_networks_allocate_rtl7(ieee);
7771 if (err) {
7772 IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
7773 err);
7774 goto failed;
7775 }
7776 - ieee80211_networks_initialize(ieee);
7777 + ieee80211_networks_initialize_rtl7(ieee);
7778  
7779 /* Default fragmentation threshold is maximum payload size */
7780 ieee->fts = DEFAULT_FTS;
7781 @@ -138,7 +143,7 @@
7782 INIT_LIST_HEAD(&ieee->crypt_deinit_list);
7783 init_timer(&ieee->crypt_deinit_timer);
7784 ieee->crypt_deinit_timer.data = (unsigned long)ieee;
7785 - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
7786 + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7;
7787  
7788 spin_lock_init(&ieee->lock);
7789  
7790 @@ -149,7 +154,7 @@
7791 ieee->ieee802_1x = 1;
7792 ieee->raw_tx = 0;
7793  
7794 - ieee80211_softmac_init(ieee);
7795 + ieee80211_softmac_init_rtl7(ieee);
7796  
7797 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
7798 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
7799 @@ -167,7 +172,7 @@
7800 }
7801  
7802  
7803 -void free_ieee80211(struct net_device *dev)
7804 +void free_ieee80211_rtl7(struct net_device *dev)
7805 {
7806 struct ieee80211_device *ieee = netdev_priv(dev);
7807  
7808 @@ -175,9 +180,9 @@
7809 struct list_head *p, *q;
7810  
7811  
7812 - ieee80211_softmac_free(ieee);
7813 + ieee80211_softmac_free_rtl7(ieee);
7814 del_timer_sync(&ieee->crypt_deinit_timer);
7815 - ieee80211_crypt_deinit_entries(ieee, 1);
7816 + ieee80211_crypt_deinit_entries_rtl7(ieee, 1);
7817  
7818 for (i = 0; i < WEP_KEYS; i++) {
7819 struct ieee80211_crypt_data *crypt = ieee->crypt[i];
7820 @@ -191,7 +196,7 @@
7821 }
7822 }
7823  
7824 - ieee80211_networks_free(ieee);
7825 + ieee80211_networks_free_rtl7(ieee);
7826  
7827 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
7828 list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
7829 @@ -210,13 +215,13 @@
7830 u32 ieee80211_debug_level = 0;
7831 struct proc_dir_entry *ieee80211_proc = NULL;
7832  
7833 -static int show_debug_level(char *page, char **start, off_t offset,
7834 +static int show_debug_level_rtl7(char *page, char **start, off_t offset,
7835 int count, int *eof, void *data)
7836 {
7837 return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
7838 }
7839  
7840 -static int store_debug_level(struct file *file, const char *buffer,
7841 +static int store_debug_level_rtl7(struct file *file, const char *buffer,
7842 unsigned long count, void *data)
7843 {
7844 char buf[] = "0x00000000";
7845 @@ -243,7 +248,7 @@
7846 return strnlen(buf, count);
7847 }
7848  
7849 -static int __init ieee80211_init(void)
7850 +static int __init ieee80211_init_rtl7(void)
7851 {
7852 struct proc_dir_entry *e;
7853  
7854 @@ -268,7 +273,7 @@
7855 return 0;
7856 }
7857  
7858 -static void __exit ieee80211_exit(void)
7859 +static void __exit ieee80211_exit_rtl7(void)
7860 {
7861 if (ieee80211_proc) {
7862 remove_proc_entry("debug_level", ieee80211_proc);
7863 @@ -282,9 +287,9 @@
7864 MODULE_PARM_DESC(debug, "debug output mask");
7865  
7866  
7867 -module_exit(ieee80211_exit);
7868 -module_init(ieee80211_init);
7869 +module_exit(ieee80211_exit_rtl7);
7870 +module_init(ieee80211_init_rtl7);
7871 #endif
7872  
7873 -EXPORT_SYMBOL(alloc_ieee80211);
7874 -EXPORT_SYMBOL(free_ieee80211);
7875 +EXPORT_SYMBOL(alloc_ieee80211_rtl7);
7876 +EXPORT_SYMBOL(free_ieee80211_rtl7);
7877 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c
7878 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_rx.c 2006-06-06 04:58:00.000000000 +0200
7879 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c 2008-01-30 17:38:11.000000000 +0100
7880 @@ -13,16 +13,15 @@
7881 * more details.
7882 ******************************************************************************
7883  
7884 - Few modifications for Realtek's Wi-Fi drivers by
7885 + Few modifications for Realtek's Wi-Fi drivers by
7886 Andrea Merello <andreamrl@tiscali.it>
7887 -
7888 - A special thanks goes to Realtek for their support !
7889 +
7890 + A special thanks goes to Realtek for their support !
7891  
7892 ******************************************************************************/
7893 -
7894 +
7895  
7896 #include <linux/compiler.h>
7897 -#include <linux/config.h>
7898 #include <linux/errno.h>
7899 #include <linux/if_arp.h>
7900 #include <linux/in6.h>
7901 @@ -43,18 +42,89 @@
7902 #include <asm/uaccess.h>
7903 #include <linux/ctype.h>
7904  
7905 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
7906 +#include <linux/config.h>
7907 +#else
7908 +#include <linux/autoconf.h>
7909 +#endif
7910 +
7911 +
7912 #include "ieee80211.h"
7913  
7914 -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
7915 +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee,
7916 struct sk_buff *skb,
7917 struct ieee80211_rx_stats *rx_stats)
7918 {
7919 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
7920 - u16 fc = le16_to_cpu(hdr->frame_ctl);
7921 + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data;
7922 + u16 fc = le16_to_cpu(hdr1->frame_ctl);
7923 + int prism_header;
7924 + int hdrlen, phdrlen, head_need, tail_need;
7925 +
7926 + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) {
7927 + prism_header = 1;
7928 + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
7929 + } else {
7930 + prism_header = 0;
7931 + phdrlen = 0;
7932 + }
7933 +
7934 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
7935 +
7936 + /* check if there is enough room for extra data; if not, expand skb
7937 + * buffer to be large enough for the changes */
7938 + head_need = phdrlen;
7939 + tail_need = 0;
7940 +#ifdef PRISM2_ADD_BOGUS_CRC
7941 + tail_need += 4;
7942 +#endif /* PRISM2_ADD_BOGUS_CRC */
7943 +
7944 + head_need -= skb_headroom(skb);
7945 + tail_need -= skb_tailroom(skb);
7946 +
7947 + if (head_need > 0 || tail_need > 0) {
7948 + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
7949 + tail_need > 0 ? tail_need : 0,
7950 + GFP_ATOMIC)) {
7951 + printk(KERN_DEBUG "%s: ieee80211_rx failed to "
7952 + "reallocate skb buffer\n", ieee->dev->name);
7953 + dev_kfree_skb_any(skb);
7954 + return;
7955 + }
7956 + }
7957 +
7958 + if (prism_header == 1) {
7959 + struct linux_wlan_ng_prism_hdr *hdr;
7960 + hdr = (struct linux_wlan_ng_prism_hdr *)
7961 + skb_push(skb, phdrlen);
7962 + memset(hdr, 0, phdrlen);
7963 + hdr->msgcode = LWNG_CAP_DID_BASE;
7964 + hdr->msglen = sizeof(*hdr);
7965 + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname));
7966 +#define LWNG_SETVAL(f,i,s,l,d) \
7967 +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
7968 +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
7969 + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
7970 + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time));
7971 + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
7972 + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
7973 + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
7974 + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
7975 + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
7976 + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
7977 + LWNG_SETVAL(istx, 9, 0, 4, 0);
7978 + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
7979 +#undef LWNG_SETVAL
7980 + }
7981  
7982 skb->dev = ieee->dev;
7983 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
7984 skb->mac.raw = skb->data;
7985 - skb_pull(skb, ieee80211_get_hdrlen(fc));
7986 +#else
7987 + skb_reset_mac_header(skb);
7988 +#endif
7989 + skb_pull(skb, hdrlen);
7990 + if (prism_header)
7991 + skb_pull(skb, phdrlen);
7992 skb->pkt_type = PACKET_OTHERHOST;
7993 skb->protocol = __constant_htons(ETH_P_80211_RAW);
7994 memset(skb->cb, 0, sizeof(skb->cb));
7995 @@ -64,7 +134,7 @@
7996  
7997 /* Called only as a tasklet (software IRQ) */
7998 static struct ieee80211_frag_entry *
7999 -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
8000 +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq,
8001 unsigned int frag, u8 *src, u8 *dst)
8002 {
8003 struct ieee80211_frag_entry *entry;
8004 @@ -94,7 +164,7 @@
8005  
8006 /* Called only as a tasklet (software IRQ) */
8007 static struct sk_buff *
8008 -ieee80211_frag_cache_get(struct ieee80211_device *ieee,
8009 +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee,
8010 struct ieee80211_hdr *hdr)
8011 {
8012 struct sk_buff *skb = NULL;
8013 @@ -133,7 +203,7 @@
8014 } else {
8015 /* received a fragment of a frame for which the head fragment
8016 * should have already been received */
8017 - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
8018 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2,
8019 hdr->addr1);
8020 if (entry != NULL) {
8021 entry->last_frag = frag;
8022 @@ -146,7 +216,7 @@
8023  
8024  
8025 /* Called only as a tasklet (software IRQ) */
8026 -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
8027 +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee,
8028 struct ieee80211_hdr *hdr)
8029 {
8030 u16 sc;
8031 @@ -156,7 +226,7 @@
8032 sc = le16_to_cpu(hdr->seq_ctl);
8033 seq = WLAN_GET_SEQ_SEQ(sc);
8034  
8035 - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
8036 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2,
8037 hdr->addr1);
8038  
8039 if (entry == NULL) {
8040 @@ -178,7 +248,7 @@
8041 *
8042 * Called by ieee80211_rx */
8043 static inline int
8044 -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
8045 +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
8046 struct ieee80211_rx_stats *rx_stats, u16 type,
8047 u16 stype)
8048 {
8049 @@ -187,13 +257,13 @@
8050 * response parser uses it
8051 */
8052 rx_stats->len = skb->len;
8053 - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
8054 - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
8055 + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
8056 + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype);
8057  
8058 dev_kfree_skb_any(skb);
8059 -
8060 +
8061 return 0;
8062 -
8063 +
8064 #ifdef NOT_YET
8065 if (ieee->iw_mode == IW_MODE_MASTER) {
8066 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
8067 @@ -253,7 +323,7 @@
8068 /* No encapsulation header if EtherType < 0x600 (=length) */
8069  
8070 /* Called by ieee80211_rx_frame_decrypt */
8071 -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
8072 +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee,
8073 struct sk_buff *skb)
8074 {
8075 struct net_device *dev = ieee->dev;
8076 @@ -294,7 +364,7 @@
8077  
8078 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
8079 static inline int
8080 -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
8081 +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
8082 struct ieee80211_crypt_data *crypt)
8083 {
8084 struct ieee80211_hdr *hdr;
8085 @@ -304,7 +374,7 @@
8086 return 0;
8087  
8088 hdr = (struct ieee80211_hdr *) skb->data;
8089 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
8090 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
8091  
8092 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
8093 if (ieee->tkip_countermeasures &&
8094 @@ -339,7 +409,7 @@
8095  
8096 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
8097 static inline int
8098 -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
8099 +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
8100 int keyidx, struct ieee80211_crypt_data *crypt)
8101 {
8102 struct ieee80211_hdr *hdr;
8103 @@ -349,7 +419,7 @@
8104 return 0;
8105  
8106 hdr = (struct ieee80211_hdr *) skb->data;
8107 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
8108 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
8109  
8110 atomic_inc(&crypt->refcnt);
8111 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
8112 @@ -367,7 +437,7 @@
8113  
8114 /* this function is stolen from ipw2200 driver*/
8115 #define IEEE_PACKET_RETRY_TIME (5*HZ)
8116 -static int is_duplicate_packet(struct ieee80211_device *ieee,
8117 +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee,
8118 struct ieee80211_hdr *header)
8119 {
8120 // u16 fc = le16_to_cpu(header->frame_ctl);
8121 @@ -413,7 +483,7 @@
8122 last_seq = &ieee->last_seq_num;
8123 last_frag = &ieee->last_frag_num;
8124 last_time = &ieee->last_packet_time;
8125 -
8126 +
8127 break;
8128 default:
8129 return 0;
8130 @@ -436,7 +506,7 @@
8131 drop:
8132 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
8133 // printk("DUP\n");
8134 -
8135 +
8136 return 1;
8137 }
8138  
8139 @@ -444,7 +514,7 @@
8140 /* All received frames are sent to this function. @skb contains the frame in
8141 * IEEE 802.11 format, i.e., in the format it was sent over air.
8142 * This function is called only as a tasklet (software IRQ). */
8143 -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
8144 +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
8145 struct ieee80211_rx_stats *rx_stats)
8146 {
8147 struct net_device *dev = ieee->dev;
8148 @@ -481,9 +551,9 @@
8149 type = WLAN_FC_GET_TYPE(fc);
8150 stype = WLAN_FC_GET_STYPE(fc);
8151 sc = le16_to_cpu(hdr->seq_ctl);
8152 -
8153 +
8154 frag = WLAN_GET_SEQ_FRAG(sc);
8155 - hdrlen = ieee80211_get_hdrlen(fc);
8156 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
8157  
8158 #ifdef NOT_YET
8159 #if WIRELESS_EXT > 15
8160 @@ -501,12 +571,12 @@
8161 }
8162 #endif /* IW_WIRELESS_SPY */
8163 #endif /* WIRELESS_EXT > 15 */
8164 - hostap_update_rx_stats(local->ap, hdr, rx_stats);
8165 + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats);
8166 #endif
8167  
8168 #if WIRELESS_EXT > 15
8169 if (ieee->iw_mode == IW_MODE_MONITOR) {
8170 - ieee80211_monitor_rx(ieee, skb, rx_stats);
8171 + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats);
8172 stats->rx_packets++;
8173 stats->rx_bytes += skb->len;
8174 return 1;
8175 @@ -529,7 +599,7 @@
8176 * stations that do not support WEP key mapping). */
8177  
8178 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
8179 - (void) hostap_handle_sta_crypto(local, hdr, &crypt,
8180 + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt,
8181 &sta);
8182 #endif
8183  
8184 @@ -555,7 +625,7 @@
8185 if (skb->len < IEEE80211_DATA_HDR3_LEN)
8186 goto rx_dropped;
8187  
8188 - if (is_duplicate_packet(ieee, hdr))
8189 + if (is_duplicate_packet_rtl7(ieee, hdr))
8190 goto rx_dropped;
8191  
8192  
8193 @@ -573,9 +643,9 @@
8194 goto rx_dropped;
8195 }
8196 #endif
8197 -
8198 -
8199 - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
8200 +
8201 +
8202 + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype))
8203 goto rx_dropped;
8204 else
8205 goto rx_exit;
8206 @@ -583,7 +653,7 @@
8207  
8208  
8209 /* Data frame - extract src/dst addresses */
8210 -
8211 +
8212 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
8213 case IEEE80211_FCTL_FROMDS:
8214 memcpy(dst, hdr->addr1, ETH_ALEN);
8215 @@ -606,7 +676,7 @@
8216 }
8217  
8218 #ifdef NOT_YET
8219 - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
8220 + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds))
8221 goto rx_dropped;
8222 if (wds) {
8223 skb->dev = dev = wds;
8224 @@ -619,7 +689,7 @@
8225 memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
8226 /* Frame from BSSID of the AP for which we are a client */
8227 skb->dev = dev = ieee->stadev;
8228 - stats = hostap_get_stats(dev);
8229 + stats = hostap_get_stats_rtl7(dev);
8230 from_assoc_ap = 1;
8231 }
8232 #endif
8233 @@ -630,7 +700,7 @@
8234 if ((ieee->iw_mode == IW_MODE_MASTER ||
8235 ieee->iw_mode == IW_MODE_REPEAT) &&
8236 !from_assoc_ap) {
8237 - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
8238 + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats,
8239 wds != NULL)) {
8240 case AP_RX_CONTINUE_NOT_AUTHORIZED:
8241 frame_authorized = 0;
8242 @@ -664,7 +734,7 @@
8243 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
8244  
8245 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8246 - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
8247 + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0)
8248 goto rx_dropped;
8249  
8250 hdr = (struct ieee80211_hdr *) skb->data;
8251 @@ -674,7 +744,7 @@
8252 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8253 if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
8254 int flen;
8255 - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
8256 + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr);
8257 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
8258  
8259 if (!frag_skb) {
8260 @@ -694,7 +764,7 @@
8261 printk(KERN_WARNING "%s: host decrypted and "
8262 "reassembled frame did not fit skb\n",
8263 dev->name);
8264 - ieee80211_frag_cache_invalidate(ieee, hdr);
8265 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
8266 goto rx_dropped;
8267 }
8268  
8269 @@ -722,19 +792,19 @@
8270 * delivered, so remove skb from fragment cache */
8271 skb = frag_skb;
8272 hdr = (struct ieee80211_hdr *) skb->data;
8273 - ieee80211_frag_cache_invalidate(ieee, hdr);
8274 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
8275 }
8276  
8277 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
8278 * encrypted/authenticated */
8279 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
8280 - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
8281 + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt))
8282 goto rx_dropped;
8283  
8284 hdr = (struct ieee80211_hdr *) skb->data;
8285 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
8286 if (/*ieee->ieee802_1x &&*/
8287 - ieee80211_is_eapol_frame(ieee, skb)) {
8288 + ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
8289 #ifdef CONFIG_IEEE80211_DEBUG
8290 /* pass unencrypted EAPOL frames even if encryption is
8291 * configured */
8292 @@ -763,7 +833,7 @@
8293 #endif
8294  
8295 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
8296 - !ieee80211_is_eapol_frame(ieee, skb)) {
8297 + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
8298 IEEE80211_DEBUG_DROP(
8299 "dropped unencrypted RX data "
8300 "frame from " MAC_FMT
8301 @@ -861,7 +931,12 @@
8302 if (skb2 != NULL) {
8303 /* send to wireless media */
8304 skb2->protocol = __constant_htons(ETH_P_802_3);
8305 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
8306 skb2->mac.raw = skb2->nh.raw = skb2->data;
8307 +#else
8308 + skb_reset_mac_header(skb2);
8309 + skb_reset_network_header(skb2);
8310 +#endif
8311 /* skb2->nh.raw = skb2->data + ETH_HLEN; */
8312 skb2->dev = dev;
8313 dev_queue_xmit(skb2);
8314 @@ -896,7 +971,7 @@
8315  
8316 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
8317  
8318 -static inline int ieee80211_is_ofdm_rate(u8 rate)
8319 +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate)
8320 {
8321 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
8322 case IEEE80211_OFDM_RATE_6MB:
8323 @@ -913,7 +988,7 @@
8324 }
8325  
8326  
8327 -static inline int ieee80211_network_init(
8328 +static inline int ieee80211_network_init_rtl7(
8329 struct ieee80211_device *ieee,
8330 struct ieee80211_probe_response *beacon,
8331 struct ieee80211_network *network,
8332 @@ -964,7 +1039,7 @@
8333  
8334 switch (info_element->id) {
8335 case MFIE_TYPE_SSID:
8336 - if (ieee80211_is_empty_essid(info_element->data,
8337 + if (ieee80211_is_empty_essid_rtl7(info_element->data,
8338 info_element->len)) {
8339 network->flags |= NETWORK_EMPTY_ESSID;
8340 break;
8341 @@ -991,7 +1066,7 @@
8342 #ifdef CONFIG_IEEE80211_DEBUG
8343 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
8344 #endif
8345 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
8346 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
8347 network->flags |= NETWORK_HAS_OFDM;
8348 if (info_element->data[i] &
8349 IEEE80211_BASIC_RATE_MASK)
8350 @@ -1014,7 +1089,7 @@
8351 #ifdef CONFIG_IEEE80211_DEBUG
8352 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
8353 #endif
8354 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
8355 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
8356 network->flags |= NETWORK_HAS_OFDM;
8357 if (info_element->data[i] &
8358 IEEE80211_BASIC_RATE_MASK)
8359 @@ -1043,47 +1118,47 @@
8360 break;
8361  
8362 case MFIE_TYPE_TIM:
8363 -
8364 - if(info_element->len < 4)
8365 +
8366 + if(info_element->len < 4)
8367 break;
8368 -
8369 +
8370 network->dtim_period = info_element->data[1];
8371 -
8372 +
8373 if(ieee->state != IEEE80211_LINKED)
8374 break;
8375 -
8376 - network->last_dtim_sta_time[0] = stats->mac_time[0];
8377 +
8378 + network->last_dtim_sta_time[0] = stats->mac_time[0];
8379 network->last_dtim_sta_time[1] = stats->mac_time[1];
8380 -
8381 +
8382 network->dtim_data = IEEE80211_DTIM_VALID;
8383 -
8384 - if(info_element->data[0] != 0)
8385 +
8386 + if(info_element->data[0] != 0)
8387 break;
8388 -
8389 +
8390 if(info_element->data[2] & 1)
8391 network->dtim_data |= IEEE80211_DTIM_MBCAST;
8392 -
8393 +
8394 offset = (info_element->data[2] >> 1)*2;
8395 -
8396 - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
8397 -
8398 - if(ieee->assoc_id < offset ||
8399 +
8400 + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
8401 +
8402 + if(ieee->assoc_id < offset ||
8403 ieee->assoc_id > 8*(offset + info_element->len -3))
8404 -
8405 +
8406 break;
8407 -
8408 -
8409 +
8410 +
8411 offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ;
8412 -
8413 - // printk("offset:%x data:%x, ucast:%d\n", offset,
8414 +
8415 + // printk("offset:%x data:%x, ucast:%d\n", offset,
8416 // info_element->data[3+offset] ,
8417 // info_element->data[3+offset] & (1<<(ieee->assoc_id%8)));
8418 -
8419 +
8420 if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
8421 network->dtim_data |= IEEE80211_DTIM_UCAST;
8422 -
8423 +
8424 break;
8425 -
8426 +
8427 case MFIE_TYPE_IBSS_SET:
8428 IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n");
8429 break;
8430 @@ -1115,7 +1190,7 @@
8431 memcpy(network->rsn_ie, info_element,
8432 network->rsn_ie_len);
8433 break;
8434 -
8435 +
8436 default:
8437 IEEE80211_DEBUG_SCAN("unsupported IE %d\n",
8438 info_element->id);
8439 @@ -1147,7 +1222,7 @@
8440 return 1;
8441 }
8442  
8443 - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
8444 + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len))
8445 network->flags |= NETWORK_EMPTY_ESSID;
8446  
8447 memcpy(&network->stats, stats, sizeof(network->stats));
8448 @@ -1155,24 +1230,24 @@
8449 return 0;
8450 }
8451  
8452 -static inline int is_same_network(struct ieee80211_network *src,
8453 +static inline int is_same_network_rtl7(struct ieee80211_network *src,
8454 struct ieee80211_network *dst)
8455 {
8456 /* A network is only a duplicate if the channel, BSSID, ESSID
8457 - * and the capability field (in particular IBSS and BSS) all match.
8458 + * and the capability field (in particular IBSS and BSS) all match.
8459 * We treat all <hidden> with the same BSSID and channel
8460 * as one network */
8461 return ((src->ssid_len == dst->ssid_len) &&
8462 (src->channel == dst->channel) &&
8463 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
8464 !memcmp(src->ssid, dst->ssid, src->ssid_len) &&
8465 - ((src->capability & WLAN_CAPABILITY_IBSS) ==
8466 + ((src->capability & WLAN_CAPABILITY_IBSS) ==
8467 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
8468 - ((src->capability & WLAN_CAPABILITY_BSS) ==
8469 + ((src->capability & WLAN_CAPABILITY_BSS) ==
8470 (dst->capability & WLAN_CAPABILITY_BSS)));
8471 }
8472  
8473 -static inline void update_network(struct ieee80211_network *dst,
8474 +static inline void update_network_rtl7(struct ieee80211_network *dst,
8475 struct ieee80211_network *src)
8476 {
8477 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
8478 @@ -1194,7 +1269,7 @@
8479 dst->dtim_data = src->dtim_data;
8480 dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
8481 dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
8482 -
8483 +
8484 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
8485 dst->wpa_ie_len = src->wpa_ie_len;
8486 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
8487 @@ -1204,7 +1279,7 @@
8488 /* dst->last_associate is not overwritten */
8489 }
8490  
8491 -static inline void ieee80211_process_probe_response(
8492 +static inline void ieee80211_process_probe_response_rtl7(
8493 struct ieee80211_device *ieee,
8494 struct ieee80211_probe_response *beacon,
8495 struct ieee80211_rx_stats *stats)
8496 @@ -1239,7 +1314,7 @@
8497 (beacon->capability & (1<<0x1)) ? '1' : '0',
8498 (beacon->capability & (1<<0x0)) ? '1' : '0');
8499  
8500 - if (ieee80211_network_init(ieee, beacon, &network, stats)) {
8501 + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) {
8502 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
8503 escape_essid(info_element->data,
8504 info_element->len),
8505 @@ -1261,12 +1336,12 @@
8506 * already there. */
8507  
8508 spin_lock_irqsave(&ieee->lock, flags);
8509 -
8510 - if(is_same_network(&ieee->current_network, &network))
8511 - update_network(&ieee->current_network, &network);
8512 -
8513 +
8514 + if(is_same_network_rtl7(&ieee->current_network, &network))
8515 + update_network_rtl7(&ieee->current_network, &network);
8516 +
8517 list_for_each_entry(target, &ieee->network_list, list) {
8518 - if (is_same_network(target, &network))
8519 + if (is_same_network_rtl7(target, &network))
8520 break;
8521  
8522 if ((oldest == NULL) ||
8523 @@ -1306,7 +1381,7 @@
8524 memcpy(target, &network, sizeof(*target));
8525 list_add_tail(&target->list, &ieee->network_list);
8526 if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
8527 - ieee80211_softmac_new_net(ieee,&network);
8528 + ieee80211_softmac_new_net_rtl7(ieee,&network);
8529 } else {
8530 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
8531 escape_essid(target->ssid,
8532 @@ -1315,39 +1390,39 @@
8533 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
8534 IEEE80211_STYPE_PROBE_RESP ?
8535 "PROBE RESPONSE" : "BEACON");
8536 -
8537 +
8538 /* we have an entry and we are going to update it. But this entry may
8539 - * be already expired. In this case we do the same as we found a new
8540 + * be already expired. In this case we do the same as we found a new
8541 * net and call the new_net handler
8542 */
8543 renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
8544 - update_network(target, &network);
8545 + update_network_rtl7(target, &network);
8546 if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
8547 - ieee80211_softmac_new_net(ieee,&network);
8548 + ieee80211_softmac_new_net_rtl7(ieee,&network);
8549 }
8550  
8551 spin_unlock_irqrestore(&ieee->lock, flags);
8552 }
8553  
8554 -void ieee80211_rx_mgt(struct ieee80211_device *ieee,
8555 +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
8556 struct ieee80211_hdr *header,
8557 struct ieee80211_rx_stats *stats)
8558 {
8559 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
8560 -
8561 +
8562 case IEEE80211_STYPE_BEACON:
8563 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
8564 WLAN_FC_GET_STYPE(header->frame_ctl));
8565 IEEE80211_DEBUG_SCAN("Beacon\n");
8566 - ieee80211_process_probe_response(
8567 + ieee80211_process_probe_response_rtl7(
8568 ieee, (struct ieee80211_probe_response *)header, stats);
8569 break;
8570 -
8571 +
8572 case IEEE80211_STYPE_PROBE_RESP:
8573 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
8574 WLAN_FC_GET_STYPE(header->frame_ctl));
8575 IEEE80211_DEBUG_SCAN("Probe response\n");
8576 - ieee80211_process_probe_response(
8577 + ieee80211_process_probe_response_rtl7(
8578 ieee, (struct ieee80211_probe_response *)header, stats);
8579 break;
8580  
8581 @@ -1355,5 +1430,5 @@
8582 }
8583  
8584  
8585 -EXPORT_SYMBOL(ieee80211_rx_mgt);
8586 -EXPORT_SYMBOL(ieee80211_rx);
8587 +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7);
8588 +EXPORT_SYMBOL(ieee80211_rx_rtl7);
8589 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c
8590 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac.c 2006-06-19 03:27:33.000000000 +0200
8591 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c 2008-01-30 17:38:11.000000000 +0100
8592 @@ -1,14 +1,14 @@
8593 /* IEEE 802.11 SoftMAC layer
8594 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
8595 *
8596 - * Mostly extracted from the rtl8180-sa2400 driver for the
8597 + * Mostly extracted from the rtl8180-sa2400 driver for the
8598 * in-kernel generic ieee802.11 stack.
8599 *
8600 * Few lines might be stolen from other part of the ieee80211
8601 * stack. Copyright who own it's copyright
8602 *
8603 * WPA code stolen from the ipw2200 driver.
8604 - * Copyright who own it's copyright.
8605 + * Copyright who own it's copyright.
8606 *
8607 * released under the GPL
8608 */
8609 @@ -20,12 +20,12 @@
8610 #include <linux/delay.h>
8611 #include <linux/version.h>
8612  
8613 -short ieee80211_is_54g(struct ieee80211_network net)
8614 +short ieee80211_is_54g_rtl7(struct ieee80211_network net)
8615 {
8616 return ((net.rates_ex_len > 0) || (net.rates_len > 4));
8617 }
8618  
8619 -short ieee80211_is_shortslot(struct ieee80211_network net)
8620 +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net)
8621 {
8622 return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
8623 }
8624 @@ -34,28 +34,28 @@
8625 * tag and the EXTENDED RATE MFIE tag if needed.
8626 * It encludes two bytes per tag for the tag itself and its len
8627 */
8628 -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
8629 +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee)
8630 {
8631 unsigned int rate_len = 0;
8632 -
8633 +
8634 if (ieee->modulation & IEEE80211_CCK_MODULATION)
8635 rate_len = IEEE80211_CCK_RATE_LEN + 2;
8636 -
8637 +
8638 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
8639 -
8640 +
8641 rate_len += IEEE80211_OFDM_RATE_LEN + 2;
8642 -
8643 +
8644 return rate_len;
8645 }
8646  
8647 -/* pleace the MFIE rate, tag to the memory (double) poined.
8648 +/* pleace the MFIE rate, tag to the memory (double) poined.
8649 * Then it updates the pointer so that
8650 * it points after the new MFIE tag added.
8651 - */
8652 -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
8653 + */
8654 +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
8655 {
8656 - u8 *tag = *tag_p;
8657 -
8658 + u8 *tag = *tag_p;
8659 +
8660 if (ieee->modulation & IEEE80211_CCK_MODULATION){
8661 *tag++ = MFIE_TYPE_RATES;
8662 *tag++ = 4;
8663 @@ -64,17 +64,17 @@
8664 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
8665 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
8666 }
8667 -
8668 +
8669 /* We may add an option for custom rates that specific HW might support */
8670 *tag_p = tag;
8671 }
8672  
8673 -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
8674 -{
8675 - u8 *tag = *tag_p;
8676 -
8677 +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
8678 +{
8679 + u8 *tag = *tag_p;
8680 +
8681 if (ieee->modulation & IEEE80211_OFDM_MODULATION){
8682 -
8683 +
8684 *tag++ = MFIE_TYPE_RATES_EX;
8685 *tag++ = 8;
8686 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
8687 @@ -85,73 +85,73 @@
8688 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
8689 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
8690 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
8691 -
8692 +
8693 }
8694 -
8695 +
8696 /* We may add an option for custom rates that specific HW might support */
8697 *tag_p = tag;
8698 }
8699  
8700 -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
8701 +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
8702 {
8703 int nh;
8704 nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
8705 -
8706 +
8707 /*
8708 * if the queue is full but we have newer frames then
8709 * just overwrites the oldest.
8710 - *
8711 + *
8712 * if (nh == ieee->mgmt_queue_tail)
8713 * return -1;
8714 - */
8715 + */
8716 ieee->mgmt_queue_head = nh;
8717 ieee->mgmt_queue_ring[nh] = skb;
8718 -
8719 +
8720 //return 0;
8721 }
8722  
8723 -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
8724 +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee)
8725 {
8726 struct sk_buff *ret;
8727 -
8728 +
8729 if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
8730 return NULL;
8731 -
8732 +
8733 ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
8734 -
8735 - ieee->mgmt_queue_tail =
8736 +
8737 + ieee->mgmt_queue_tail =
8738 (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
8739 -
8740 +
8741 return ret;
8742 }
8743  
8744 -void init_mgmt_queue(struct ieee80211_device *ieee)
8745 +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee)
8746 {
8747 ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
8748 }
8749  
8750  
8751 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
8752 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl);
8753  
8754 -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
8755 +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
8756 {
8757 unsigned long flags;
8758 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
8759 struct ieee80211_hdr_3addr *header=
8760 (struct ieee80211_hdr_3addr *) skb->data;
8761 -
8762 -
8763 +
8764 +
8765 spin_lock_irqsave(&ieee->lock, flags);
8766 -
8767 +
8768 /* called with 2nd param 0, no mgmt lock required */
8769 - ieee80211_sta_wakeup(ieee,0);
8770 -
8771 + ieee80211_sta_wakeup_rtl7(ieee,0);
8772 +
8773 if(single){
8774 -
8775 +
8776 if(ieee->queue_stop){
8777 -
8778 - enqueue_mgmt(ieee,skb);
8779 -
8780 +
8781 + enqueue_mgmt_rtl7(ieee,skb);
8782 +
8783 }else{
8784 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8785  
8786 @@ -159,119 +159,119 @@
8787 ieee->seq_ctrl = 0;
8788 else
8789 ieee->seq_ctrl++;
8790 -
8791 +
8792 /* avoid watchdog triggers */
8793 ieee->dev->trans_start = jiffies;
8794 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
8795 }
8796 -
8797 +
8798 spin_unlock_irqrestore(&ieee->lock, flags);
8799 }else{
8800 spin_unlock_irqrestore(&ieee->lock, flags);
8801 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
8802 -
8803 +
8804 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8805 -
8806 +
8807 if (ieee->seq_ctrl == 0xFFF)
8808 ieee->seq_ctrl = 0;
8809 else
8810 ieee->seq_ctrl++;
8811 -
8812 +
8813 ieee->softmac_hard_start_xmit(skb,ieee->dev);
8814 -
8815 +
8816 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
8817 }
8818 }
8819  
8820  
8821 -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
8822 +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
8823 {
8824 -
8825 +
8826 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
8827 struct ieee80211_hdr_3addr *header =
8828 (struct ieee80211_hdr_3addr *) skb->data;
8829 -
8830 -
8831 +
8832 +
8833 if(single){
8834 -
8835 +
8836 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8837  
8838 if (ieee->seq_ctrl == 0xFFF)
8839 ieee->seq_ctrl = 0;
8840 else
8841 ieee->seq_ctrl++;
8842 -
8843 +
8844 /* avoid watchdog triggers */
8845 ieee->dev->trans_start = jiffies;
8846 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
8847 -
8848 +
8849 }else{
8850 -
8851 +
8852 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
8853 -
8854 +
8855 if (ieee->seq_ctrl == 0xFFF)
8856 ieee->seq_ctrl = 0;
8857 else
8858 ieee->seq_ctrl++;
8859  
8860 ieee->softmac_hard_start_xmit(skb,ieee->dev);
8861 -
8862 +
8863 }
8864 }
8865  
8866 -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
8867 +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee)
8868 {
8869 unsigned int len,rate_len;
8870 u8 *tag;
8871 struct sk_buff *skb;
8872 struct ieee80211_probe_request *req;
8873 -
8874 +
8875 len = ieee->current_network.ssid_len;
8876 -
8877 - rate_len = ieee80211_MFIE_rate_len(ieee);
8878 -
8879 +
8880 + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
8881 +
8882 skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
8883 2 + len + rate_len);
8884 -
8885 - if (!skb)
8886 +
8887 + if (!skb)
8888 return NULL;
8889 -
8890 +
8891 req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
8892 req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
8893 - req->header.duration_id = 0; //FIXME: is this OK ?
8894 -
8895 + req->header.duration_id = 0; //FIXME: is this OK ?
8896 +
8897 memset(req->header.addr1, 0xff, ETH_ALEN);
8898 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
8899 memset(req->header.addr3, 0xff, ETH_ALEN);
8900 -
8901 +
8902 tag = (u8 *) skb_put(skb,len+2+rate_len);
8903 -
8904 +
8905 *tag++ = MFIE_TYPE_SSID;
8906 *tag++ = len;
8907 memcpy(tag, ieee->current_network.ssid, len);
8908 tag += len;
8909 -
8910 - ieee80211_MFIE_Brate(ieee,&tag);
8911 - ieee80211_MFIE_Grate(ieee,&tag);
8912 +
8913 + ieee80211_MFIE_Brate_rtl7(ieee,&tag);
8914 + ieee80211_MFIE_Grate_rtl7(ieee,&tag);
8915 return skb;
8916 }
8917  
8918 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
8919 -void ieee80211_send_beacon(struct ieee80211_device *ieee)
8920 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee);
8921 +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee)
8922 {
8923 struct sk_buff *skb;
8924 -
8925 - unsigned long flags;
8926 -
8927 - skb = ieee80211_get_beacon_(ieee);
8928 +
8929 + unsigned long flags;
8930 +
8931 + skb = ieee80211_get_beacon__rtl7(ieee);
8932 if (skb){
8933 - softmac_mgmt_xmit(skb, ieee);
8934 + softmac_mgmt_xmit_rtl7(skb, ieee);
8935 ieee->softmac_stats.tx_beacons++;
8936 }
8937  
8938 - ieee->beacon_timer.expires = jiffies +
8939 + ieee->beacon_timer.expires = jiffies +
8940 (MSECS( ieee->current_network.beacon_interval -5));
8941 -
8942 +
8943 spin_lock_irqsave(&ieee->beacon_lock,flags);
8944 if(ieee->beacon_txing)
8945 add_timer(&ieee->beacon_timer);
8946 @@ -279,57 +279,57 @@
8947 }
8948  
8949  
8950 -void ieee80211_send_beacon_cb(unsigned long _ieee)
8951 +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee)
8952 {
8953 struct ieee80211_device *ieee =
8954 (struct ieee80211_device *) _ieee;
8955 - ieee80211_send_beacon(ieee);
8956 + ieee80211_send_beacon_rtl7(ieee);
8957 }
8958  
8959  
8960 -void ieee80211_send_probe(struct ieee80211_device *ieee)
8961 +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee)
8962 {
8963 struct sk_buff *skb;
8964 -
8965 - skb = ieee80211_probe_req(ieee);
8966 +
8967 + skb = ieee80211_probe_req_rtl7(ieee);
8968 if (skb){
8969 - softmac_mgmt_xmit(skb, ieee);
8970 + softmac_mgmt_xmit_rtl7(skb, ieee);
8971 ieee->softmac_stats.tx_probe_rq++;
8972 }
8973 }
8974  
8975 -void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
8976 +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee)
8977 {
8978 if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
8979 - ieee80211_send_probe(ieee);
8980 - ieee80211_send_probe(ieee);
8981 + ieee80211_send_probe_rtl7(ieee);
8982 + ieee80211_send_probe_rtl7(ieee);
8983 }
8984 }
8985  
8986 /* this performs syncro scan blocking the caller until all channels
8987 - * in the allowed channel map has been checked.
8988 + * in the allowed channel map has been checked.
8989 */
8990 -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
8991 +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee)
8992 {
8993 short ch = 0;
8994 -
8995 +
8996 down(&ieee->scan_sem);
8997 -
8998 +
8999 while(1)
9000 {
9001 -
9002 +
9003 do{
9004 ch++;
9005 - if (ch > MAX_CHANNEL_NUMBER)
9006 + if (ch > MAX_CHANNEL_NUMBER)
9007 goto out; /* scan completed */
9008 -
9009 +
9010 }while(!ieee->channel_map[ch]);
9011 -
9012 +
9013 /* this fuction can be called in two situations
9014 * 1- We have switched to ad-hoc mode and we are
9015 * performing a complete syncro scan before conclude
9016 - * there are no interesting cell and to create a
9017 - * new one. In this case the link state is
9018 + * there are no interesting cell and to create a
9019 + * new one. In this case the link state is
9020 * IEEE80211_NOLINK until we found an interesting cell.
9021 * If so the ieee8021_new_net, called by the RX path
9022 * will set the state to IEEE80211_LINKED, so we stop
9023 @@ -342,24 +342,24 @@
9024 * not filter RX frames and the channel is changing.
9025 * So the only situation in witch are interested is to check
9026 * if the state become LINKED because of the #1 situation
9027 - */
9028 -
9029 + */
9030 +
9031 if (ieee->state == IEEE80211_LINKED)
9032 goto out;
9033 -
9034 +
9035 ieee->set_chan(ieee->dev, ch);
9036 -
9037 - ieee80211_send_probe_requests(ieee);
9038 -
9039 +
9040 + ieee80211_send_probe_requests_rtl7(ieee);
9041 +
9042 /* this prevent excessive time wait when we
9043 * need to wait for a syncro scan to end..
9044 - */
9045 + */
9046 if (ieee->sync_scan_hurryup)
9047 goto out;
9048  
9049  
9050 msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME);
9051 -
9052 +
9053 }
9054 out:
9055 ieee->sync_scan_hurryup = 0;
9056 @@ -370,43 +370,49 @@
9057 void ieee80211_softmac_scan(struct ieee80211_device *ieee)
9058 {
9059 short watchdog = 0;
9060 -
9061 +
9062 do{
9063 - ieee->current_network.channel =
9064 + ieee->current_network.channel =
9065 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
9066 - if (watchdog++ > MAX_CHANNEL_NUMBER)
9067 + if (watchdog++ > MAX_CHANNEL_NUMBER)
9068 return; /* no good chans */
9069 -
9070 +
9071 }while(!ieee->channel_map[ieee->current_network.channel]);
9072 -
9073 +
9074  
9075 schedule_work(&ieee->softmac_scan_wq);
9076 }
9077 #endif
9078  
9079 -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
9080 -{
9081 - down(&ieee->scan_sem);
9082 -
9083 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9084 +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work)
9085 +{
9086 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
9087 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
9088 +#else
9089 +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee)
9090 +{
9091 +#endif
9092 short watchdog = 0;
9093 -
9094 + down(&ieee->scan_sem);
9095 +
9096 do{
9097 - ieee->current_network.channel =
9098 + ieee->current_network.channel =
9099 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
9100 - if (watchdog++ > MAX_CHANNEL_NUMBER)
9101 + if (watchdog++ > MAX_CHANNEL_NUMBER)
9102 goto out; /* no good chans */
9103 -
9104 +
9105 }while(!ieee->channel_map[ieee->current_network.channel]);
9106 -
9107 +
9108 if (ieee->scanning == 0 )
9109 goto out;
9110 -
9111 +
9112 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9113 - ieee80211_send_probe_requests(ieee);
9114 + ieee80211_send_probe_requests_rtl7(ieee);
9115  
9116 -#if 0
9117 +#if 0
9118 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME);
9119 - if (ieee->scanning == 1)
9120 + if (ieee->scanning == 1)
9121 add_timer(&ieee->scan_timer);
9122 #endif
9123 queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
9124 @@ -419,7 +425,7 @@
9125 {
9126 unsigned long flags;
9127 struct ieee80211_device *ieee = (struct ieee80211_device *)_dev;
9128 -
9129 +
9130 spin_lock_irqsave(&ieee->lock, flags);
9131 ieee80211_softmac_scan(ieee);
9132 spin_unlock_irqrestore(&ieee->lock, flags);
9133 @@ -427,19 +433,19 @@
9134 #endif
9135  
9136  
9137 -void ieee80211_beacons_start(struct ieee80211_device *ieee)
9138 +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee)
9139 {
9140 - unsigned long flags;
9141 + unsigned long flags;
9142  
9143 spin_lock_irqsave(&ieee->beacon_lock,flags);
9144  
9145 ieee->beacon_txing = 1;
9146 - ieee80211_send_beacon(ieee);
9147 -
9148 + ieee80211_send_beacon_rtl7(ieee);
9149 +
9150 spin_unlock_irqrestore(&ieee->beacon_lock,flags);
9151 }
9152  
9153 -void ieee80211_beacons_stop(struct ieee80211_device *ieee)
9154 +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee)
9155 {
9156 unsigned long flags;
9157  
9158 @@ -453,111 +459,111 @@
9159 }
9160  
9161  
9162 -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
9163 +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee)
9164 {
9165 if(ieee->stop_send_beacons)
9166 ieee->stop_send_beacons(ieee->dev);
9167 if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
9168 - ieee80211_beacons_stop(ieee);
9169 + ieee80211_beacons_stop_rtl7(ieee);
9170 }
9171  
9172  
9173 -void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
9174 +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee)
9175 {
9176 if(ieee->start_send_beacons)
9177 ieee->start_send_beacons(ieee->dev);
9178 if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
9179 - ieee80211_beacons_start(ieee);
9180 + ieee80211_beacons_start_rtl7(ieee);
9181 }
9182  
9183  
9184 -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
9185 +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee)
9186 {
9187 -// unsigned long flags;
9188 -
9189 +// unsigned long flags;
9190 +
9191 //ieee->sync_scan_hurryup = 1;
9192 -
9193 +
9194 down(&ieee->scan_sem);
9195 // spin_lock_irqsave(&ieee->lock, flags);
9196 -
9197 +
9198 if (ieee->scanning == 1){
9199 ieee->scanning = 0;
9200 //del_timer_sync(&ieee->scan_timer);
9201 cancel_delayed_work(&ieee->softmac_scan_wq);
9202 }
9203 -
9204 +
9205 // spin_unlock_irqrestore(&ieee->lock, flags);
9206 up(&ieee->scan_sem);
9207 }
9208  
9209 -void ieee80211_stop_scan(struct ieee80211_device *ieee)
9210 +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee)
9211 {
9212 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
9213 - ieee80211_softmac_stop_scan(ieee);
9214 + ieee80211_softmac_stop_scan_rtl7(ieee);
9215 else
9216 ieee->stop_scan(ieee->dev);
9217 }
9218  
9219 /* called with ieee->lock held */
9220 -void ieee80211_start_scan(struct ieee80211_device *ieee)
9221 +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee)
9222 {
9223 - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
9224 + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
9225 if (ieee->scanning == 0){
9226 ieee->scanning = 1;
9227 //ieee80211_softmac_scan(ieee);
9228 - queue_work(ieee->wq, &ieee->softmac_scan_wq);
9229 + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
9230 }
9231 }else
9232 ieee->start_scan(ieee->dev);
9233 -
9234 +
9235 }
9236  
9237 /* called with wx_sem held */
9238 -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
9239 +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee)
9240 {
9241 ieee->sync_scan_hurryup = 0;
9242 -
9243 +
9244 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
9245 - ieee80211_softmac_scan_syncro(ieee);
9246 + ieee80211_softmac_scan_syncro_rtl7(ieee);
9247 else
9248 ieee->scan_syncro(ieee->dev);
9249 -
9250 +
9251 }
9252  
9253 -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
9254 +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon,
9255 struct ieee80211_device *ieee, int challengelen)
9256 {
9257 - struct sk_buff *skb;
9258 + struct sk_buff *skb;
9259 struct ieee80211_authentication *auth;
9260 -
9261 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
9262 -
9263 +
9264 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
9265 +
9266 if (!skb) return NULL;
9267 -
9268 +
9269 auth = (struct ieee80211_authentication *)
9270 skb_put(skb, sizeof(struct ieee80211_authentication));
9271 -
9272 +
9273 auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
9274 if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
9275 -
9276 +
9277 auth->header.duration_id = 0x013a; //FIXME
9278 -
9279 +
9280 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
9281 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9282 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
9283 -
9284 +
9285 auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
9286 -
9287 +
9288 auth->transaction = cpu_to_le16(ieee->associate_seq);
9289 ieee->associate_seq++;
9290 -
9291 +
9292 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
9293 -
9294 +
9295 return skb;
9296 -
9297 +
9298 }
9299  
9300 -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
9301 +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
9302 {
9303 u8 *tag;
9304 int beacon_size;
9305 @@ -566,23 +572,23 @@
9306 int encrypt;
9307 int atim_len,erp_len;
9308 struct ieee80211_crypt_data* crypt;
9309 -
9310 +
9311 char *ssid = ieee->current_network.ssid;
9312 int ssid_len = ieee->current_network.ssid_len;
9313 int rate_len = ieee->current_network.rates_len+2;
9314 int rate_ex_len = ieee->current_network.rates_ex_len;
9315 if(rate_ex_len > 0) rate_ex_len+=2;
9316 -
9317 +
9318 if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
9319 atim_len = 4;
9320 else
9321 atim_len = 0;
9322 -
9323 - if(ieee80211_is_54g(ieee->current_network))
9324 +
9325 + if(ieee80211_is_54g_rtl7(ieee->current_network))
9326 erp_len = 3;
9327 else
9328 erp_len = 0;
9329 -
9330 +
9331 beacon_size = sizeof(struct ieee80211_probe_response)+
9332 ssid_len
9333 +3 //channel
9334 @@ -590,72 +596,72 @@
9335 +rate_ex_len
9336 +atim_len
9337 +erp_len;
9338 -
9339 +
9340 skb = dev_alloc_skb(beacon_size);
9341 -
9342 - if (!skb)
9343 +
9344 + if (!skb)
9345 return NULL;
9346 -
9347 +
9348 beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size);
9349 -
9350 +
9351 memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
9352 memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9353 memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
9354  
9355 beacon_buf->header.duration_id = 0; //FIXME
9356 - beacon_buf->beacon_interval =
9357 + beacon_buf->beacon_interval =
9358 cpu_to_le16(ieee->current_network.beacon_interval);
9359 - beacon_buf->capability =
9360 + beacon_buf->capability =
9361 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
9362 -
9363 +
9364 if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
9365 - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
9366 -
9367 + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
9368 +
9369 crypt = ieee->crypt[ieee->tx_keyidx];
9370  
9371 - encrypt = ieee->host_encrypt && crypt && crypt->ops &&
9372 + encrypt = ieee->host_encrypt && crypt && crypt->ops &&
9373 (0 == strcmp(crypt->ops->name, "WEP"));
9374  
9375 - if (encrypt)
9376 + if (encrypt)
9377 beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9378 -
9379 -
9380 +
9381 +
9382 beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
9383 -
9384 - beacon_buf->info_element.id = MFIE_TYPE_SSID;
9385 +
9386 + beacon_buf->info_element.id = MFIE_TYPE_SSID;
9387 beacon_buf->info_element.len = ssid_len;
9388 -
9389 +
9390 tag = (u8*) beacon_buf->info_element.data;
9391 -
9392 +
9393 memcpy(tag, ssid, ssid_len);
9394 -
9395 +
9396 tag += ssid_len;
9397 -
9398 +
9399 *(tag++) = MFIE_TYPE_RATES;
9400 - *(tag++) = rate_len-2;
9401 + *(tag++) = rate_len-2;
9402 memcpy(tag,ieee->current_network.rates,rate_len-2);
9403 tag+=rate_len-2;
9404 -
9405 +
9406 *(tag++) = MFIE_TYPE_DS_SET;
9407 *(tag++) = 1;
9408 *(tag++) = ieee->current_network.channel;
9409 -
9410 +
9411 if(atim_len){
9412 *(tag++) = MFIE_TYPE_IBSS_SET;
9413 *(tag++) = 2;
9414 *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
9415 tag+=2;
9416 }
9417 -
9418 +
9419 if(erp_len){
9420 *(tag++) = MFIE_TYPE_ERP;
9421 *(tag++) = 1;
9422 - *(tag++) = 0;
9423 + *(tag++) = 0;
9424 }
9425 -
9426 +
9427 if(rate_ex_len){
9428 *(tag++) = MFIE_TYPE_RATES_EX;
9429 - *(tag++) = rate_ex_len-2;
9430 + *(tag++) = rate_ex_len-2;
9431 memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
9432 tag+=rate_ex_len-2;
9433 }
9434 @@ -664,208 +670,211 @@
9435 }
9436  
9437  
9438 -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
9439 +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
9440 {
9441 struct sk_buff *skb;
9442 u8* tag;
9443 -
9444 +
9445 struct ieee80211_crypt_data* crypt;
9446 struct ieee80211_assoc_response_frame *assoc;
9447 short encrypt;
9448 -
9449 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
9450 +
9451 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
9452 int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len;
9453 -
9454 - skb = dev_alloc_skb(len);
9455 -
9456 - if (!skb)
9457 +
9458 + skb = dev_alloc_skb(len);
9459 +
9460 + if (!skb)
9461 return NULL;
9462 -
9463 +
9464 assoc = (struct ieee80211_assoc_response_frame *)
9465 skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
9466 -
9467 +
9468 assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
9469 memcpy(assoc->header.addr1, dest,ETH_ALEN);
9470 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
9471 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9472 - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
9473 + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
9474 WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
9475 -
9476 -
9477 +
9478 +
9479 if(ieee->short_slot)
9480 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
9481 -
9482 +
9483 if (ieee->host_encrypt)
9484 crypt = ieee->crypt[ieee->tx_keyidx];
9485 else crypt = NULL;
9486 -
9487 +
9488 encrypt = ( crypt && crypt->ops);
9489 -
9490 +
9491 if (encrypt)
9492 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9493 -
9494 +
9495 assoc->status = 0;
9496 assoc->aid = cpu_to_le16(ieee->assoc_id);
9497 if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
9498 else ieee->assoc_id++;
9499 -
9500 +
9501 tag = (u8*) skb_put(skb, rate_len);
9502 -
9503 - ieee80211_MFIE_Brate(ieee, &tag);
9504 - ieee80211_MFIE_Grate(ieee, &tag);
9505 -
9506 +
9507 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
9508 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
9509 +
9510 return skb;
9511 }
9512  
9513 -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
9514 +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest)
9515 {
9516 struct sk_buff *skb;
9517 struct ieee80211_authentication *auth;
9518 -
9519 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
9520 -
9521 - if (!skb)
9522 +
9523 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
9524 +
9525 + if (!skb)
9526 return NULL;
9527 -
9528 +
9529 skb->len = sizeof(struct ieee80211_authentication);
9530 -
9531 +
9532 auth = (struct ieee80211_authentication *)skb->data;
9533 -
9534 +
9535 auth->status = cpu_to_le16(status);
9536 auth->transaction = cpu_to_le16(2);
9537 auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
9538 -
9539 +
9540 memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
9541 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9542 memcpy(auth->header.addr1, dest, ETH_ALEN);
9543 - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
9544 + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
9545 return skb;
9546 -
9547 -
9548 +
9549 +
9550 }
9551  
9552 -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
9553 +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr)
9554 {
9555 struct sk_buff *skb;
9556 struct ieee80211_hdr_3addr* hdr;
9557 -
9558 - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
9559 -
9560 - if (!skb)
9561 +
9562 + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
9563 +
9564 + if (!skb)
9565 return NULL;
9566 -
9567 +
9568 hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
9569 -
9570 +
9571 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
9572 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
9573 memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
9574 -
9575 - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
9576 - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
9577 - (pwr ? IEEE80211_FCTL_PM:0));
9578 -
9579 +
9580 + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
9581 + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
9582 + (pwr ? IEEE80211_FCTL_PM:0));
9583 +
9584 return skb;
9585 -
9586 -
9587 +
9588 +
9589 }
9590  
9591  
9592 -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
9593 +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest)
9594 {
9595 - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
9596 -
9597 + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest);
9598 +
9599 if (buf)
9600 - softmac_mgmt_xmit(buf, ieee);
9601 + softmac_mgmt_xmit_rtl7(buf, ieee);
9602 }
9603  
9604  
9605 -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
9606 +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest)
9607 {
9608 - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
9609 -
9610 + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest);
9611 +
9612 if (buf)
9613 - softmac_mgmt_xmit(buf, ieee);
9614 + softmac_mgmt_xmit_rtl7(buf, ieee);
9615 }
9616  
9617  
9618 -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
9619 +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest)
9620 {
9621 -
9622 - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
9623 -
9624 - if (buf)
9625 - softmac_mgmt_xmit(buf, ieee);
9626 +
9627 + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest);
9628 +
9629 + if (buf)
9630 + softmac_mgmt_xmit_rtl7(buf, ieee);
9631 }
9632  
9633  
9634 -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
9635 +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
9636 {
9637 struct sk_buff *skb;
9638 -
9639 +
9640 struct ieee80211_assoc_request_frame *hdr;
9641 u8 *tag;
9642 -
9643 +
9644 unsigned int wpa_len = beacon->wpa_ie_len;
9645 -
9646 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
9647 -
9648 -
9649 -
9650 +
9651 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
9652 +
9653 +
9654 +
9655 int len=sizeof(struct ieee80211_assoc_request_frame)+
9656 + beacon->ssid_len//essid tagged val
9657 + rate_len//rates tagged val
9658 + wpa_len;
9659 -
9660 +
9661 skb = dev_alloc_skb(len);
9662 -
9663 - if (!skb)
9664 +
9665 + if (!skb)
9666 return NULL;
9667 -
9668 +
9669 hdr = (struct ieee80211_assoc_request_frame *)
9670 skb_put(skb, sizeof(struct ieee80211_assoc_request_frame));
9671 -
9672 -
9673 +
9674 +
9675 hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ;
9676 hdr->header.duration_id= 37; //FIXME
9677 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
9678 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
9679 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
9680 -
9681 +
9682 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
9683 - if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
9684 + if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
9685 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
9686 -
9687 +
9688 if(ieee->short_slot)
9689 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
9690 -
9691 +
9692 + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
9693 + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
9694 +
9695 hdr->listen_interval = 0xa; //FIXME
9696 -
9697 +
9698 hdr->info_element.id = MFIE_TYPE_SSID;
9699  
9700 hdr->info_element.len = beacon->ssid_len;
9701 tag = skb_put(skb, beacon->ssid_len);
9702 memcpy(tag, beacon->ssid, beacon->ssid_len);
9703 -
9704 - tag = skb_put(skb, rate_len);
9705 -
9706 - ieee80211_MFIE_Brate(ieee, &tag);
9707 - ieee80211_MFIE_Grate(ieee, &tag);
9708 -
9709 +
9710 + tag = skb_put(skb, rate_len);
9711 +
9712 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
9713 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
9714 +
9715 tag = skb_put(skb,wpa_len);
9716 -
9717 +
9718 memcpy(tag,beacon->wpa_ie,wpa_len);
9719 -
9720 +
9721 return skb;
9722 }
9723  
9724 -void ieee80211_associate_abort(struct ieee80211_device *ieee)
9725 +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee)
9726 {
9727 -
9728 +
9729 unsigned long flags;
9730 spin_lock_irqsave(&ieee->lock, flags);
9731 -
9732 +
9733 ieee->associate_seq++;
9734 -
9735 +
9736 /* don't scan, and avoid to have the RX path possibily
9737 * try again to associate. Even do not react to AUTH or
9738 * ASSOC response. Just wait for the retry wq to be scheduled.
9739 @@ -873,166 +882,181 @@
9740 * with, so we retry or just get back to NO_LINK and scanning
9741 */
9742 if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
9743 - IEEE80211_DEBUG_MGMT("Authentication failed\n");
9744 + IEEE80211_DEBUG_MGMT("Authentication failed\n");
9745 ieee->softmac_stats.no_auth_rs++;
9746 }else{
9747 - IEEE80211_DEBUG_MGMT("Association failed\n");
9748 + IEEE80211_DEBUG_MGMT("Association failed\n");
9749 ieee->softmac_stats.no_ass_rs++;
9750 }
9751 -
9752 +
9753 ieee->state = IEEE80211_ASSOCIATING_RETRY;
9754 -
9755 +
9756 queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
9757 -
9758 +
9759 spin_unlock_irqrestore(&ieee->lock, flags);
9760 }
9761  
9762 -void ieee80211_associate_abort_cb(unsigned long dev)
9763 +void ieee80211_associate_abort_cb_rtl7(unsigned long dev)
9764 {
9765 - ieee80211_associate_abort((struct ieee80211_device *) dev);
9766 + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev);
9767 }
9768  
9769  
9770 -void ieee80211_associate_step1(struct ieee80211_device *ieee)
9771 +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee)
9772 {
9773 struct ieee80211_network *beacon = &ieee->current_network;
9774 struct sk_buff *skb;
9775 -
9776 +
9777 IEEE80211_DEBUG_MGMT("Stopping scan\n");
9778 -
9779 +
9780 ieee->softmac_stats.tx_auth_rq++;
9781 - skb=ieee80211_authentication_req(beacon, ieee, 0);
9782 -
9783 - if (!skb)
9784 - ieee80211_associate_abort(ieee);
9785 - else{
9786 + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0);
9787 +
9788 + if (!skb)
9789 + ieee80211_associate_abort_rtl7(ieee);
9790 + else{
9791 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
9792 IEEE80211_DEBUG_MGMT("Sending authentication request\n");
9793 - softmac_mgmt_xmit(skb, ieee);
9794 + softmac_mgmt_xmit_rtl7(skb, ieee);
9795 ieee->associate_timer.expires = jiffies + (HZ / 2);
9796 add_timer(&ieee->associate_timer);
9797 - }
9798 + }
9799 }
9800  
9801 -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
9802 +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen)
9803 {
9804 - u8 *c;
9805 + u8 *c;
9806 struct sk_buff *skb;
9807 struct ieee80211_network *beacon = &ieee->current_network;
9808 // int hlen = sizeof(struct ieee80211_authentication);
9809 -
9810 +
9811 ieee->associate_seq++;
9812 ieee->softmac_stats.tx_auth_rq++;
9813 -
9814 - skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
9815 - if (!skb)
9816 - ieee80211_associate_abort(ieee);
9817 +
9818 + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2);
9819 + if (!skb)
9820 + ieee80211_associate_abort_rtl7(ieee);
9821 else{
9822 c = skb_put(skb, chlen+2);
9823 *(c++) = MFIE_TYPE_CHALLENGE;
9824 *(c++) = chlen;
9825 memcpy(c, challenge, chlen);
9826 -
9827 +
9828 IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
9829 -
9830 - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
9831 -
9832 - softmac_mgmt_xmit(skb, ieee);
9833 +
9834 + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
9835 +
9836 + softmac_mgmt_xmit_rtl7(skb, ieee);
9837 ieee->associate_timer.expires = jiffies + (HZ / 2);
9838 add_timer(&ieee->associate_timer);
9839 - }
9840 + }
9841 kfree(challenge);
9842 }
9843  
9844 -void ieee80211_associate_step2(struct ieee80211_device *ieee)
9845 +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee)
9846 {
9847 struct sk_buff* skb;
9848 struct ieee80211_network *beacon = &ieee->current_network;
9849 -
9850 +
9851 del_timer_sync(&ieee->associate_timer);
9852 -
9853 +
9854 IEEE80211_DEBUG_MGMT("Sending association request\n");
9855 -
9856 +
9857 ieee->softmac_stats.tx_ass_rq++;
9858 - skb=ieee80211_association_req(beacon, ieee);
9859 - if (!skb)
9860 - ieee80211_associate_abort(ieee);
9861 + skb=ieee80211_association_req_rtl7(beacon, ieee);
9862 + if (!skb)
9863 + ieee80211_associate_abort_rtl7(ieee);
9864 else{
9865 - softmac_mgmt_xmit(skb, ieee);
9866 + softmac_mgmt_xmit_rtl7(skb, ieee);
9867 ieee->associate_timer.expires = jiffies + (HZ / 2);
9868 add_timer(&ieee->associate_timer);
9869 - }
9870 + }
9871 }
9872  
9873 -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
9874 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9875 +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work)
9876 +{
9877 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
9878 +#else
9879 +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee)
9880 {
9881 +#endif
9882 printk(KERN_INFO "Associated successfully\n");
9883 - if(ieee80211_is_54g(ieee->current_network) &&
9884 +#if 0
9885 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
9886 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
9887 -
9888 +
9889 ieee->rate = 540;
9890 printk(KERN_INFO"Using G rates\n");
9891 }else{
9892 ieee->rate = 110;
9893 printk(KERN_INFO"Using B rates\n");
9894 }
9895 +#else
9896 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
9897 +#endif
9898 ieee->link_change(ieee->dev);
9899 - notify_wx_assoc_event(ieee);
9900 + notify_wx_assoc_event_rtl7(ieee);
9901 if (ieee->data_hard_resume)
9902 ieee->data_hard_resume(ieee->dev);
9903 netif_carrier_on(ieee->dev);
9904 }
9905  
9906 -void ieee80211_associate_complete(struct ieee80211_device *ieee)
9907 +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee)
9908 {
9909  
9910 del_timer_sync(&ieee->associate_timer);
9911 -
9912 +
9913 ieee->seq_ctrl = 0;
9914 ieee->state = IEEE80211_LINKED;
9915 IEEE80211_DEBUG_MGMT("Successfully associated\n");
9916 -
9917 +
9918 queue_work(ieee->wq, &ieee->associate_complete_wq);
9919 }
9920  
9921 -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
9922 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
9923 +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work)
9924 {
9925 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
9926 +#else
9927 +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee)
9928 +{
9929 +#endif
9930 ieee->sync_scan_hurryup = 1;
9931 down(&ieee->wx_sem);
9932 -
9933 if (ieee->data_hard_stop)
9934 ieee->data_hard_stop(ieee->dev);
9935 -
9936 - ieee80211_stop_scan(ieee);
9937 +
9938 + ieee80211_stop_scan_rtl7(ieee);
9939 ieee->set_chan(ieee->dev, ieee->current_network.channel);
9940 -
9941 +
9942 ieee->associate_seq = 1;
9943 - ieee80211_associate_step1(ieee);
9944 -
9945 + ieee80211_associate_step1_rtl7(ieee);
9946 +
9947 up(&ieee->wx_sem);
9948 }
9949  
9950 -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
9951 +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net)
9952 {
9953 -
9954 +
9955 u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
9956 int tmp_ssid_len = 0;
9957 -
9958 +
9959 short apset,ssidset,ssidbroad,apmatch,ssidmatch;
9960 -
9961 - /* we are interested in new new only if we are not associated
9962 +
9963 + /* we are interested in new new only if we are not associated
9964 * and we are not associating / authenticating
9965 */
9966 if (ieee->state != IEEE80211_NOLINK)
9967 - return;
9968 -
9969 + return;
9970 +
9971 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
9972 return;
9973 -
9974 +
9975 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
9976 return;
9977  
9978 -
9979 +
9980 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
9981 /* if the user specified the AP MAC, we need also the essid
9982 * This could be obtained by beacons or, if the network does not
9983 @@ -1043,23 +1067,23 @@
9984 ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
9985 apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
9986 ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
9987 -
9988 -
9989 -
9990 +
9991 +
9992 +
9993 if ( /* if the user set the AP check if match.
9994 * if the network does not broadcast essid we check the user supplyed ANY essid
9995 * if the network does broadcast and the user does not set essid it is OK
9996 * if the network does broadcast and the user did set essid chech if essid match
9997 */
9998 - ( apset && apmatch &&
9999 - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
10000 + ( apset && apmatch &&
10001 + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
10002 /* if the ap is not set, check that the user set the bssid
10003 * and the network does bradcast and that those two bssid matches
10004 - */
10005 - (!apset && ssidset && ssidbroad && ssidmatch)
10006 + */
10007 + (!apset && ssidset && ssidbroad && ssidmatch)
10008 ){
10009 -
10010 -
10011 +
10012 +
10013 /* if the essid is hidden replace it with the
10014 * essid provided by the user.
10015 */
10016 @@ -1068,18 +1092,19 @@
10017 tmp_ssid_len = ieee->current_network.ssid_len;
10018 }
10019 memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
10020 -
10021 +
10022 if (!ssidbroad){
10023 strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
10024 ieee->current_network.ssid_len = tmp_ssid_len;
10025 }
10026 - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid);
10027 -
10028 + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10));
10029 +
10030 if (ieee->iw_mode == IW_MODE_INFRA){
10031 ieee->state = IEEE80211_ASSOCIATING;
10032 queue_work(ieee->wq, &ieee->associate_procedure_wq);
10033 }else{
10034 - if(ieee80211_is_54g(ieee->current_network) &&
10035 +#if 0
10036 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
10037 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
10038 ieee->rate = 540;
10039 printk(KERN_INFO"Using G rates\n");
10040 @@ -1087,44 +1112,45 @@
10041 ieee->rate = 110;
10042 printk(KERN_INFO"Using B rates\n");
10043 }
10044 +#else
10045 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
10046 +#endif
10047 ieee->state = IEEE80211_LINKED;
10048 }
10049 -
10050 +
10051 }
10052 }
10053 -
10054 }
10055  
10056 -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
10057 +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee)
10058 {
10059 -
10060 +
10061 unsigned long flags;
10062 struct ieee80211_network *target;
10063 -
10064 +
10065 spin_lock_irqsave(&ieee->lock, flags);
10066 -
10067 list_for_each_entry(target, &ieee->network_list, list) {
10068 -
10069 +
10070 /* if the state become different that NOLINK means
10071 * we had found what we are searching for
10072 */
10073 - if (ieee->state != IEEE80211_NOLINK)
10074 + if (ieee->state != IEEE80211_NOLINK)
10075 break;
10076 -
10077 +
10078 //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
10079 - ieee80211_softmac_new_net(ieee, target);
10080 + ieee80211_softmac_new_net_rtl7(ieee, target);
10081 }
10082 -
10083 +
10084 spin_unlock_irqrestore(&ieee->lock, flags);
10085 -
10086 +
10087 }
10088  
10089  
10090 -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
10091 +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen)
10092 {
10093 struct ieee80211_authentication *a;
10094 u8 *t;
10095 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10096 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10097 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
10098 return 0xcafe;
10099 }
10100 @@ -1132,58 +1158,58 @@
10101 a = (struct ieee80211_authentication*) skb->data;
10102 if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
10103 t = skb->data + sizeof(struct ieee80211_authentication);
10104 -
10105 +
10106 if(*(t++) == MFIE_TYPE_CHALLENGE){
10107 *chlen = *(t++);
10108 *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
10109 memcpy(*challenge, t, *chlen);
10110 }
10111 }
10112 -
10113 +
10114 return cpu_to_le16(a->status);
10115 -
10116 +
10117 }
10118  
10119  
10120 -int auth_rq_parse(struct sk_buff *skb,u8* dest)
10121 +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
10122 {
10123 struct ieee80211_authentication *a;
10124 -
10125 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10126 - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
10127 +
10128 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
10129 + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
10130 return -1;
10131 }
10132 a = (struct ieee80211_authentication*) skb->data;
10133 -
10134 +
10135 memcpy(dest,a->header.addr2, ETH_ALEN);
10136 -
10137 - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
10138 +
10139 + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
10140 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
10141 -
10142 +
10143 return WLAN_STATUS_SUCCESS;
10144 }
10145  
10146 -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
10147 +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
10148 {
10149 u8 *tag;
10150 u8 *skbend;
10151 u8 *ssid=NULL;
10152 u8 ssidlen = 0;
10153 -
10154 +
10155 struct ieee80211_hdr_3addr *header =
10156 (struct ieee80211_hdr_3addr *) skb->data;
10157 -
10158 - if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
10159 +
10160 + if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
10161 return -1; /* corrupted */
10162 -
10163 +
10164 memcpy(src,header->addr2, ETH_ALEN);
10165 -
10166 +
10167 skbend = (u8*)skb->data + skb->len;
10168 -
10169 +
10170 tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
10171 -
10172 +
10173 while (tag+1 < skbend){
10174 - if (*tag == 0){
10175 + if (*tag == 0){
10176 ssid = tag+2;
10177 ssidlen = *(tag+1);
10178 break;
10179 @@ -1192,88 +1218,88 @@
10180 tag = tag + *(tag); /* point to the last data byte of the tag */
10181 tag++; /* point to the next tag */
10182 }
10183 -
10184 +
10185 //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
10186 if (ssidlen == 0) return 1;
10187 -
10188 +
10189 if (!ssid) return 1; /* ssid not found in tagged param */
10190 return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
10191 -
10192 +
10193 }
10194  
10195 -int assoc_rq_parse(struct sk_buff *skb,u8* dest)
10196 +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
10197 {
10198 struct ieee80211_assoc_request_frame *a;
10199 -
10200 - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
10201 - sizeof(struct ieee80211_info_element))) {
10202 -
10203 +
10204 + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
10205 + sizeof(struct ieee80211_info_element))) {
10206 +
10207 IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
10208 return -1;
10209 }
10210 -
10211 +
10212 a = (struct ieee80211_assoc_request_frame*) skb->data;
10213 -
10214 +
10215 memcpy(dest,a->header.addr2,ETH_ALEN);
10216 -
10217 +
10218 return 0;
10219 }
10220  
10221 -static inline u16 assoc_parse(struct sk_buff *skb, int *aid)
10222 +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid)
10223 {
10224 struct ieee80211_assoc_response_frame *a;
10225 - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
10226 + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
10227 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
10228 return 0xcafe;
10229 }
10230 -
10231 +
10232 a = (struct ieee80211_assoc_response_frame*) skb->data;
10233 *aid = le16_to_cpu(a->aid) & 0x3fff;
10234 return le16_to_cpu(a->status);
10235 }
10236  
10237 static inline void
10238 -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10239 +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10240 {
10241 u8 dest[ETH_ALEN];
10242 -
10243 +
10244 //IEEE80211DMESG("Rx probe");
10245 ieee->softmac_stats.rx_probe_rq++;
10246 //DMESG("Dest is "MACSTR, MAC2STR(dest));
10247 - if (probe_rq_parse(ieee, skb, dest)){
10248 + if (probe_rq_parse_rtl7(ieee, skb, dest)){
10249 //IEEE80211DMESG("Was for me!");
10250 ieee->softmac_stats.tx_probe_rs++;
10251 - ieee80211_resp_to_probe(ieee, dest);
10252 + ieee80211_resp_to_probe_rtl7(ieee, dest);
10253 }
10254 }
10255  
10256 static inline void
10257 -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10258 +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10259 {
10260 u8 dest[ETH_ALEN];
10261 int status;
10262 //IEEE80211DMESG("Rx probe");
10263 ieee->softmac_stats.rx_auth_rq++;
10264 -
10265 - if ((status = auth_rq_parse(skb, dest))!= -1){
10266 - ieee80211_resp_to_auth(ieee, status, dest);
10267 +
10268 + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){
10269 + ieee80211_resp_to_auth_rtl7(ieee, status, dest);
10270 }
10271 //DMESG("Dest is "MACSTR, MAC2STR(dest));
10272 -
10273 +
10274 }
10275  
10276 static inline void
10277 -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
10278 +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
10279 {
10280 -
10281 +
10282 u8 dest[ETH_ALEN];
10283 //unsigned long flags;
10284 -
10285 +
10286 ieee->softmac_stats.rx_ass_rq++;
10287 - if (assoc_rq_parse(skb,dest) != -1){
10288 - ieee80211_resp_to_assoc_rq(ieee, dest);
10289 + if (assoc_rq_parse_rtl7(skb,dest) != -1){
10290 + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest);
10291 }
10292 -
10293 +
10294 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
10295 //FIXME
10296 #if 0
10297 @@ -1285,25 +1311,25 @@
10298  
10299  
10300  
10301 -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
10302 +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr)
10303 {
10304 -
10305 - struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
10306 -
10307 +
10308 + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr);
10309 +
10310 if (buf)
10311 - softmac_ps_mgmt_xmit(buf, ieee);
10312 + softmac_ps_mgmt_xmit_rtl7(buf, ieee);
10313  
10314 -}
10315 +}
10316  
10317  
10318 -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
10319 -{
10320 +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
10321 +{
10322 int timeout = ieee->ps_timeout;
10323 u8 dtim;
10324 /*if(ieee->ps == IEEE80211_PS_DISABLED ||
10325 - ieee->iw_mode != IW_MODE_INFRA ||
10326 + ieee->iw_mode != IW_MODE_INFRA ||
10327 ieee->state != IEEE80211_LINKED)
10328 -
10329 +
10330 return 0;
10331 */
10332 dtim = ieee->current_network.dtim_data;
10333 @@ -1312,133 +1338,133 @@
10334 return 0;
10335 //printk("VALID\n");
10336 ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
10337 -
10338 +
10339 if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
10340 return 2;
10341 -
10342 +
10343 if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
10344 return 0;
10345 -
10346 +
10347 if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
10348 return 0;
10349 -
10350 +
10351 if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
10352 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
10353 return 0;
10354 -
10355 +
10356 if(time_l){
10357 - *time_l = ieee->current_network.last_dtim_sta_time[0]
10358 - + (ieee->current_network.beacon_interval
10359 + *time_l = ieee->current_network.last_dtim_sta_time[0]
10360 + + (ieee->current_network.beacon_interval
10361 * ieee->current_network.dtim_period) * 1000;
10362 }
10363 -
10364 +
10365 if(time_h){
10366 *time_h = ieee->current_network.last_dtim_sta_time[1];
10367 if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
10368 *time_h += 1;
10369 }
10370 -
10371 +
10372 return 1;
10373 -
10374 -
10375 +
10376 +
10377 }
10378  
10379 -inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
10380 +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee)
10381 {
10382  
10383 u32 th,tl;
10384 short sleep;
10385 -
10386 +
10387 unsigned long flags,flags2;
10388 -
10389 +
10390 spin_lock_irqsave(&ieee->lock, flags);
10391 -
10392 +
10393 if((ieee->ps == IEEE80211_PS_DISABLED ||
10394 - ieee->iw_mode != IW_MODE_INFRA ||
10395 + ieee->iw_mode != IW_MODE_INFRA ||
10396 ieee->state != IEEE80211_LINKED)){
10397 -
10398 - #warning CHECK_LOCK_HERE
10399 +
10400 +// #warning CHECK_LOCK_HERE
10401 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10402 -
10403 - ieee80211_sta_wakeup(ieee, 1);
10404 -
10405 +
10406 + ieee80211_sta_wakeup_rtl7(ieee, 1);
10407 + printk(KERN_WARNING "wakeup 1!\n" );
10408 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10409 }
10410 -
10411 - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
10412 +
10413 + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl);
10414 /* 2 wake, 1 sleep, 0 do nothing */
10415 if(sleep == 0)
10416 goto out;
10417 -
10418 +
10419 if(sleep == 1){
10420 -
10421 +
10422 if(ieee->sta_sleep == 1)
10423 ieee->enter_sleep_state(ieee->dev,th,tl);
10424 -
10425 +
10426 else if(ieee->sta_sleep == 0){
10427 // printk("send null 1\n");
10428 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10429 -
10430 +
10431 if(ieee->ps_is_queue_empty(ieee->dev)){
10432 -
10433 -
10434 +
10435 +
10436 ieee->sta_sleep = 2;
10437 -
10438 +
10439 ieee->ps_request_tx_ack(ieee->dev);
10440 -
10441 - ieee80211_sta_ps_send_null_frame(ieee,1);
10442 -
10443 +
10444 + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1);
10445 +
10446 ieee->ps_th = th;
10447 ieee->ps_tl = tl;
10448 - }
10449 + }
10450 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10451 -
10452 +
10453 }
10454 -
10455 -
10456 +
10457 +
10458 }else if(sleep == 2){
10459 -#warning CHECK_LOCK_HERE
10460 +// #warning CHECK_LOCK_HERE
10461 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10462 -
10463 - ieee80211_sta_wakeup(ieee,1);
10464 -
10465 +
10466 + ieee80211_sta_wakeup_rtl7(ieee,1);
10467 + printk(KERN_WARNING "wakeup 2!\n" );
10468 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10469 }
10470  
10471 -out:
10472 +out:
10473 spin_unlock_irqrestore(&ieee->lock, flags);
10474 -
10475 +
10476 }
10477  
10478 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
10479 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl)
10480 {
10481 if(ieee->sta_sleep == 0){
10482 if(nl){
10483 printk("Warning: driver is probably failing to report TX ps error\n");
10484 ieee->ps_request_tx_ack(ieee->dev);
10485 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10486 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10487 }
10488 return;
10489 -
10490 +
10491 }
10492 -
10493 - if(ieee->sta_sleep == 1)
10494 +
10495 + if(ieee->sta_sleep == 1)
10496 ieee->sta_wake_up(ieee->dev);
10497 -
10498 +
10499 ieee->sta_sleep = 0;
10500 -
10501 +
10502 if(nl){
10503 ieee->ps_request_tx_ack(ieee->dev);
10504 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10505 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10506 }
10507 }
10508  
10509 -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
10510 +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success)
10511 {
10512 unsigned long flags,flags2;
10513 -
10514 +
10515 spin_lock_irqsave(&ieee->lock, flags);
10516 -
10517 +
10518 if(ieee->sta_sleep == 2){
10519 /* Null frame with PS bit set */
10520 if(success){
10521 @@ -1451,10 +1477,10 @@
10522 }
10523 /* 21112005 - tx again null without PS bit if lost */
10524 else {
10525 -
10526 +
10527 if((ieee->sta_sleep == 0) && !success){
10528 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
10529 - ieee80211_sta_ps_send_null_frame(ieee, 0);
10530 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
10531 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
10532 }
10533 }
10534 @@ -1462,129 +1488,132 @@
10535 }
10536  
10537 inline int
10538 -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
10539 +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
10540 struct ieee80211_rx_stats *rx_stats, u16 type,
10541 u16 stype)
10542 {
10543 struct ieee80211_hdr_3addr *header;
10544 - header = (struct ieee80211_hdr_3addr *) skb->data;
10545 u16 errcode;
10546 u8* challenge;
10547 int chlen;
10548 int aid;
10549 -
10550 +
10551 + chlen = 0;
10552 +
10553 + header = (struct ieee80211_hdr_3addr *) skb->data;
10554 +
10555 if(!ieee->proto_started)
10556 return 0;
10557 -
10558 +
10559 if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
10560 - ieee->iw_mode == IW_MODE_INFRA &&
10561 + ieee->iw_mode == IW_MODE_INFRA &&
10562 ieee->state == IEEE80211_LINKED))
10563 -
10564 +
10565 tasklet_schedule(&ieee->ps_task);
10566 -
10567 +
10568 if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
10569 WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
10570 ieee->last_rx_ps_time = jiffies;
10571 -
10572 +
10573 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
10574 -
10575 +
10576 case IEEE80211_STYPE_ASSOC_RESP:
10577 case IEEE80211_STYPE_REASSOC_RESP:
10578 -
10579 +
10580 IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
10581 WLAN_FC_GET_STYPE(header->frame_ctl));
10582 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10583 - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
10584 + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
10585 ieee->iw_mode == IW_MODE_INFRA){
10586 - if (0 == (errcode=assoc_parse(skb, &aid))){
10587 -
10588 + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){
10589 +
10590 ieee->state=IEEE80211_LINKED;
10591 ieee->assoc_id = aid;
10592 ieee->softmac_stats.rx_ass_ok++;
10593 -
10594 - ieee80211_associate_complete(ieee);
10595 +
10596 + ieee80211_associate_complete_rtl7(ieee);
10597 }else{
10598 ieee->softmac_stats.rx_ass_err++;
10599 IEEE80211_DEBUG_MGMT(
10600 "Association response status code 0x%x\n",
10601 errcode);
10602 - ieee80211_associate_abort(ieee);
10603 + ieee80211_associate_abort_rtl7(ieee);
10604 }
10605 }
10606 break;
10607 -
10608 +
10609 case IEEE80211_STYPE_ASSOC_REQ:
10610 case IEEE80211_STYPE_REASSOC_REQ:
10611 -
10612 +
10613 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10614 ieee->iw_mode == IW_MODE_MASTER)
10615 -
10616 - ieee80211_rx_assoc_rq(ieee, skb);
10617 +
10618 + ieee80211_rx_assoc_rq_rtl7(ieee, skb);
10619 break;
10620 -
10621 +
10622 case IEEE80211_STYPE_AUTH:
10623 -
10624 +
10625 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
10626 - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
10627 + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
10628 ieee->iw_mode == IW_MODE_INFRA){
10629 -
10630 +
10631 IEEE80211_DEBUG_MGMT("Received authentication response");
10632 -
10633 - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
10634 +
10635 + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){
10636 if(ieee->open_wep || !challenge){
10637 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
10638 ieee->softmac_stats.rx_auth_rs_ok++;
10639 -
10640 - ieee80211_associate_step2(ieee);
10641 +
10642 + ieee80211_associate_step2_rtl7(ieee);
10643 }else{
10644 - ieee80211_auth_challenge(ieee, challenge, chlen);
10645 + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen);
10646 }
10647 }else{
10648 ieee->softmac_stats.rx_auth_rs_err++;
10649 IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
10650 - ieee80211_associate_abort(ieee);
10651 + ieee80211_associate_abort_rtl7(ieee);
10652 }
10653 -
10654 +
10655 }else if (ieee->iw_mode == IW_MODE_MASTER){
10656 - ieee80211_rx_auth_rq(ieee, skb);
10657 + ieee80211_rx_auth_rq_rtl7(ieee, skb);
10658 }
10659 }
10660 break;
10661 -
10662 +
10663 case IEEE80211_STYPE_PROBE_REQ:
10664 -
10665 - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
10666 - ((ieee->iw_mode == IW_MODE_ADHOC ||
10667 +
10668 + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
10669 + ((ieee->iw_mode == IW_MODE_ADHOC ||
10670 ieee->iw_mode == IW_MODE_MASTER) &&
10671 ieee->state == IEEE80211_LINKED))
10672 -
10673 - ieee80211_rx_probe_rq(ieee, skb);
10674 +
10675 + ieee80211_rx_probe_rq_rtl7(ieee, skb);
10676 break;
10677 -
10678 +
10679 case IEEE80211_STYPE_DISASSOC:
10680 case IEEE80211_STYPE_DEAUTH:
10681 - /* FIXME for now repeat all the association procedure
10682 + /* FIXME for now repeat all the association procedure
10683 * both for disassociation and deauthentication
10684 */
10685 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
10686 - ieee->state == IEEE80211_LINKED &&
10687 + ieee->state == IEEE80211_LINKED &&
10688 ieee->iw_mode == IW_MODE_INFRA){
10689 -
10690 +
10691 ieee->state = IEEE80211_ASSOCIATING;
10692 ieee->softmac_stats.reassoc++;
10693 -
10694 - notify_wx_assoc_event(ieee);
10695 -
10696 +
10697 + notify_wx_assoc_event_rtl7(ieee);
10698 +
10699 queue_work(ieee->wq, &ieee->associate_procedure_wq);
10700 }
10701 -
10702 +
10703 break;
10704 -
10705 - default:
10706 +
10707 + default:
10708 return -1;
10709 break;
10710 }
10711 -
10712 +
10713 //dev_kfree_skb_any(skb);
10714 return 0;
10715 }
10716 @@ -1602,21 +1631,21 @@
10717 * This might be useful if each fragment need it's own
10718 * descriptor, thus just keep a total free memory > than
10719 * the max fragmentation treshold is not enought.. If the
10720 - * ieee802.11 stack passed a TXB struct then you needed
10721 - * to keep N free descriptors where
10722 + * ieee802.11 stack passed a TXB struct then you needed
10723 + * to keep N free descriptors where
10724 * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
10725 * In this way you need just one and the 802.11 stack
10726 - * will take care of buffering fragments and pass them to
10727 + * will take care of buffering fragments and pass them to
10728 * to the driver later, when it wakes the queue.
10729 - */
10730 -
10731 -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
10732 + */
10733 +
10734 +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
10735 {
10736 -
10737 -
10738 +
10739 +
10740 unsigned long flags;
10741 int i;
10742 -
10743 +
10744 spin_lock_irqsave(&ieee->lock,flags);
10745 #if 0
10746 if(ieee->queue_stop){
10747 @@ -1627,13 +1656,13 @@
10748 err = 1;
10749 goto exit;
10750 }
10751 -
10752 +
10753 ieee->stats.tx_bytes+=skb->len;
10754 -
10755 -
10756 +
10757 +
10758 txb=ieee80211_skb_to_txb(ieee,skb);
10759 -
10760 -
10761 +
10762 +
10763 if(txb==NULL){
10764 IEEE80211DMESG("WW: IEEE stack failed to provide txb");
10765 //dev_kfree_skb_any(skb);
10766 @@ -1641,12 +1670,12 @@
10767 goto exit;
10768 }
10769 #endif
10770 -
10771 +
10772 /* called with 2nd parm 0, no tx mgmt lock required */
10773 - ieee80211_sta_wakeup(ieee,0);
10774 + ieee80211_sta_wakeup_rtl7(ieee,0);
10775  
10776 for(i = 0; i < txb->nr_frags; i++) {
10777 -
10778 +
10779 if (ieee->queue_stop){
10780 ieee->tx_pending.txb = txb;
10781 ieee->tx_pending.frag = i;
10782 @@ -1658,29 +1687,29 @@
10783 //(i+1)<txb->nr_frags);
10784 ieee->stats.tx_packets++;
10785 ieee->stats.tx_bytes += txb->fragments[i]->len;
10786 - ieee->dev->trans_start = jiffies;
10787 + ieee->dev->trans_start = jiffies;
10788 }
10789 - }
10790 -
10791 - ieee80211_txb_free(txb);
10792 -
10793 + }
10794 +
10795 + ieee80211_txb_free_rtl7(txb);
10796 +
10797 exit:
10798 spin_unlock_irqrestore(&ieee->lock,flags);
10799 -
10800 +
10801 }
10802  
10803 /* called with ieee->lock acquired */
10804 -void ieee80211_resume_tx(struct ieee80211_device *ieee)
10805 +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee)
10806 {
10807 int i;
10808 for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
10809 -
10810 +
10811 if (ieee->queue_stop){
10812 ieee->tx_pending.frag = i;
10813 return;
10814 }else{
10815 -
10816 - ieee->softmac_data_hard_start_xmit(
10817 +
10818 + ieee->softmac_data_hard_start_xmit(
10819 ieee->tx_pending.txb->fragments[i],
10820 ieee->dev,ieee->rate);
10821 //(i+1)<ieee->tx_pending.txb->nr_frags);
10822 @@ -1688,21 +1717,21 @@
10823 ieee->dev->trans_start = jiffies;
10824 }
10825 }
10826 -
10827 -
10828 - ieee80211_txb_free(ieee->tx_pending.txb);
10829 +
10830 +
10831 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
10832 ieee->tx_pending.txb = NULL;
10833 }
10834  
10835  
10836 -void ieee80211_reset_queue(struct ieee80211_device *ieee)
10837 +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee)
10838 {
10839 unsigned long flags;
10840 -
10841 +
10842 spin_lock_irqsave(&ieee->lock,flags);
10843 - init_mgmt_queue(ieee);
10844 + init_mgmt_queue_rtl7(ieee);
10845 if (ieee->tx_pending.txb){
10846 - ieee80211_txb_free(ieee->tx_pending.txb);
10847 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
10848 ieee->tx_pending.txb = NULL;
10849 }
10850 ieee->queue_stop = 0;
10851 @@ -1710,23 +1739,23 @@
10852  
10853 }
10854  
10855 -void ieee80211_wake_queue(struct ieee80211_device *ieee)
10856 +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee)
10857 {
10858  
10859 unsigned long flags;
10860 struct sk_buff *skb;
10861 struct ieee80211_hdr_3addr *header;
10862 -
10863 +
10864 spin_lock_irqsave(&ieee->lock,flags);
10865 if (! ieee->queue_stop) goto exit;
10866 -
10867 +
10868 ieee->queue_stop = 0;
10869 -
10870 +
10871 if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
10872 - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
10873 -
10874 + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){
10875 +
10876 header = (struct ieee80211_hdr_3addr *) skb->data;
10877 -
10878 +
10879 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
10880  
10881 if (ieee->seq_ctrl == 0xFFF)
10882 @@ -1738,19 +1767,19 @@
10883 }
10884 }
10885 if (!ieee->queue_stop && ieee->tx_pending.txb)
10886 - ieee80211_resume_tx(ieee);
10887 -
10888 + ieee80211_resume_tx_rtl7(ieee);
10889 +
10890 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
10891 ieee->softmac_stats.swtxawake++;
10892 netif_wake_queue(ieee->dev);
10893 }
10894 -
10895 +
10896 exit :
10897 spin_unlock_irqrestore(&ieee->lock,flags);
10898 }
10899  
10900  
10901 -void ieee80211_stop_queue(struct ieee80211_device *ieee)
10902 +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee)
10903 {
10904 //unsigned long flags;
10905 //spin_lock_irqsave(&ieee->lock,flags);
10906 @@ -1761,81 +1790,88 @@
10907 }
10908 ieee->queue_stop = 1;
10909 //spin_unlock_irqrestore(&ieee->lock,flags);
10910 -
10911 +
10912 }
10913  
10914  
10915 -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
10916 +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee)
10917 {
10918 -
10919 +
10920 get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
10921 -
10922 +
10923 /* an IBSS cell address must have the two less significant
10924 - * bits of the first byte = 2
10925 + * bits of the first byte = 2
10926 */
10927 ieee->current_network.bssid[0] &= ~0x01;
10928 ieee->current_network.bssid[0] |= 0x02;
10929 }
10930  
10931 /* called in user context only */
10932 -void ieee80211_start_master_bss(struct ieee80211_device *ieee)
10933 +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee)
10934 {
10935 ieee->assoc_id = 1;
10936 -
10937 +
10938 if (ieee->current_network.ssid_len == 0){
10939 - strncpy(ieee->current_network.ssid,
10940 + strncpy(ieee->current_network.ssid,
10941 IEEE80211_DEFAULT_TX_ESSID,
10942 IW_ESSID_MAX_SIZE);
10943 -
10944 +
10945 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
10946 ieee->ssid_set = 1;
10947 }
10948 -
10949 +
10950 memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
10951 -
10952 +
10953 ieee->set_chan(ieee->dev, ieee->current_network.channel);
10954 ieee->state = IEEE80211_LINKED;
10955 ieee->link_change(ieee->dev);
10956 - notify_wx_assoc_event(ieee);
10957 -
10958 + notify_wx_assoc_event_rtl7(ieee);
10959 +
10960 if (ieee->data_hard_resume)
10961 ieee->data_hard_resume(ieee->dev);
10962 -
10963 +
10964 netif_carrier_on(ieee->dev);
10965 }
10966  
10967 -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
10968 +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee)
10969 {
10970 if(ieee->raw_tx){
10971 -
10972 +
10973 if (ieee->data_hard_resume)
10974 ieee->data_hard_resume(ieee->dev);
10975 -
10976 +
10977 netif_carrier_on(ieee->dev);
10978 }
10979 }
10980 -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
10981 +
10982 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
10983 +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work)
10984 +{
10985 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq);
10986 +#else
10987 +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee)
10988 {
10989 -
10990 +#endif
10991 +
10992 /* iwconfig mode ad-hoc will schedule this and return
10993 * on the other hand this will block further iwconfig SET
10994 * operations because of the wx_sem hold.
10995 * Anyway some most set operations set a flag to speed-up
10996 - * (abort) this wq (when syncro scanning) before sleeping
10997 + * (abort) this wq (when syncro scanning) before sleeping
10998 * on the semaphore
10999 */
11000 -
11001 +
11002 down(&ieee->wx_sem);
11003 -
11004 +
11005 if (ieee->current_network.ssid_len == 0){
11006 strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
11007 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
11008 ieee->ssid_set = 1;
11009 - }
11010 -
11011 + }
11012 +
11013 /* check if we have this cell in our network list */
11014 - ieee80211_softmac_check_all_nets(ieee);
11015 -
11016 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11017 +
11018 /* if not then the state is not linked. Maybe the user swithced to
11019 * ad-hoc mode just after being in monitor mode, or just after
11020 * being very few time in managed mode (so the card have had no
11021 @@ -1851,29 +1887,29 @@
11022 * associated.
11023 */
11024 if (ieee->state == IEEE80211_NOLINK)
11025 - ieee80211_start_scan_syncro(ieee);
11026 + ieee80211_start_scan_syncro_rtl7(ieee);
11027  
11028 /* the network definitively is not here.. create a new cell */
11029 if (ieee->state == IEEE80211_NOLINK){
11030 - printk("creating new IBSS cell\n");
11031 + printk("creating new IBSS cell\n");
11032 if(!ieee->wap_set)
11033 - ieee80211_randomize_cell(ieee);
11034 -
11035 + ieee80211_randomize_cell_rtl7(ieee);
11036 +
11037 if(ieee->modulation & IEEE80211_CCK_MODULATION){
11038 -
11039 +
11040 ieee->current_network.rates_len = 4;
11041 -
11042 +
11043 ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
11044 ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
11045 ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
11046 ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
11047 -
11048 +
11049 }else
11050 ieee->current_network.rates_len = 0;
11051 -
11052 +
11053 if(ieee->modulation & IEEE80211_OFDM_MODULATION){
11054 ieee->current_network.rates_ex_len = 8;
11055 -
11056 +
11057 ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
11058 ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
11059 ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
11060 @@ -1882,44 +1918,44 @@
11061 ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
11062 ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
11063 ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
11064 -
11065 - ieee->rate = 540;
11066 +
11067 +// ieee->rate = 540;
11068 }else{
11069 ieee->current_network.rates_ex_len = 0;
11070 - ieee->rate = 110;
11071 +// ieee->rate = 110;
11072 }
11073 -
11074 +
11075 ieee->current_network.atim_window = 0;
11076 ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
11077 if(ieee->short_slot)
11078 ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
11079 -
11080 +
11081 }
11082 -
11083 +
11084 ieee->state = IEEE80211_LINKED;
11085 -
11086 +
11087 ieee->set_chan(ieee->dev, ieee->current_network.channel);
11088 ieee->link_change(ieee->dev);
11089 -
11090 - notify_wx_assoc_event(ieee);
11091 -
11092 - ieee80211_start_send_beacons(ieee);
11093 -
11094 +
11095 + notify_wx_assoc_event_rtl7(ieee);
11096 +
11097 + ieee80211_start_send_beacons_rtl7(ieee);
11098 +
11099 if (ieee->data_hard_resume)
11100 ieee->data_hard_resume(ieee->dev);
11101 -
11102 +
11103 netif_carrier_on(ieee->dev);
11104 -
11105 +
11106 up(&ieee->wx_sem);
11107 }
11108  
11109 -inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
11110 +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee)
11111 {
11112 queue_work(ieee->wq, &ieee->start_ibss_wq);
11113 }
11114  
11115 /* this is called only in user context, with wx_sem held */
11116 -void ieee80211_start_bss(struct ieee80211_device *ieee)
11117 +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee)
11118 {
11119 unsigned long flags;
11120 /* check if we have already found the net we
11121 @@ -1927,8 +1963,8 @@
11122 * if not (we are disassociated and we are not
11123 * in associating / authenticating phase) start the background scanning.
11124 */
11125 - ieee80211_softmac_check_all_nets(ieee);
11126 -
11127 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11128 +
11129 /* ensure no-one start an associating process (thus setting
11130 * the ieee->state to ieee80211_ASSOCIATING) while we
11131 * have just cheked it and we are going to enable scan.
11132 @@ -1937,41 +1973,49 @@
11133 * the rx path), so we cannot be in the middle of such function
11134 */
11135 spin_lock_irqsave(&ieee->lock, flags);
11136 -
11137 if (ieee->state == IEEE80211_NOLINK)
11138 - ieee80211_start_scan(ieee);
11139 -
11140 + ieee80211_start_scan_rtl7(ieee);
11141 +
11142 spin_unlock_irqrestore(&ieee->lock, flags);
11143 }
11144  
11145 /* called only in userspace context */
11146 -void ieee80211_disassociate(struct ieee80211_device *ieee)
11147 +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee)
11148 {
11149 netif_carrier_off(ieee->dev);
11150 -
11151 +
11152 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
11153 - ieee80211_reset_queue(ieee);
11154 -
11155 + ieee80211_reset_queue_rtl7(ieee);
11156 +
11157 if (ieee->data_hard_stop)
11158 ieee->data_hard_stop(ieee->dev);
11159 -
11160 +
11161 ieee->state = IEEE80211_NOLINK;
11162 ieee->link_change(ieee->dev);
11163 - notify_wx_assoc_event(ieee);
11164 -
11165 + notify_wx_assoc_event_rtl7(ieee);
11166 +
11167 }
11168 -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
11169 +
11170 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
11171 +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work)
11172 +{
11173 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
11174 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
11175 +#else
11176 +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee)
11177 {
11178 +#endif
11179 unsigned long flags;
11180 -
11181 +
11182 down(&ieee->wx_sem);
11183 +
11184 if(!ieee->proto_started)
11185 goto exit;
11186 -
11187 +
11188 if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
11189 goto exit;
11190 -
11191 - /* until we do not set the state to IEEE80211_NOLINK
11192 +
11193 + /* until we do not set the state to IEEE80211_NOLINK
11194 * there are no possibility to have someone else trying
11195 * to start an association procdure (we get here with
11196 * ieee->state = IEEE80211_ASSOCIATING).
11197 @@ -1981,122 +2025,120 @@
11198 * RX path works with ieee->lock held so there are no
11199 * problems. If we are still disassociated then start a scan.
11200 * the lock here is necessary to ensure no one try to start
11201 - * an association procedure when we have just checked the
11202 + * an association procedure when we have just checked the
11203 * state and we are going to start the scan.
11204 */
11205 ieee->state = IEEE80211_NOLINK;
11206  
11207 - ieee80211_softmac_check_all_nets(ieee);
11208 -
11209 + ieee80211_softmac_check_all_nets_rtl7(ieee);
11210 +
11211 spin_lock_irqsave(&ieee->lock, flags);
11212 -
11213 +
11214 if(ieee->state == IEEE80211_NOLINK)
11215 - ieee80211_start_scan(ieee);
11216 -
11217 + ieee80211_start_scan_rtl7(ieee);
11218 +
11219 spin_unlock_irqrestore(&ieee->lock, flags);
11220  
11221 exit:
11222 up(&ieee->wx_sem);
11223 }
11224  
11225 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
11226 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee)
11227 {
11228 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
11229 -
11230 +
11231 struct sk_buff *skb;
11232 struct ieee80211_probe_response *b;
11233 -
11234 - skb = ieee80211_probe_resp(ieee, broadcast_addr);
11235 -
11236 - if (!skb)
11237 +
11238 + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr);
11239 +
11240 + if (!skb)
11241 return NULL;
11242 -
11243 +
11244 b = (struct ieee80211_probe_response *) skb->data;
11245 b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON);
11246 -
11247 +
11248 return skb;
11249 -
11250 +
11251 }
11252  
11253 -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
11254 +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee)
11255 {
11256 struct sk_buff *skb;
11257 struct ieee80211_probe_response *b;
11258 -
11259 - skb = ieee80211_get_beacon_(ieee);
11260 - if(!skb)
11261 +
11262 + skb = ieee80211_get_beacon__rtl7(ieee);
11263 + if(!skb)
11264 return NULL;
11265 -
11266 - b = (struct ieee80211_probe_response *) skb->data;
11267 +
11268 + b = (struct ieee80211_probe_response *) skb->data;
11269 b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4);
11270 -
11271 +
11272 if (ieee->seq_ctrl == 0xFFF)
11273 ieee->seq_ctrl = 0;
11274 else
11275 ieee->seq_ctrl++;
11276 -
11277 +
11278 return skb;
11279 }
11280  
11281 -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
11282 +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee)
11283 {
11284 ieee->sync_scan_hurryup = 1;
11285 down(&ieee->wx_sem);
11286 - ieee80211_stop_protocol(ieee);
11287 +
11288 + ieee80211_stop_protocol_rtl7(ieee);
11289 up(&ieee->wx_sem);
11290 }
11291  
11292  
11293 -void ieee80211_stop_protocol(struct ieee80211_device *ieee)
11294 +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee)
11295 {
11296 if (!ieee->proto_started)
11297 return;
11298 -
11299 +
11300 ieee->proto_started = 0;
11301 -
11302 - ieee80211_stop_send_beacons(ieee);
11303 -
11304 +
11305 + ieee80211_stop_send_beacons_rtl7(ieee);
11306 +
11307 del_timer_sync(&ieee->associate_timer);
11308 - cancel_delayed_work(&ieee->associate_retry_wq);
11309 -
11310 - ieee80211_stop_scan(ieee);
11311 + cancel_delayed_work(&ieee->associate_retry_wq);
11312 +
11313 + ieee80211_stop_scan_rtl7(ieee);
11314  
11315 - ieee80211_disassociate(ieee);
11316 + ieee80211_disassociate_rtl7(ieee);
11317 }
11318  
11319 -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
11320 +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee)
11321 {
11322 ieee->sync_scan_hurryup = 0;
11323 down(&ieee->wx_sem);
11324 - ieee80211_start_protocol(ieee);
11325 + ieee80211_start_protocol_rtl7(ieee);
11326 up(&ieee->wx_sem);
11327 }
11328  
11329 -void ieee80211_start_protocol(struct ieee80211_device *ieee)
11330 +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee)
11331 {
11332 short ch = 0;
11333 -
11334 if (ieee->proto_started)
11335 return;
11336 -
11337 +
11338 ieee->proto_started = 1;
11339 -
11340 +
11341 if (ieee->current_network.channel == 0){
11342 do{
11343 ch++;
11344 - if (ch > MAX_CHANNEL_NUMBER)
11345 + if (ch > MAX_CHANNEL_NUMBER)
11346 return; /* no channel found */
11347 -
11348 +
11349 }while(!ieee->channel_map[ch]);
11350 -
11351 +
11352 ieee->current_network.channel = ch;
11353 }
11354 -
11355 +
11356 if (ieee->current_network.beacon_interval == 0)
11357 ieee->current_network.beacon_interval = 100;
11358 -
11359 ieee->set_chan(ieee->dev,ieee->current_network.channel);
11360 -
11361 ieee->last_seq_num = -1;
11362 ieee->last_frag_num = -1;
11363 ieee->last_packet_time = 0;
11364 @@ -2107,30 +2149,27 @@
11365 * attempts does not fail just because the user provide the essid
11366 * and the nic is still checking for the AP MAC ??
11367 */
11368 -
11369 +
11370 if (ieee->iw_mode == IW_MODE_INFRA)
11371 - ieee80211_start_bss(ieee);
11372 -
11373 + ieee80211_start_bss_rtl7(ieee);
11374 else if (ieee->iw_mode == IW_MODE_ADHOC)
11375 - ieee80211_start_ibss(ieee);
11376 -
11377 + ieee80211_start_ibss_rtl7(ieee);
11378 else if (ieee->iw_mode == IW_MODE_MASTER)
11379 - ieee80211_start_master_bss(ieee);
11380 -
11381 + ieee80211_start_master_bss_rtl7(ieee);
11382 else if(ieee->iw_mode == IW_MODE_MONITOR)
11383 - ieee80211_start_monitor_mode(ieee);
11384 + ieee80211_start_monitor_mode_rtl7(ieee);
11385 }
11386  
11387  
11388 #define DRV_NAME "Ieee80211"
11389 -void ieee80211_softmac_init(struct ieee80211_device *ieee)
11390 +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee)
11391 {
11392 memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
11393 -
11394 +
11395 ieee->state = IEEE80211_NOLINK;
11396 ieee->sync_scan_hurryup = 0;
11397 ieee->seq_ctrl = 0;
11398 -
11399 +
11400 ieee->assoc_id = 0;
11401 ieee->queue_stop = 0;
11402 ieee->scanning = 0;
11403 @@ -2142,66 +2181,75 @@
11404 ieee->rate = 3;
11405 ieee->ps = IEEE80211_PS_DISABLED;
11406 ieee->sta_sleep = 0;
11407 -
11408 - init_mgmt_queue(ieee);
11409 +
11410 + init_mgmt_queue_rtl7(ieee);
11411 #if 0
11412 init_timer(&ieee->scan_timer);
11413 ieee->scan_timer.data = (unsigned long)ieee;
11414 ieee->scan_timer.function = ieee80211_softmac_scan_cb;
11415 #endif
11416 ieee->tx_pending.txb = NULL;
11417 -
11418 +
11419 init_timer(&ieee->associate_timer);
11420 ieee->associate_timer.data = (unsigned long)ieee;
11421 - ieee->associate_timer.function = ieee80211_associate_abort_cb;
11422 + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7;
11423  
11424 init_timer(&ieee->beacon_timer);
11425 ieee->beacon_timer.data = (unsigned long) ieee;
11426 - ieee->beacon_timer.function = ieee80211_send_beacon_cb;
11427 -
11428 + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7;
11429 +
11430 #ifdef PF_SYNCTHREAD
11431 ieee->wq = create_workqueue(DRV_NAME,0);
11432 -#else
11433 +#else
11434 ieee->wq = create_workqueue(DRV_NAME);
11435 #endif
11436 -
11437 - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
11438 - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
11439 - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
11440 - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
11441 - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
11442 - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
11443 -
11444 +
11445 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
11446 + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee);
11447 + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee);
11448 + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee);
11449 + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee);
11450 + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee);
11451 + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee);
11452 +#else
11453 + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7);
11454 + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7);
11455 + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7);
11456 + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7);
11457 + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7);
11458 + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7);
11459 +#endif
11460 +
11461 sema_init(&ieee->wx_sem, 1);
11462 sema_init(&ieee->scan_sem, 1);
11463 -
11464 +
11465 spin_lock_init(&ieee->mgmt_tx_lock);
11466 spin_lock_init(&ieee->beacon_lock);
11467 -
11468 +
11469 tasklet_init(&ieee->ps_task,
11470 - (void(*)(unsigned long)) ieee80211_sta_ps,
11471 + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7,
11472 (unsigned long)ieee);
11473  
11474 }
11475  
11476 -void ieee80211_softmac_free(struct ieee80211_device *ieee)
11477 +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee)
11478 {
11479 down(&ieee->wx_sem);
11480 -
11481 +
11482 del_timer_sync(&ieee->associate_timer);
11483 cancel_delayed_work(&ieee->associate_retry_wq);
11484 destroy_workqueue(ieee->wq);
11485 -
11486 +
11487 up(&ieee->wx_sem);
11488 }
11489  
11490 -/********************************************************
11491 +/********************************************************
11492 * Start of WPA code. *
11493 * this is stolen from the ipw2200 driver *
11494 ********************************************************/
11495  
11496 -
11497 -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
11498 +
11499 +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value)
11500 {
11501 /* This is called when wpa_supplicant loads and closes the driver
11502 * interface. */
11503 @@ -2210,19 +2258,19 @@
11504 return 0;
11505 }
11506  
11507 -
11508 -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
11509 +
11510 +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
11511 {
11512 /* make sure WPA is enabled */
11513 - ieee80211_wpa_enable(ieee, 1);
11514 + ieee80211_wpa_enable_rtl7(ieee, 1);
11515  
11516 - ieee80211_disassociate(ieee);
11517 + ieee80211_disassociate_rtl7(ieee);
11518 }
11519  
11520  
11521 -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
11522 +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason)
11523 {
11524 -
11525 +
11526 int ret = 0;
11527  
11528 switch (command) {
11529 @@ -2231,7 +2279,7 @@
11530 break;
11531  
11532 case IEEE_MLME_STA_DISASSOC:
11533 - ieee80211_disassociate(ieee);
11534 + ieee80211_disassociate_rtl7(ieee);
11535 break;
11536  
11537 default:
11538 @@ -2243,7 +2291,7 @@
11539 }
11540  
11541  
11542 -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
11543 +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee,
11544 struct ieee_param *param, int plen)
11545 {
11546 u8 *buf;
11547 @@ -2267,16 +2315,16 @@
11548 ieee->wpa_ie_len = 0;
11549 }
11550  
11551 - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
11552 + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
11553 return 0;
11554 }
11555  
11556 #define AUTH_ALG_OPEN_SYSTEM 0x1
11557 #define AUTH_ALG_SHARED_KEY 0x2
11558  
11559 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
11560 +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value)
11561 {
11562 -
11563 +
11564 struct ieee80211_security sec = {
11565 .flags = SEC_AUTH_MODE,
11566 };
11567 @@ -2300,13 +2348,13 @@
11568  
11569  
11570  
11571 -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
11572 +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value)
11573 {
11574 int ret=0;
11575  
11576 switch (name) {
11577 case IEEE_PARAM_WPA_ENABLED:
11578 - ret = ieee80211_wpa_enable(ieee, value);
11579 + ret = ieee80211_wpa_enable_rtl7(ieee, value);
11580 break;
11581  
11582 case IEEE_PARAM_TKIP_COUNTERMEASURES:
11583 @@ -2351,7 +2399,7 @@
11584 break;
11585  
11586 case IEEE_PARAM_AUTH_ALGS:
11587 - ret = ieee80211_wpa_set_auth_algs(ieee, value);
11588 + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value);
11589 break;
11590  
11591 case IEEE_PARAM_IEEE_802_1X:
11592 @@ -2368,11 +2416,11 @@
11593  
11594 /* implementation borrowed from hostap driver */
11595  
11596 -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
11597 +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee,
11598 struct ieee_param *param, int param_len)
11599 {
11600 int ret = 0;
11601 -
11602 +
11603 struct ieee80211_crypto_ops *ops;
11604 struct ieee80211_crypt_data **crypt;
11605  
11606 @@ -2407,7 +2455,7 @@
11607 //sec.encrypt = 0;
11608 sec.level = SEC_LEVEL_0;
11609 sec.flags |= SEC_ENABLED | SEC_LEVEL;
11610 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11611 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11612 }
11613 goto done;
11614 }
11615 @@ -2421,16 +2469,16 @@
11616 strcmp(param->u.crypt.alg, "TKIP"))
11617 goto skip_host_crypt;
11618  
11619 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11620 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11621 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
11622 - request_module("ieee80211_crypt_wep");
11623 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11624 + request_module("ieee80211_crypt_wep_rtl");
11625 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11626 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
11627 - request_module("ieee80211_crypt_tkip");
11628 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11629 + request_module("ieee80211_crypt_tkip_rtl");
11630 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11631 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
11632 - request_module("ieee80211_crypt_ccmp");
11633 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
11634 + request_module("ieee80211_crypt_ccmp_rtl");
11635 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
11636 }
11637 if (ops == NULL) {
11638 printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
11639 @@ -2442,7 +2490,7 @@
11640 if (*crypt == NULL || (*crypt)->ops != ops) {
11641 struct ieee80211_crypt_data *new_crypt;
11642  
11643 - ieee80211_crypt_delayed_deinit(ieee, crypt);
11644 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
11645  
11646 new_crypt = (struct ieee80211_crypt_data *)
11647 kmalloc(sizeof(*new_crypt), GFP_KERNEL);
11648 @@ -2525,7 +2573,7 @@
11649  
11650  
11651  
11652 -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
11653 +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p)
11654 {
11655 struct ieee_param *param;
11656 int ret=0;
11657 @@ -2537,7 +2585,7 @@
11658 ret = -EINVAL;
11659 goto out;
11660 }
11661 -
11662 +
11663 param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
11664 if (param == NULL){
11665 ret = -ENOMEM;
11666 @@ -2552,20 +2600,20 @@
11667 switch (param->cmd) {
11668  
11669 case IEEE_CMD_SET_WPA_PARAM:
11670 - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
11671 + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name,
11672 param->u.wpa_param.value);
11673 break;
11674  
11675 case IEEE_CMD_SET_WPA_IE:
11676 - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
11677 + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length);
11678 break;
11679  
11680 case IEEE_CMD_SET_ENCRYPTION:
11681 - ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
11682 + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length);
11683 break;
11684  
11685 case IEEE_CMD_MLME:
11686 - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
11687 + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command,
11688 param->u.mlme.reason_code);
11689 break;
11690  
11691 @@ -2581,11 +2629,11 @@
11692 kfree(param);
11693 out:
11694 up(&ieee->wx_sem);
11695 -
11696 +
11697 return ret;
11698 }
11699  
11700 -void notify_wx_assoc_event(struct ieee80211_device *ieee)
11701 +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee)
11702 {
11703 union iwreq_data wrqu;
11704 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
11705 @@ -2597,14 +2645,14 @@
11706 }
11707  
11708  
11709 -EXPORT_SYMBOL(ieee80211_get_beacon);
11710 -EXPORT_SYMBOL(ieee80211_wake_queue);
11711 -EXPORT_SYMBOL(ieee80211_stop_queue);
11712 -EXPORT_SYMBOL(ieee80211_reset_queue);
11713 -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
11714 -EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
11715 -EXPORT_SYMBOL(ieee80211_is_shortslot);
11716 -EXPORT_SYMBOL(ieee80211_is_54g);
11717 -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
11718 -EXPORT_SYMBOL(ieee80211_ps_tx_ack);
11719 -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
11720 +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7);
11721 +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7);
11722 +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7);
11723 +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7);
11724 +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7);
11725 +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7);
11726 +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7);
11727 +EXPORT_SYMBOL(ieee80211_is_54g_rtl7);
11728 +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7);
11729 +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7);
11730 +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7);
11731 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c
11732 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_softmac_wx.c 2006-06-06 04:57:54.000000000 +0200
11733 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c 2008-01-30 17:38:11.000000000 +0100
11734 @@ -1,7 +1,7 @@
11735 /* IEEE 802.11 SoftMAC layer
11736 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
11737 *
11738 - * Mostly extracted from the rtl8180-sa2400 driver for the
11739 + * Mostly extracted from the rtl8180-sa2400 driver for the
11740 * in-kernel generic ieee802.11 stack.
11741 *
11742 * Some pieces of code might be stolen from ipw2100 driver
11743 @@ -18,23 +18,23 @@
11744  
11745 /* FIXME: add A freqs */
11746  
11747 -const long ieee80211_wlan_frequencies[] = {
11748 - 2412, 2417, 2422, 2427,
11749 - 2432, 2437, 2442, 2447,
11750 - 2452, 2457, 2462, 2467,
11751 - 2472, 2484
11752 +const long ieee80211_wlan_frequencies_rtl7[] = {
11753 + 2412, 2417, 2422, 2427,
11754 + 2432, 2437, 2442, 2447,
11755 + 2452, 2457, 2462, 2467,
11756 + 2472, 2484
11757 };
11758  
11759  
11760 -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
11761 +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
11762 union iwreq_data *wrqu, char *b)
11763 {
11764 int ret;
11765 struct iw_freq *fwrq = & wrqu->freq;
11766  
11767 down(&ieee->wx_sem);
11768 -
11769 - if(ieee->iw_mode == IW_MODE_INFRA){
11770 +
11771 + if(ieee->iw_mode == IW_MODE_INFRA){
11772 ret = -EOPNOTSUPP;
11773 goto out;
11774 }
11775 @@ -45,31 +45,31 @@
11776 fwrq->m <= (int) 2.487e8)) {
11777 int f = fwrq->m / 100000;
11778 int c = 0;
11779 -
11780 - while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
11781 +
11782 + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c]))
11783 c++;
11784 -
11785 +
11786 /* hack to fall through */
11787 fwrq->e = 0;
11788 fwrq->m = c + 1;
11789 }
11790 }
11791 -
11792 - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
11793 +
11794 + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
11795 ret = -EOPNOTSUPP;
11796 goto out;
11797 -
11798 +
11799 }else { /* Set the channel */
11800 -
11801 -
11802 +
11803 +
11804 ieee->current_network.channel = fwrq->m;
11805 ieee->set_chan(ieee->dev, ieee->current_network.channel);
11806 -
11807 +
11808 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
11809 if(ieee->state == IEEE80211_LINKED){
11810 -
11811 - ieee80211_stop_send_beacons(ieee);
11812 - ieee80211_start_send_beacons(ieee);
11813 +
11814 + ieee80211_stop_send_beacons_rtl7(ieee);
11815 + ieee80211_start_send_beacons_rtl7(ieee);
11816 }
11817 }
11818  
11819 @@ -80,7 +80,7 @@
11820 }
11821  
11822  
11823 -int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
11824 +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee,
11825 struct iw_request_info *a,
11826 union iwreq_data *wrqu, char *b)
11827 {
11828 @@ -88,110 +88,110 @@
11829  
11830 if (ieee->current_network.channel == 0)
11831 return -1;
11832 -
11833 +
11834 fwrq->m = ieee->current_network.channel;
11835 fwrq->e = 0;
11836 -
11837 +
11838 return 0;
11839 }
11840  
11841 -int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
11842 - struct iw_request_info *info,
11843 +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
11844 + struct iw_request_info *info,
11845 union iwreq_data *wrqu, char *extra)
11846 {
11847 - unsigned long flags;
11848 -
11849 + unsigned long flags;
11850 +
11851 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
11852 -
11853 +
11854 if (ieee->iw_mode == IW_MODE_MONITOR)
11855 return -1;
11856 -
11857 +
11858 /* We want avoid to give to the user inconsistent infos*/
11859 spin_lock_irqsave(&ieee->lock, flags);
11860 -
11861 - if (ieee->state != IEEE80211_LINKED &&
11862 +
11863 + if (ieee->state != IEEE80211_LINKED &&
11864 ieee->state != IEEE80211_LINKED_SCANNING &&
11865 ieee->wap_set == 0)
11866 -
11867 +
11868 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
11869 else
11870 - memcpy(wrqu->ap_addr.sa_data,
11871 + memcpy(wrqu->ap_addr.sa_data,
11872 ieee->current_network.bssid, ETH_ALEN);
11873 -
11874 +
11875 spin_unlock_irqrestore(&ieee->lock, flags);
11876 -
11877 +
11878 return 0;
11879 }
11880  
11881  
11882 -int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
11883 +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
11884 struct iw_request_info *info,
11885 union iwreq_data *awrq,
11886 char *extra)
11887 {
11888 -
11889 +
11890 int ret = 0;
11891 u8 zero[] = {0,0,0,0,0,0};
11892 unsigned long flags;
11893 -
11894 +
11895 + struct sockaddr *temp = NULL;
11896 short ifup = ieee->proto_started;//dev->flags & IFF_UP;
11897 -
11898 +
11899 ieee->sync_scan_hurryup = 1;
11900 -
11901 +
11902 down(&ieee->wx_sem);
11903 -
11904 - struct sockaddr *temp = (struct sockaddr *)awrq;
11905 -
11906 +
11907 + temp = (struct sockaddr *)awrq;
11908 /* use ifconfig hw ether */
11909 if (ieee->iw_mode == IW_MODE_MASTER){
11910 ret = -1;
11911 goto out;
11912 }
11913 -
11914 +
11915 if (temp->sa_family != ARPHRD_ETHER){
11916 ret = -EINVAL;
11917 goto out;
11918 }
11919 -
11920 +
11921 if (ifup)
11922 - ieee80211_stop_protocol(ieee);
11923 -
11924 + ieee80211_stop_protocol_rtl7(ieee);
11925 +
11926 /* just to avoid to give inconsistent infos in the
11927 - * get wx method. not really needed otherwise
11928 + * get wx method. not really needed otherwise
11929 */
11930 spin_lock_irqsave(&ieee->lock, flags);
11931 -
11932 - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
11933 +
11934 + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
11935 ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
11936 -
11937 +
11938 spin_unlock_irqrestore(&ieee->lock, flags);
11939 -
11940 +
11941 if (ifup)
11942 - ieee80211_start_protocol(ieee);
11943 -
11944 + ieee80211_start_protocol_rtl7(ieee);
11945 +
11946 out:
11947 up(&ieee->wx_sem);
11948 return ret;
11949 }
11950 -
11951 - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
11952 +
11953 + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
11954 {
11955 int len,ret = 0;
11956 unsigned long flags;
11957 -
11958 +
11959 if (ieee->iw_mode == IW_MODE_MONITOR)
11960 return -1;
11961 -
11962 - /* We want avoid to give to the user inconsistent infos*/
11963 +
11964 + /* We want avoid to give to the user inconsistent infos*/
11965 spin_lock_irqsave(&ieee->lock, flags);
11966 -
11967 +
11968 if (ieee->current_network.ssid[0] == '\0' ||
11969 - ieee->current_network.ssid_len == 0){
11970 + ieee->current_network.ssid_len == 0){
11971 ret = -1;
11972 goto out;
11973 }
11974 -
11975 - if (ieee->state != IEEE80211_LINKED &&
11976 +
11977 + if (ieee->state != IEEE80211_LINKED &&
11978 ieee->state != IEEE80211_LINKED_SCANNING &&
11979 ieee->ssid_set == 0){
11980 ret = -1;
11981 @@ -204,59 +204,76 @@
11982  
11983 out:
11984 spin_unlock_irqrestore(&ieee->lock, flags);
11985 -
11986 +
11987 return ret;
11988 -
11989 +
11990 }
11991  
11992 -int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
11993 +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
11994 struct iw_request_info *info,
11995 union iwreq_data *wrqu, char *extra)
11996 {
11997  
11998 u32 target_rate = wrqu->bitrate.value;
11999 -
12000 +
12001 ieee->rate = target_rate/100000;
12002 //FIXME: we might want to limit rate also in management protocols.
12003 - return 0;
12004 + return 0;
12005 }
12006  
12007  
12008  
12009 -int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
12010 - struct iw_request_info *info,
12011 +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
12012 + struct iw_request_info *info,
12013 union iwreq_data *wrqu, char *extra)
12014 {
12015 -
12016 +
12017 wrqu->bitrate.value = ieee->rate * 100000;
12018 -
12019 +
12020 return 0;
12021 }
12022  
12023 -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
12024 +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12025 union iwreq_data *wrqu, char *b)
12026 {
12027 -
12028 + short prev = ieee->raw_tx;
12029 +
12030 ieee->sync_scan_hurryup = 1;
12031 -
12032 +
12033 down(&ieee->wx_sem);
12034 -
12035 +
12036 if (wrqu->mode == ieee->iw_mode)
12037 goto out;
12038 -
12039 +
12040 if (wrqu->mode == IW_MODE_MONITOR){
12041 -
12042 - ieee->dev->type = ARPHRD_IEEE80211;
12043 + ieee->dev->type = ARPHRD_IEEE80211_PRISM;
12044 }else{
12045 ieee->dev->type = ARPHRD_ETHER;
12046 }
12047 -
12048 +
12049 if (!ieee->proto_started){
12050 ieee->iw_mode = wrqu->mode;
12051 }else{
12052 - ieee80211_stop_protocol(ieee);
12053 + ieee80211_stop_protocol_rtl7(ieee);
12054 ieee->iw_mode = wrqu->mode;
12055 - ieee80211_start_protocol(ieee);
12056 + ieee80211_start_protocol_rtl7(ieee);
12057 + }
12058 +
12059 + if(ieee->iw_mode == IW_MODE_MONITOR)
12060 + {
12061 + ieee->raw_tx = 1;
12062 + if(prev == 0 && ieee->raw_tx){
12063 + if (ieee->data_hard_resume)
12064 + ieee->data_hard_resume(ieee->dev);
12065 +
12066 + netif_carrier_on(ieee->dev);
12067 + }
12068 +
12069 + netif_carrier_on(ieee->dev);
12070 + }
12071 + else
12072 + {
12073 + ieee->raw_tx = 0;
12074 }
12075  
12076 out:
12077 @@ -264,120 +281,132 @@
12078 return 0;
12079 }
12080  
12081 -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
12082 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
12083 +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work)
12084 {
12085 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
12086 +#else
12087 +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee)
12088 +{
12089 +#endif
12090 short chan;
12091  
12092 chan = ieee->current_network.channel;
12093 -
12094 +
12095 netif_carrier_off(ieee->dev);
12096 -
12097 +
12098 if (ieee->data_hard_stop)
12099 ieee->data_hard_stop(ieee->dev);
12100 -
12101 - ieee80211_stop_send_beacons(ieee);
12102 -
12103 +
12104 + ieee80211_stop_send_beacons_rtl7(ieee);
12105 +
12106 ieee->state = IEEE80211_LINKED_SCANNING;
12107 ieee->link_change(ieee->dev);
12108 -
12109 - ieee80211_start_scan_syncro(ieee);
12110 -
12111 +
12112 + ieee80211_start_scan_syncro_rtl7(ieee);
12113 +
12114 ieee->set_chan(ieee->dev, chan);
12115 -
12116 +
12117 ieee->state = IEEE80211_LINKED;
12118 ieee->link_change(ieee->dev);
12119 -
12120 +
12121 if (ieee->data_hard_resume)
12122 ieee->data_hard_resume(ieee->dev);
12123 -
12124 +
12125 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
12126 - ieee80211_start_send_beacons(ieee);
12127 -
12128 + ieee80211_start_send_beacons_rtl7(ieee);
12129 +
12130 netif_carrier_on(ieee->dev);
12131 -
12132 +
12133 up(&ieee->wx_sem);
12134 -
12135 +
12136 }
12137  
12138 -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
12139 +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12140 union iwreq_data *wrqu, char *b)
12141 {
12142 int ret = 0;
12143 -
12144 +
12145 down(&ieee->wx_sem);
12146 -
12147 - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
12148 +
12149 + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
12150 ret = -1;
12151 goto out;
12152 }
12153 -
12154 +
12155 if ( ieee->state == IEEE80211_LINKED){
12156 queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
12157 /* intentionally forget to up sem */
12158 return 0;
12159 }
12160 -
12161 +
12162 out:
12163 up(&ieee->wx_sem);
12164 return ret;
12165 }
12166  
12167 -int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
12168 +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
12169 struct iw_request_info *a,
12170 union iwreq_data *wrqu, char *extra)
12171 {
12172 -
12173 +
12174 int ret=0,len;
12175 short proto_started;
12176 unsigned long flags;
12177 -
12178 +
12179 ieee->sync_scan_hurryup = 1;
12180 -
12181 +
12182 down(&ieee->wx_sem);
12183 -
12184 +
12185 proto_started = ieee->proto_started;
12186 -
12187 +
12188 if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
12189 ret= -E2BIG;
12190 goto out;
12191 }
12192 -
12193 +
12194 if (ieee->iw_mode == IW_MODE_MONITOR){
12195 ret= -1;
12196 goto out;
12197 }
12198 -
12199 +
12200 if(proto_started)
12201 - ieee80211_stop_protocol(ieee);
12202 -
12203 + ieee80211_stop_protocol_rtl7(ieee);
12204 +
12205 /* this is just to be sure that the GET wx callback
12206 * has consisten infos. not needed otherwise
12207 */
12208 spin_lock_irqsave(&ieee->lock, flags);
12209 -
12210 +
12211 if (wrqu->essid.flags && wrqu->essid.length) {
12212 +#if WIRELESS_EXT > 20
12213 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
12214 +#else
12215 len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
12216 -
12217 +#endif
12218 +
12219 strncpy(ieee->current_network.ssid, extra, len);
12220 ieee->current_network.ssid_len = len;
12221 ieee->ssid_set = 1;
12222 }
12223 - else{
12224 + else{
12225 ieee->ssid_set = 0;
12226 ieee->current_network.ssid[0] = '\0';
12227 ieee->current_network.ssid_len = 0;
12228 }
12229 -
12230 +
12231 spin_unlock_irqrestore(&ieee->lock, flags);
12232 -
12233 +
12234 if (proto_started)
12235 - ieee80211_start_protocol(ieee);
12236 + ieee80211_start_protocol_rtl7(ieee);
12237 out:
12238 up(&ieee->wx_sem);
12239 +
12240 +
12241 return ret;
12242 }
12243  
12244 - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
12245 + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
12246 union iwreq_data *wrqu, char *b)
12247 {
12248  
12249 @@ -385,23 +414,23 @@
12250 return 0;
12251 }
12252  
12253 - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
12254 - struct iw_request_info *info,
12255 + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
12256 + struct iw_request_info *info,
12257 union iwreq_data *wrqu, char *extra)
12258 {
12259 -
12260 +
12261 int *parms = (int *)extra;
12262 int enable = (parms[0] > 0);
12263 short prev = ieee->raw_tx;
12264  
12265 down(&ieee->wx_sem);
12266 -
12267 - if(enable)
12268 +
12269 + if(enable)
12270 ieee->raw_tx = 1;
12271 - else
12272 + else
12273 ieee->raw_tx = 0;
12274  
12275 - printk(KERN_INFO"raw TX is %s\n",
12276 + printk(KERN_INFO"raw TX is %s\n",
12277 ieee->raw_tx ? "enabled" : "disabled");
12278  
12279 if(ieee->iw_mode == IW_MODE_MONITOR)
12280 @@ -409,21 +438,21 @@
12281 if(prev == 0 && ieee->raw_tx){
12282 if (ieee->data_hard_resume)
12283 ieee->data_hard_resume(ieee->dev);
12284 -
12285 - netif_carrier_on(ieee->dev);
12286 +
12287 + netif_carrier_on(ieee->dev);
12288 }
12289 -
12290 +
12291 if(prev && ieee->raw_tx == 1)
12292 - netif_carrier_off(ieee->dev);
12293 + netif_carrier_off(ieee->dev);
12294 }
12295 -
12296 +
12297 up(&ieee->wx_sem);
12298 -
12299 +
12300 return 0;
12301 }
12302 -
12303 -int ieee80211_wx_get_name(struct ieee80211_device *ieee,
12304 - struct iw_request_info *info,
12305 +
12306 +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
12307 + struct iw_request_info *info,
12308 union iwreq_data *wrqu, char *extra)
12309 {
12310 strcpy(wrqu->name, "802.11");
12311 @@ -433,20 +462,20 @@
12312 strcat(wrqu->name, "/g");
12313 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
12314 strcat(wrqu->name, "g");
12315 -
12316 - if((ieee->state == IEEE80211_LINKED) ||
12317 +
12318 + if((ieee->state == IEEE80211_LINKED) ||
12319 (ieee->state == IEEE80211_LINKED_SCANNING))
12320 strcat(wrqu->name," linked");
12321 else if(ieee->state != IEEE80211_NOLINK)
12322 strcat(wrqu->name," link..");
12323 -
12324 -
12325 +
12326 +
12327 return 0;
12328 }
12329  
12330  
12331 /* this is mostly stolen from hostap */
12332 -int ieee80211_wx_set_power(struct ieee80211_device *ieee,
12333 +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
12334 struct iw_request_info *info,
12335 union iwreq_data *wrqu, char *extra)
12336 {
12337 @@ -457,50 +486,50 @@
12338 (!ieee->ps_request_tx_ack) ||
12339 (!ieee->enter_sleep_state) ||
12340 (!ieee->ps_is_queue_empty)){
12341 -
12342 +
12343 printk("ERROR. PS mode is tryied to be use but\
12344 -driver missed a callback\n\n");
12345 -
12346 +driver missed a callback\n\n");
12347 +
12348 return -1;
12349 }
12350 -
12351 +
12352 down(&ieee->wx_sem);
12353 -
12354 +
12355 if (wrqu->power.disabled){
12356 ieee->ps = IEEE80211_PS_DISABLED;
12357 -
12358 +
12359 goto exit;
12360 }
12361 switch (wrqu->power.flags & IW_POWER_MODE) {
12362 case IW_POWER_UNICAST_R:
12363 ieee->ps = IEEE80211_PS_UNICAST;
12364 -
12365 +
12366 break;
12367 case IW_POWER_ALL_R:
12368 - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
12369 + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
12370 break;
12371 -
12372 +
12373 case IW_POWER_ON:
12374 ieee->ps = IEEE80211_PS_DISABLED;
12375 break;
12376 -
12377 +
12378 default:
12379 ret = -EINVAL;
12380 goto exit;
12381 }
12382  
12383 if (wrqu->power.flags & IW_POWER_TIMEOUT) {
12384 -
12385 +
12386 ieee->ps_timeout = wrqu->power.value / 1000;
12387 printk("Timeout %d\n",ieee->ps_timeout);
12388 }
12389 -
12390 +
12391 if (wrqu->power.flags & IW_POWER_PERIOD) {
12392 -
12393 +
12394 ret = -EOPNOTSUPP;
12395 goto exit;
12396 //wrq->value / 1024;
12397 -
12398 +
12399 }
12400 exit:
12401 up(&ieee->wx_sem);
12402 @@ -509,15 +538,15 @@
12403 }
12404  
12405 /* this is stolen from hostap */
12406 -int ieee80211_wx_get_power(struct ieee80211_device *ieee,
12407 +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
12408 struct iw_request_info *info,
12409 union iwreq_data *wrqu, char *extra)
12410 {
12411 int ret =0;
12412 -
12413 +
12414 down(&ieee->wx_sem);
12415 -
12416 - if(ieee->ps == IEEE80211_PS_DISABLED){
12417 +
12418 + if(ieee->ps == IEEE80211_PS_DISABLED){
12419 wrqu->power.disabled = 1;
12420 goto exit;
12421 }
12422 @@ -547,19 +576,19 @@
12423  
12424 }
12425  
12426 -EXPORT_SYMBOL(ieee80211_wx_get_essid);
12427 -EXPORT_SYMBOL(ieee80211_wx_set_essid);
12428 -EXPORT_SYMBOL(ieee80211_wx_set_rate);
12429 -EXPORT_SYMBOL(ieee80211_wx_get_rate);
12430 -EXPORT_SYMBOL(ieee80211_wx_set_wap);
12431 -EXPORT_SYMBOL(ieee80211_wx_get_wap);
12432 -EXPORT_SYMBOL(ieee80211_wx_set_mode);
12433 -EXPORT_SYMBOL(ieee80211_wx_get_mode);
12434 -EXPORT_SYMBOL(ieee80211_wx_set_scan);
12435 -EXPORT_SYMBOL(ieee80211_wx_get_freq);
12436 -EXPORT_SYMBOL(ieee80211_wx_set_freq);
12437 -EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
12438 -EXPORT_SYMBOL(ieee80211_wx_get_name);
12439 -EXPORT_SYMBOL(ieee80211_wx_set_power);
12440 -EXPORT_SYMBOL(ieee80211_wx_get_power);
12441 -EXPORT_SYMBOL(ieee80211_wlan_frequencies);
12442 +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7);
12443 +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7);
12444 +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7);
12445 +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7);
12446 +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7);
12447 +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7);
12448 +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7);
12449 +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7);
12450 +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7);
12451 +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7);
12452 +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7);
12453 +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7);
12454 +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7);
12455 +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7);
12456 +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7);
12457 +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7);
12458 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c
12459 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_tx.c 2006-06-06 04:57:54.000000000 +0200
12460 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c 2008-01-30 17:38:11.000000000 +0100
12461 @@ -24,15 +24,14 @@
12462  
12463 ******************************************************************************
12464  
12465 - Few modifications for Realtek's Wi-Fi drivers by
12466 + Few modifications for Realtek's Wi-Fi drivers by
12467 Andrea Merello <andreamrl@tiscali.it>
12468 -
12469 - A special thanks goes to Realtek for their support !
12470 +
12471 + A special thanks goes to Realtek for their support !
12472  
12473 ******************************************************************************/
12474  
12475 #include <linux/compiler.h>
12476 -#include <linux/config.h>
12477 #include <linux/errno.h>
12478 #include <linux/if_arp.h>
12479 #include <linux/in6.h>
12480 @@ -52,6 +51,12 @@
12481 #include <linux/etherdevice.h>
12482 #include <asm/uaccess.h>
12483  
12484 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
12485 +#include <linux/config.h>
12486 +#else
12487 +#include <linux/autoconf.h>
12488 +#endif
12489 +
12490 #include "ieee80211.h"
12491  
12492  
12493 @@ -155,7 +160,7 @@
12494 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
12495 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
12496  
12497 -static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
12498 +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto)
12499 {
12500 struct ieee80211_snap_hdr *snap;
12501 u8 *oui;
12502 @@ -178,7 +183,7 @@
12503 return SNAP_SIZE + sizeof(u16);
12504 }
12505  
12506 -int ieee80211_encrypt_fragment(
12507 +int ieee80211_encrypt_fragment_rtl7(
12508 struct ieee80211_device *ieee,
12509 struct sk_buff *frag,
12510 int hdr_len)
12511 @@ -225,7 +230,7 @@
12512 }
12513  
12514  
12515 -void ieee80211_txb_free(struct ieee80211_txb *txb) {
12516 +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) {
12517 int i;
12518 if (unlikely(!txb))
12519 return;
12520 @@ -235,7 +240,7 @@
12521 kfree(txb);
12522 }
12523  
12524 -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
12525 +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size,
12526 int gfp_mask)
12527 {
12528 struct ieee80211_txb *txb;
12529 @@ -267,7 +272,7 @@
12530 }
12531  
12532 /* SKBs are added to the ieee->tx_queue. */
12533 -int ieee80211_xmit(struct sk_buff *skb,
12534 +int ieee80211_xmit_rtl7(struct sk_buff *skb,
12535 struct net_device *dev)
12536 {
12537 struct ieee80211_device *ieee = netdev_priv(dev);
12538 @@ -299,27 +304,27 @@
12539 }
12540  
12541 if(likely(ieee->raw_tx == 0)){
12542 -
12543 +
12544 if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
12545 printk(KERN_WARNING "%s: skb too small (%d).\n",
12546 ieee->dev->name, skb->len);
12547 goto success;
12548 }
12549 -
12550 -
12551 +
12552 +
12553 ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
12554 -
12555 +
12556 crypt = ieee->crypt[ieee->tx_keyidx];
12557 -
12558 +
12559 encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
12560 ieee->host_encrypt && crypt && crypt->ops;
12561 -
12562 +
12563 if (!encrypt && ieee->ieee802_1x &&
12564 ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
12565 stats->tx_dropped++;
12566 goto success;
12567 }
12568 -
12569 +
12570 #ifdef CONFIG_IEEE80211_DEBUG
12571 if (crypt && !encrypt && ether_type == ETH_P_PAE) {
12572 struct eapol *eap = (struct eapol *)(skb->data +
12573 @@ -328,23 +333,23 @@
12574 eap_get_type(eap->type));
12575 }
12576 #endif
12577 -
12578 +
12579 /* Save source and destination addresses */
12580 memcpy(&dest, skb->data, ETH_ALEN);
12581 memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
12582 -
12583 +
12584 /* Advance the SKB to the start of the payload */
12585 skb_pull(skb, sizeof(struct ethhdr));
12586 -
12587 +
12588 /* Determine total amount of storage required for TXB packets */
12589 bytes = skb->len + SNAP_SIZE + sizeof(u16);
12590 -
12591 +
12592 if (encrypt)
12593 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
12594 IEEE80211_FCTL_WEP;
12595 else
12596 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
12597 -
12598 +
12599 if (ieee->iw_mode == IW_MODE_INFRA) {
12600 fc |= IEEE80211_FCTL_TODS;
12601 /* To DS: Addr1 = BSSID, Addr2 = SA,
12602 @@ -360,9 +365,9 @@
12603 memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
12604 }
12605 header.frame_ctl = cpu_to_le16(fc);
12606 -
12607 +
12608 hdr_len = IEEE80211_3ADDR_LEN;
12609 -
12610 +
12611 /* Determine fragmentation size based on destination (multicast
12612 * and broadcast are not fragmented) */
12613 if (is_multicast_ether_addr(dest) ||
12614 @@ -370,7 +375,7 @@
12615 frag_size = MAX_FRAG_THRESHOLD;
12616 else
12617 frag_size = ieee->fts;
12618 -
12619 +
12620 /* Determine amount of payload per fragment. Regardless of if
12621 * this stack is providing the full 802.11 header, one will
12622 * eventually be affixed to this fragment -- so we must account for
12623 @@ -379,12 +384,12 @@
12624 if (ieee->config &
12625 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
12626 bytes_per_frag -= IEEE80211_FCS_LEN;
12627 -
12628 +
12629 /* Each fragment may need to have room for encryptiong pre/postfix */
12630 if (encrypt)
12631 bytes_per_frag -= crypt->ops->extra_prefix_len +
12632 crypt->ops->extra_postfix_len;
12633 -
12634 +
12635 /* Number of fragments is the total bytes_per_frag /
12636 * payload_per_fragment */
12637 nr_frags = bytes / bytes_per_frag;
12638 @@ -393,11 +398,11 @@
12639 nr_frags++;
12640 else
12641 bytes_last_frag = bytes_per_frag;
12642 -
12643 +
12644 /* When we allocate the TXB we allocate enough space for the reserve
12645 * and full fragment bytes (bytes_per_frag doesn't include prefix,
12646 * postfix, header, FCS, etc.) */
12647 - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
12648 + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC);
12649 if (unlikely(!txb)) {
12650 printk(KERN_WARNING "%s: Could not allocate TXB\n",
12651 ieee->dev->name);
12652 @@ -405,93 +410,94 @@
12653 }
12654 txb->encrypted = encrypt;
12655 txb->payload_size = bytes;
12656 -
12657 +
12658 for (i = 0; i < nr_frags; i++) {
12659 skb_frag = txb->fragments[i];
12660 -
12661 +
12662 if (encrypt)
12663 skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
12664 -
12665 +
12666 frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
12667 memcpy(frag_hdr, &header, hdr_len);
12668 -
12669 +
12670 /* If this is not the last fragment, then add the MOREFRAGS
12671 * bit to the frame control */
12672 if (i != nr_frags - 1) {
12673 frag_hdr->frame_ctl = cpu_to_le16(
12674 fc | IEEE80211_FCTL_MOREFRAGS);
12675 bytes = bytes_per_frag;
12676 -
12677 +
12678 } else {
12679 /* The last fragment takes the remaining length */
12680 bytes = bytes_last_frag;
12681 }
12682 -
12683 +
12684 frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i);
12685 -
12686 -
12687 +
12688 +
12689 /* Put a SNAP header on the first fragment */
12690 if (i == 0) {
12691 - ieee80211_put_snap(
12692 + ieee80211_put_snap_rtl7(
12693 skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
12694 ether_type);
12695 bytes -= SNAP_SIZE + sizeof(u16);
12696 }
12697 -
12698 +
12699 memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
12700 -
12701 +
12702 /* Advance the SKB... */
12703 skb_pull(skb, bytes);
12704 -
12705 +
12706 /* Encryption routine will move the header forward in order
12707 * to insert the IV between the header and the payload */
12708 if (encrypt)
12709 - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
12710 + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len);
12711 if (ieee->config &
12712 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
12713 skb_put(skb_frag, 4);
12714 }
12715 - // Advance sequence number in data frame.
12716 + // Advance sequence number in data frame.
12717 if (ieee->seq_ctrl == 0xFFF)
12718 ieee->seq_ctrl = 0;
12719 else
12720 ieee->seq_ctrl++;
12721 //---
12722 }else{
12723 - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
12724 +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
12725 + if (unlikely(skb->len < 14)) {
12726 printk(KERN_WARNING "%s: skb too small (%d).\n",
12727 ieee->dev->name, skb->len);
12728 goto success;
12729 }
12730 -
12731 - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
12732 +
12733 + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC);
12734 if(!txb){
12735 printk(KERN_WARNING "%s: Could not allocate TXB\n",
12736 ieee->dev->name);
12737 goto failed;
12738 }
12739 -
12740 +
12741 txb->encrypted = 0;
12742 txb->payload_size = skb->len;
12743 memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len);
12744 - }
12745 + }
12746  
12747 success:
12748 spin_unlock_irqrestore(&ieee->lock, flags);
12749 dev_kfree_skb_any(skb);
12750 if (txb) {
12751 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
12752 - ieee80211_softmac_xmit(txb, ieee);
12753 + ieee80211_softmac_xmit_rtl7(txb, ieee);
12754 }else{
12755 if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
12756 stats->tx_packets++;
12757 stats->tx_bytes += txb->payload_size;
12758 return 0;
12759 }
12760 - ieee80211_txb_free(txb);
12761 + ieee80211_txb_free_rtl7(txb);
12762 }
12763 -
12764 -
12765 +
12766 +
12767 }
12768  
12769 return 0;
12770 @@ -504,4 +510,4 @@
12771  
12772 }
12773  
12774 -EXPORT_SYMBOL(ieee80211_txb_free);
12775 +EXPORT_SYMBOL(ieee80211_txb_free_rtl7);
12776 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c
12777 --- rtl8187_linux_26.1010.0622.2006/ieee80211/ieee80211_wx.c 2006-06-06 04:57:56.000000000 +0200
12778 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c 2008-01-30 17:38:11.000000000 +0100
12779 @@ -40,7 +40,7 @@
12780 };
12781  
12782 #define MAX_CUSTOM_LEN 64
12783 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
12784 +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee,
12785 char *start, char *stop,
12786 struct ieee80211_network *network)
12787 {
12788 @@ -207,7 +207,7 @@
12789 return start;
12790 }
12791  
12792 -int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
12793 +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
12794 struct iw_request_info *info,
12795 union iwreq_data *wrqu, char *extra)
12796 {
12797 @@ -220,13 +220,14 @@
12798  
12799 IEEE80211_DEBUG_WX("Getting scan\n");
12800 down(&ieee->wx_sem);
12801 + printk("GOT WX GET SCAN WX_SEM LOCK");
12802 spin_lock_irqsave(&ieee->lock, flags);
12803  
12804 list_for_each_entry(network, &ieee->network_list, list) {
12805 i++;
12806 if (ieee->scan_age == 0 ||
12807 time_after(network->last_scanned + ieee->scan_age, jiffies))
12808 - ev = ipw2100_translate_scan(ieee, ev, stop, network);
12809 + ev = ipw2100_translate_scan_rtl7(ieee, ev, stop, network);
12810 else
12811 IEEE80211_DEBUG_SCAN(
12812 "Not showing network '%s ("
12813 @@ -247,7 +248,7 @@
12814 return 0;
12815 }
12816  
12817 -int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
12818 +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
12819 struct iw_request_info *info,
12820 union iwreq_data *wrqu, char *keybuf)
12821 {
12822 @@ -259,6 +260,9 @@
12823 int i, key, key_provided, len;
12824 struct ieee80211_crypt_data **crypt;
12825  
12826 + if (erq->flags & IW_ENCODE_RESTRICTED)
12827 + return -EINVAL;
12828 +
12829 IEEE80211_DEBUG_WX("SET_ENCODE\n");
12830  
12831 key = erq->flags & IW_ENCODE_INDEX;
12832 @@ -281,7 +285,7 @@
12833 if (key_provided && *crypt) {
12834 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
12835 key);
12836 - ieee80211_crypt_delayed_deinit(ieee, crypt);
12837 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
12838 } else
12839 IEEE80211_DEBUG_WX("Disabling encryption.\n");
12840  
12841 @@ -291,7 +295,7 @@
12842 if (ieee->crypt[i] != NULL) {
12843 if (key_provided)
12844 break;
12845 - ieee80211_crypt_delayed_deinit(
12846 + ieee80211_crypt_delayed_deinit_rtl7(
12847 ieee, &ieee->crypt[i]);
12848 }
12849 }
12850 @@ -314,7 +318,7 @@
12851 strcmp((*crypt)->ops->name, "WEP") != 0) {
12852 /* changing to use WEP; deinit previously used algorithm
12853 * on this key */
12854 - ieee80211_crypt_delayed_deinit(ieee, crypt);
12855 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
12856 }
12857  
12858 if (*crypt == NULL) {
12859 @@ -326,10 +330,10 @@
12860 if (new_crypt == NULL)
12861 return -ENOMEM;
12862 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
12863 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
12864 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
12865 if (!new_crypt->ops) {
12866 - request_module("ieee80211_crypt_wep");
12867 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
12868 + request_module("ieee80211_crypt_wep_rtl");
12869 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
12870 }
12871  
12872 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
12873 @@ -340,7 +344,7 @@
12874 new_crypt = NULL;
12875  
12876 printk(KERN_WARNING "%s: could not initialize WEP: "
12877 - "load module ieee80211_crypt_wep\n",
12878 + "load module ieee80211_crypt_wep_rtl\n",
12879 dev->name);
12880 return -EOPNOTSUPP;
12881 }
12882 @@ -418,7 +422,7 @@
12883 return 0;
12884 }
12885  
12886 -int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
12887 +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
12888 struct iw_request_info *info,
12889 union iwreq_data *wrqu, char *keybuf)
12890 {
12891 @@ -430,7 +434,7 @@
12892  
12893 if(ieee->iw_mode == IW_MODE_MONITOR)
12894 return -1;
12895 -
12896 +
12897 key = erq->flags & IW_ENCODE_INDEX;
12898 if (key) {
12899 if (key > WEP_KEYS)
12900 @@ -470,6 +474,6 @@
12901 }
12902  
12903  
12904 -EXPORT_SYMBOL(ieee80211_wx_get_scan);
12905 -EXPORT_SYMBOL(ieee80211_wx_set_encode);
12906 -EXPORT_SYMBOL(ieee80211_wx_get_encode);
12907 +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7);
12908 +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7);
12909 +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7);
12910 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile
12911 --- rtl8187_linux_26.1010.0622.2006/ieee80211/Makefile 2006-06-06 04:57:54.000000000 +0200
12912 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile 2008-01-30 17:38:11.000000000 +0100
12913 @@ -17,6 +17,7 @@
12914 KVER := $(shell uname -r)
12915 KSRC := /lib/modules/$(KVER)/build
12916 INSTALL_PREFIX :=
12917 +PWD = $(shell pwd)
12918  
12919 all: modules
12920  
12921 diff -Naur rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers
12922 --- rtl8187_linux_26.1010.0622.2006/ieee80211/Modules.symvers 2006-06-06 04:57:56.000000000 +0200
12923 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers 1970-01-01 01:00:00.000000000 +0100
12924 @@ -1,43 +0,0 @@
12925 -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12926 -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12927 -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt
12928 -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12929 -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12930 -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12931 -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12932 -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12933 -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12934 -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12935 -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12936 -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12937 -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt
12938 -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12939 -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12940 -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12941 -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12942 -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12943 -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt
12944 -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12945 -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12946 -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12947 -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12948 -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12949 -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12950 -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12951 -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12952 -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt
12953 -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211
12954 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12955 -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt
12956 -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211
12957 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt
12958 -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211
12959 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211
12960 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
12961 -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12962 -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12963 -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12964 -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12965 -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12966 -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12967 -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
12968 diff -Naur rtl8187_linux_26.1010.0622.2006/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/Makefile
12969 --- rtl8187_linux_26.1010.0622.2006/Makefile 1970-01-01 01:00:00.000000000 +0100
12970 +++ rtl8187_linux_26.1010.0622.2006_rawtx/Makefile 2008-01-30 17:39:29.000000000 +0100
12971 @@ -0,0 +1,38 @@
12972 +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless
12973 +r8187dir = $(prefix)/rtl8187
12974 +ieeedir = $(prefix)/rtl_ieee80211
12975 +
12976 +default: all
12977 +
12978 +all:
12979 + -rm -f ieee80211/Module.symvers 2>/dev/null
12980 + -rm -f ieee80211/Modules.symvers 2>/dev/null
12981 + $(MAKE) -C ieee80211 $(@)
12982 + -chmod +x symvers
12983 + -./symvers
12984 + $(MAKE) -C beta-8187 $(@)
12985 +
12986 +install:
12987 + install -d $(ieeedir)
12988 + install -d $(r8187dir)
12989 + install -m 644 ./ieee80211/*.ko $(ieeedir)
12990 + install -m 644 ./beta-8187/*.ko $(r8187dir)
12991 + -depmod -ae
12992 +
12993 +uninstall:
12994 + -rm -f $(ieeedir)/ieee80211-rtl.ko
12995 + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko
12996 + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko
12997 + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko
12998 + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko
12999 + -rm -f $(r8187dir)/r8187.ko
13000 + -rm -fr $(ieeedir)
13001 + -rm -fr $(r8187dir)
13002 + -depmod -ae
13003 +
13004 +clean:
13005 + $(MAKE) -C ieee80211 $(@)
13006 + $(MAKE) -C beta-8187 $(@)
13007 +
13008 +distclean: clean
13009 +
13010 diff -Naur rtl8187_linux_26.1010.0622.2006/symvers rtl8187_linux_26.1010.0622.2006_rawtx/symvers
13011 --- rtl8187_linux_26.1010.0622.2006/symvers 1970-01-01 01:00:00.000000000 +0100
13012 +++ rtl8187_linux_26.1010.0622.2006_rawtx/symvers 2008-01-30 17:38:11.000000000 +0100
13013 @@ -0,0 +1,25 @@
13014 +#!/bin/sh
13015 +
13016 +cd beta-8187
13017 +
13018 +if [ -e Module.symvers ]
13019 +then
13020 + rm Module.symvers
13021 +fi
13022 +
13023 +if [ -e Modules.symvers ]
13024 +then
13025 + rm Modules.symvers
13026 +fi
13027 +
13028 +if [ -e ../ieee80211/Module.symvers ]
13029 +then
13030 + ln -sf ../ieee80211/Module.symvers ./
13031 +fi
13032 +
13033 +if [ -e ../ieee80211/Modules.symvers ]
13034 +then
13035 + ln -sf ../ieee80211/Modules.symvers ./
13036 +fi
13037 +
13038 +cd ..
13039 diff -Naur rtl8187_linux_26.1010.0622.2006/wlan0rmv rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv
13040 --- rtl8187_linux_26.1010.0622.2006/wlan0rmv 2006-09-05 07:21:10.000000000 +0200
13041 +++ rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv 2008-01-30 17:38:11.000000000 +0100
13042 @@ -1,5 +1,9 @@
13043 #!/bin/bash
13044  
13045 -rmmod r8180
13046 -rmmod ieee80211_r8180
13047 -rmmod ieee80211_crypt_r8180
13048 +rmmod rtl8187 2>/dev/null
13049 +rmmod r8187 2>/dev/null
13050 +rmmod ieee80211_rtl 2>/dev/null
13051 +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null
13052 +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null
13053 +rmmod ieee80211_crypt_wep_rtl 2>/dev/null
13054 +rmmod ieee80211_crypt_rtl 2>/dev/null