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_orig/beta-8187/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h
2 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/ieee80211_crypt.h 2006-06-05 22:58:02.000000000 -0400
3 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211_crypt.h 2008-08-12 13:11:32.000000000 -0400
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_orig/beta-8187/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h
24 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/ieee80211.h 2006-06-05 22:58:02.000000000 -0400
25 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/ieee80211.h 2008-08-12 14:23:31.000000000 -0400
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,21 @@
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 +#if WIRELESS_EXT >= 22
405 +static inline void *ieee80211_priv_rtl7(struct net_device *dev)
406 +#else
407 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
408 +#endif
409 {
410 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
411 }
412  
413 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
414 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
415 {
416 /* Single white space is for Linksys APs */
417 if (essid_len == 1 && essid[0] == ' ')
418 @@ -1175,7 +1200,7 @@
419 return 1;
420 }
421  
422 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
423 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
424 {
425 /*
426 * It is possible for both access points and our device to support
427 @@ -1201,7 +1226,7 @@
428 return 0;
429 }
430  
431 -extern inline int ieee80211_get_hdrlen(u16 fc)
432 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
433 {
434 int hdrlen = 24;
435  
436 @@ -1229,140 +1254,144 @@
437  
438  
439 /* ieee80211.c */
440 -extern void free_ieee80211(struct net_device *dev);
441 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
442 +extern void free_ieee80211_rtl7(struct net_device *dev);
443 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
444  
445 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
446 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
447  
448 /* ieee80211_tx.c */
449  
450 -extern int ieee80211_encrypt_fragment(
451 +extern int ieee80211_encrypt_fragment_rtl7(
452 struct ieee80211_device *ieee,
453 struct sk_buff *frag,
454 int hdr_len);
455 -
456 -extern int ieee80211_xmit(struct sk_buff *skb,
457 +
458 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
459 struct net_device *dev);
460 -extern void ieee80211_txb_free(struct ieee80211_txb *);
461 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
462  
463  
464 /* ieee80211_rx.c */
465 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
466 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
467 struct ieee80211_rx_stats *rx_stats);
468 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
469 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
470 struct ieee80211_hdr *header,
471 struct ieee80211_rx_stats *stats);
472  
473 /* ieee80211_wx.c */
474 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
475 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
476 struct iw_request_info *info,
477 union iwreq_data *wrqu, char *key);
478 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
479 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
480 struct iw_request_info *info,
481 union iwreq_data *wrqu, char *key);
482 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
483 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
484 struct iw_request_info *info,
485 union iwreq_data *wrqu, char *key);
486 /* ieee80211_softmac.c */
487 -extern short ieee80211_is_54g(struct ieee80211_network net);
488 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
489 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
490 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
491 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
492 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
493 struct ieee80211_rx_stats *rx_stats, u16 type,
494 u16 stype);
495 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
496 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
497  
498 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
499 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
500 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
501 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
502 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
503 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
504 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
505 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
506 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
507 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
508 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
509 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
510 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
511 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
512 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
513 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
514 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
515 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
516 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
517 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
518 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
519 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
520 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
521 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
522 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
523 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
524 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
525 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
526 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
527 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
528 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
529 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
530 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
531 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
532 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
533 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
534 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
535 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
536 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
537 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
538 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
539 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
540 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
541 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
542 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
543 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
544 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
545 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
546 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
547 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
548  
549 /* ieee80211_softmac_wx.c */
550  
551 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
552 - struct iw_request_info *info,
553 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
554 + struct iw_request_info *info,
555 union iwreq_data *wrqu, char *ext);
556 -
557 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
558 +
559 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
560 struct iw_request_info *info,
561 union iwreq_data *awrq,
562 char *extra);
563 -
564 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
565  
566 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
567 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
568 +
569 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
570 struct iw_request_info *info,
571 union iwreq_data *wrqu, char *extra);
572 -
573 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
574 - struct iw_request_info *info,
575 +
576 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
577 + struct iw_request_info *info,
578 union iwreq_data *wrqu, char *extra);
579 -
580 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
581 +
582 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
583 union iwreq_data *wrqu, char *b);
584 -
585 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
586 +
587 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
588 union iwreq_data *wrqu, char *b);
589 -
590 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
591 +
592 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
593 struct iw_request_info *a,
594 union iwreq_data *wrqu, char *extra);
595 -
596 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
597 +
598 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
599 union iwreq_data *wrqu, char *b);
600  
601 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
602 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
603 union iwreq_data *wrqu, char *b);
604  
605 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
606 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
607 union iwreq_data *wrqu, char *b);
608  
609 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
610 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
611 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
612 +#else
613 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
614 +#endif
615  
616 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
617 - struct iw_request_info *info,
618 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
619 + struct iw_request_info *info,
620 union iwreq_data *wrqu, char *extra);
621 -
622 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
623 - struct iw_request_info *info,
624 +
625 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
626 + struct iw_request_info *info,
627 union iwreq_data *wrqu, char *extra);
628  
629 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
630 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
631 struct iw_request_info *info,
632 union iwreq_data *wrqu, char *extra);
633  
634 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
635 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
636 struct iw_request_info *info,
637 union iwreq_data *wrqu, char *extra);
638 -
639 -extern const long ieee80211_wlan_frequencies[];
640  
641 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
642 +extern const long ieee80211_wlan_frequencies_rtl7[];
643 +
644 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
645 {
646 ieee->scans++;
647 }
648  
649 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
650 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
651 {
652 return ieee->scans;
653 }
654 @@ -1372,7 +1401,7 @@
655 const char *s = essid;
656 char *d = escaped;
657  
658 - if (ieee80211_is_empty_essid(essid, essid_len)) {
659 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
660 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
661 return escaped;
662 }
663 @@ -1390,4 +1419,5 @@
664 *d = '\0';
665 return escaped;
666 }
667 +
668 #endif /* IEEE80211_H */
669 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile
670 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/Makefile 2006-06-05 22:58:00.000000000 -0400
671 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/Makefile 2008-08-12 13:11:32.000000000 -0400
672 @@ -18,6 +18,8 @@
673 KVER := $(shell uname -r)
674 KSRC := /lib/modules/$(KVER)/build
675 INSTALL_PREFIX :=
676 +PWD = $(shell pwd)
677 +
678 all: modules
679  
680 clean:
681 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_93cx6.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c
682 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_93cx6.c 2006-06-05 22:58:00.000000000 -0400
683 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.c 2008-08-12 13:11:32.000000000 -0400
684 @@ -87,7 +87,7 @@
685  
686 u32 eprom_read(struct net_device *dev, u32 addr)
687 {
688 - struct r8180_priv *priv = ieee80211_priv(dev);
689 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
690 short read_cmd[]={1,1,0};
691 short addr_str[8];
692 int i;
693 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_hw.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h
694 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_hw.h 2006-06-05 22:58:00.000000000 -0400
695 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_hw.h 2008-08-12 13:11:32.000000000 -0400
696 @@ -646,6 +646,7 @@
697 #define FFER_INTR ((1<<15))
698 #define FFER_GWAKE ((1<< 4))
699  
700 -
701 +#define MAX_TX_POWER 27
702 +#define MIN_TX_POWER 20
703  
704 #endif
705 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c
706 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.c 2006-06-05 22:58:02.000000000 -0400
707 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.c 2008-08-12 13:11:32.000000000 -0400
708 @@ -173,7 +173,7 @@
709  
710 void rtl8225_set_gain(struct net_device *dev, short gain)
711 {
712 - struct r8180_priv *priv = ieee80211_priv(dev);
713 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
714  
715 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
716  
717 @@ -208,7 +208,7 @@
718 {
719 #ifdef USE_8051_3WIRE
720  
721 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
722 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
723 struct usb_device *udev = priv->udev;
724 //u8 bit;
725 u16 wReg80, wReg82, wReg84;
726 @@ -255,7 +255,7 @@
727 u16 out,select;
728 u8 bit;
729 u32 bangdata = (data << 4) | (adr & 0xf);
730 - struct r8180_priv *priv = ieee80211_priv(dev);
731 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
732  
733 out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
734  
735 @@ -349,7 +349,7 @@
736  
737 void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch)
738 {
739 - struct r8180_priv *priv = ieee80211_priv(dev);
740 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
741  
742 int GainIdx;
743 int GainSetting;
744 @@ -454,9 +454,9 @@
745  
746 void rtl8225_rf_set_chan(struct net_device *dev, short ch)
747 {
748 - struct r8180_priv *priv = ieee80211_priv(dev);
749 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
750 short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
751 - ieee80211_is_54g(priv->ieee80211->current_network)) ||
752 + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
753 priv->ieee80211->iw_mode == IW_MODE_MONITOR;
754  
755 rtl8225_SetTXPowerLevel(dev, ch);
756 @@ -474,7 +474,7 @@
757 write_nic_byte(dev,DIFS,0x24); //DIFS: 36
758  
759 if(priv->ieee80211->state == IEEE80211_LINKED &&
760 - ieee80211_is_shortslot(priv->ieee80211->current_network))
761 + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
762 write_nic_byte(dev,SLOT,0x9); //SLOT: 9
763  
764 else
765 @@ -546,7 +546,7 @@
766  
767 void rtl8225_rf_init(struct net_device *dev)
768 {
769 - struct r8180_priv *priv = ieee80211_priv(dev);
770 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
771 int i;
772 short channel = 1;
773 u16 brsr;
774 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h
775 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225.h 2006-06-05 22:58:00.000000000 -0400
776 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.h 2008-08-12 13:11:32.000000000 -0400
777 @@ -44,3 +44,5 @@
778 extern u32 rtl8225_chan[];
779  
780 #endif
781 +
782 +void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch);
783 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225z2.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c
784 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_rtl8225z2.c 2006-06-05 22:58:02.000000000 -0400
785 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.c 2008-08-12 13:11:32.000000000 -0400
786 @@ -2,12 +2,12 @@
787 This is part of the rtl8180-sa2400 driver
788 released under the GPL (See file COPYING for details).
789 Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
790 -
791 - This files contains programming code for the rtl8225
792 +
793 + This files contains programming code for the rtl8225
794 radio frontend.
795 -
796 +
797 *Many* thanks to Realtek Corp. for their great support!
798 -
799 +
800 */
801  
802  
803 @@ -32,51 +32,68 @@
804 };
805  
806 u8 rtl8225z2_gain_a[]={
807 - 0x13,0x27,0x5a,//,0x37,// -82dbm
808 - 0x23,0x23,0x58,//,0x37,// -82dbm
809 - 0x33,0x1f,0x56,//,0x37,// -82dbm
810 - 0x43,0x1b,0x54,//,0x37,// -78dbm
811 - 0x53,0x17,0x51,//,0x37,// -74dbm
812 - 0x63,0x24,0x4f,//,0x37,// -70dbm
813 - 0x73,0x0f,0x4c,//,0x37,// -66dbm
814 + 0x13,0x27,0x5a,//,0x37,// -82dbm
815 + 0x23,0x23,0x58,//,0x37,// -82dbm
816 + 0x33,0x1f,0x56,//,0x37,// -82dbm
817 + 0x43,0x1b,0x54,//,0x37,// -78dbm
818 + 0x53,0x17,0x51,//,0x37,// -74dbm
819 + 0x63,0x24,0x4f,//,0x37,// -70dbm
820 + 0x73,0x0f,0x4c,//,0x37,// -66dbm
821 };
822 #if 0
823 u32 rtl8225_chan[] = {
824 0, //dummy channel 0
825 - 0x085c, //1
826 - 0x08dc, //2
827 - 0x095c, //3
828 - 0x09dc, //4
829 - 0x0a5c, //5
830 - 0x0adc, //6
831 - 0x0b5c, //7
832 - 0x0bdc, //8
833 - 0x0c5c, //9
834 - 0x0cdc, //10
835 - 0x0d5c, //11
836 - 0x0ddc, //12
837 - 0x0e5c, //13
838 + 0x085c, //1
839 + 0x08dc, //2
840 + 0x095c, //3
841 + 0x09dc, //4
842 + 0x0a5c, //5
843 + 0x0adc, //6
844 + 0x0b5c, //7
845 + 0x0bdc, //8
846 + 0x0c5c, //9
847 + 0x0cdc, //10
848 + 0x0d5c, //11
849 + 0x0ddc, //12
850 + 0x0e5c, //13
851 //0x0f5c, //14
852 - 0x0f72, // 14
853 + 0x0f72, // 14
854 };
855 #endif
856  
857 +#if 1
858 //-
859 -u16 rtl8225z2_rxgain[]={
860 +u16 rtl8225z2_rxgain[]={
861 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0408, 0x0409,
862 - 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
863 + 0x040a, 0x040b, 0x0502, 0x0503, 0x0504, 0x0505, 0x0540, 0x0541,
864 0x0542, 0x0543, 0x0544, 0x0545, 0x0580, 0x0581, 0x0582, 0x0583,
865 - 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
866 + 0x0584, 0x0585, 0x0588, 0x0589, 0x058a, 0x058b, 0x0643, 0x0644,
867 0x0645, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0685, 0x0688,
868 0x0689, 0x068a, 0x068b, 0x068c, 0x0742, 0x0743, 0x0744, 0x0745,
869 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0788, 0x0789,
870 0x078a, 0x078b, 0x078c, 0x078d, 0x0790, 0x0791, 0x0792, 0x0793,
871 - 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
872 - 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
873 - 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
874 + 0x0794, 0x0795, 0x0798, 0x0799, 0x079a, 0x079b, 0x079c, 0x079d,
875 + 0x07a0, 0x07a1, 0x07a2, 0x07a3, 0x07a4, 0x07a5, 0x07a8, 0x07a9,
876 + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
877 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
878  
879 };
880 +#else
881 +u16 rtl8225z2_rxgain[]={
882 + 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0008, 0x0009,
883 + 0x000a, 0x000b, 0x0102, 0x0103, 0x0104, 0x0105, 0x0140, 0x0141,
884 + 0x0142, 0x0143, 0x0144, 0x0145, 0x0180, 0x0181, 0x0182, 0x0183,
885 + 0x0184, 0x0185, 0x0188, 0x0189, 0x018a, 0x018b, 0x0243, 0x0244,
886 + 0x0245, 0x0280, 0x0281, 0x0282, 0x0283, 0x0284, 0x0285, 0x0288,
887 + 0x0289, 0x028a, 0x028b, 0x028c, 0x0342, 0x0343, 0x0344, 0x0345,
888 + 0x0380, 0x0381, 0x0382, 0x0383, 0x0384, 0x0385, 0x0388, 0x0389,
889 + 0x038a, 0x038b, 0x038c, 0x038d, 0x0390, 0x0391, 0x0392, 0x0393,
890 + 0x0394, 0x0395, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d,
891 + 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a8, 0x03a9,
892 + 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03b0, 0x03b1, 0x03b2, 0x03b3,
893 + 0x03b4, 0x03b5, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bb
894 +};
895 +#endif
896  
897 //2005.11.16,
898 u8 ZEBRA2_CCK_OFDM_GAIN_SETTING[]={
899 @@ -129,23 +146,30 @@
900 void rtl8225z2_set_gain(struct net_device *dev, short gain)
901 {
902 u8* rtl8225_gain;
903 - struct r8180_priv *priv = ieee80211_priv(dev);
904 -
905 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
906 +
907 u8 mode = priv->ieee80211->mode;
908 -
909 - if(mode == IEEE_B || mode == IEEE_G)
910 +
911 + if((mode&IEEE_B) == IEEE_B || (mode&IEEE_G) == IEEE_G) {
912 + //printk(KERN_WARNING "mode ag!\n");
913 rtl8225_gain = rtl8225z2_gain_bg;
914 - else
915 + } else {
916 rtl8225_gain = rtl8225z2_gain_a;
917 -
918 + //printk(KERN_WARNING "mode a!\n");
919 + }
920 +
921 //write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 3]);
922 //write_phy_ofdm(dev, 0x19, rtl8225_gain[gain * 3 + 1]);
923 //write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 2]);
924 //2005.11.17, by ch-hsu
925 write_phy_ofdm(dev, 0x0b, rtl8225_gain[gain * 3]);
926 + mdelay(1);
927 write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 3 + 1]);
928 + mdelay(1);
929 write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 3 + 2]);
930 - write_phy_ofdm(dev, 0x21, 0x37);
931 + mdelay(1);
932 + write_phy_ofdm(dev, 0x21, 0x17);
933 + mdelay(1);
934  
935 }
936  
937 @@ -153,33 +177,33 @@
938  
939 void rtl8225_set_gain(struct net_device *dev, short gain)
940 {
941 - struct r8180_priv *priv = ieee80211_priv(dev);
942 -
943 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
944 +
945 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
946 -
947 +
948 if(priv->card_8185 == 2)
949 write_phy_ofdm(dev, 0x21, 0x27);
950 else
951 write_phy_ofdm(dev, 0x21, 0x37);
952 -
953 +
954 write_phy_ofdm(dev, 0x25, 0x20);
955 write_phy_ofdm(dev, 0x11, 0x6);
956 -
957 +
958 if(priv->card_8185 == 1 && priv->card_8185_Bversion)
959 write_phy_ofdm(dev, 0x27, 0x8);
960 else
961 write_phy_ofdm(dev, 0x27, 0x88);
962 -
963 +
964 write_phy_ofdm(dev, 0x14, 0);
965 write_phy_ofdm(dev, 0x16, 0);
966 write_phy_ofdm(dev, 0x15, 0x40);
967 write_phy_ofdm(dev, 0x17, 0x40);
968 -
969 +
970 write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]);
971 write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]);
972 write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]);
973 write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]);
974 - //rtl8225_set_gain_usb(dev, gain);
975 + //rtl8225_set_gain_usb(dev, gain);
976 }
977 #endif
978  
979 @@ -193,7 +217,7 @@
980 // ThreeWireReg tdata;
981 int i;
982 short bit, rw;
983 -
984 +
985 u8 wLength = 6;
986 u8 rLength = 12;
987 u8 low2high = 0;
988 @@ -207,20 +231,20 @@
989  
990 dataRead = 0;
991  
992 - oval &= ~0xf;
993 + oval &= ~0xf;
994  
995 write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4);
996  
997 write_nic_word(dev, RFPinsOutput, oval ); udelay(5);
998 -
999 +
1000 rw = 0;
1001 -
1002 +
1003 mask = (low2high) ? 0x01 : (((u32)0x01)<<(32-1));
1004 for(i = 0; i < wLength/2; i++)
1005 {
1006 bit = ((data2Write&mask) != 0) ? 1 : 0;
1007 write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1);
1008 -
1009 +
1010 write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
1011 write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2);
1012  
1013 @@ -233,9 +257,9 @@
1014 write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2);
1015 break;
1016 }
1017 -
1018 +
1019 bit = ((data2Write&mask) != 0) ? 1: 0;
1020 -
1021 +
1022 write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
1023 write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2);
1024  
1025 @@ -252,22 +276,22 @@
1026 for(i = 0; i < rLength; i++)
1027 {
1028 write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1);
1029 -
1030 +
1031 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
1032 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
1033 write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2);
1034 tmp = read_nic_word(dev, RFPinsInput);
1035 -
1036 +
1037 dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0);
1038  
1039 write_nic_word(dev, RFPinsOutput, (rw|oval)); udelay(2);
1040  
1041 mask = (low2high) ? (mask<<1) : (mask>>1);
1042 }
1043 -
1044 +
1045 write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2);
1046  
1047 - write_nic_word(dev, RFPinsEnable, oval2);
1048 + write_nic_word(dev, RFPinsEnable, oval2);
1049 write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch
1050 write_nic_word(dev, RFPinsOutput, 0x3a0);
1051  
1052 @@ -280,61 +304,61 @@
1053 u16 out,select;
1054 u8 bit;
1055 u32 bangdata = (data << 4) | (adr & 0xf);
1056 - struct r8180_priv *priv = ieee80211_priv(dev);
1057 -
1058 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1059 +
1060 out = read_nic_word(dev, RFPinsOutput) & 0xfff3;
1061 -
1062 +
1063 write_nic_word(dev,RFPinsEnable,
1064 (read_nic_word(dev,RFPinsEnable) | 0x7));
1065 -
1066 +
1067 select = read_nic_word(dev, RFPinsSelect);
1068 -
1069 - write_nic_word(dev, RFPinsSelect, select | 0x7 |
1070 +
1071 + write_nic_word(dev, RFPinsSelect, select | 0x7 |
1072 ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
1073 -
1074 +
1075 force_pci_posting(dev);
1076 udelay(10);
1077 -
1078 +
1079 write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff);
1080 -
1081 +
1082 force_pci_posting(dev);
1083 udelay(2);
1084 -
1085 +
1086 write_nic_word(dev, RFPinsOutput, out);
1087 -
1088 +
1089 force_pci_posting(dev);
1090 udelay(10);
1091 -
1092 -
1093 +
1094 +
1095 for(i=15; i>=0;i--){
1096 -
1097 +
1098 bit = (bangdata & (1<<i)) >> i;
1099 -
1100 +
1101 write_nic_word(dev, RFPinsOutput, bit | out);
1102 -
1103 +
1104 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1105 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1106  
1107 i--;
1108 bit = (bangdata & (1<<i)) >> i;
1109 -
1110 +
1111 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1112 write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK);
1113  
1114 write_nic_word(dev, RFPinsOutput, bit | out);
1115  
1116 }
1117 -
1118 +
1119 write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN);
1120 -
1121 +
1122 force_pci_posting(dev);
1123 udelay(10);
1124  
1125 - write_nic_word(dev, RFPinsOutput, out |
1126 + write_nic_word(dev, RFPinsOutput, out |
1127 ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN));
1128  
1129 - write_nic_word(dev, RFPinsSelect, select |
1130 - ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
1131 + write_nic_word(dev, RFPinsSelect, select |
1132 + ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO));
1133  
1134 if(priv->card_type == USB)
1135 mdelay(2);
1136 @@ -348,30 +372,30 @@
1137 short vz2 = 1;
1138 /* sw to reg pg 1 */
1139 write_rtl8225(dev, 0, 0x1b7);
1140 -
1141 +
1142 /* reg 8 pg 1 = 23*/
1143 if( read_rtl8225(dev, 8) != 0x588)
1144 vz2 = 0;
1145 -
1146 - else /* reg 9 pg 1 = 24 */
1147 +
1148 + else /* reg 9 pg 1 = 24 */
1149 if( read_rtl8225(dev, 9) != 0x700)
1150 vz2 = 0;
1151 -
1152 - /* sw back to pg 0 */
1153 +
1154 + /* sw back to pg 0 */
1155 write_rtl8225(dev, 0, 0xb7);
1156  
1157 return vz2;
1158 -
1159 +
1160 }
1161  
1162 #if 0
1163 void rtl8225_rf_close(struct net_device *dev)
1164 {
1165 - write_rtl8225(dev, 0x4, 0x1f);
1166 -
1167 + write_rtl8225(dev, 0x4, 0x1f);
1168 +
1169 force_pci_posting(dev);
1170 mdelay(1);
1171 -
1172 +
1173 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF);
1174 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF);
1175 }
1176 @@ -380,24 +404,24 @@
1177 short rtl8225_rf_set_sens(struct net_device *dev, short sens)
1178 {
1179 if (sens <0 || sens > 6) return -1;
1180 -
1181 +
1182 if(sens > 4)
1183 write_rtl8225(dev, 0x0c, 0x850);
1184 - else
1185 + else
1186 write_rtl8225(dev, 0x0c, 0x50);
1187  
1188 sens= 6-sens;
1189 rtl8225_set_gain(dev, sens);
1190 -
1191 +
1192 write_phy_cck(dev, 0x41, rtl8225_threshold[sens]);
1193 return 0;
1194 -
1195 +
1196 }
1197 #endif
1198 void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch)
1199 {
1200 - struct r8180_priv *priv = ieee80211_priv(dev);
1201 -
1202 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1203 +
1204 // int GainIdx;
1205 // int GainSetting;
1206 int i;
1207 @@ -406,44 +430,48 @@
1208 u8 max_cck_power_level;
1209 //u8 min_cck_power_level;
1210 u8 max_ofdm_power_level;
1211 - u8 min_ofdm_power_level;
1212 + u8 min_ofdm_power_level;
1213 u8 cck_power_level = 0xff & priv->chtxpwr[ch];
1214 u8 ofdm_power_level = 0xff & priv->chtxpwr_ofdm[ch];
1215 -
1216 -
1217 - max_cck_power_level = 15;
1218 +
1219 +
1220 + max_cck_power_level = 35;
1221 //min_cck_power_level = 0;
1222 - max_ofdm_power_level = 25; // 12 -> 25
1223 + max_ofdm_power_level = 35; // 12 -> 25
1224 min_ofdm_power_level = 10;
1225 -
1226 +
1227 /* CCK power setting */
1228 if(cck_power_level > max_cck_power_level)
1229 + {
1230 cck_power_level = max_cck_power_level;
1231 -
1232 + priv->chtxpwr[ch] = max_cck_power_level;
1233 + }
1234 +
1235 cck_power_level += priv->cck_txpwr_base;
1236 -
1237 +
1238 if(cck_power_level > 35)
1239 cck_power_level = 35;
1240 -
1241 - if(ch == 14)
1242 +
1243 + if(ch == 14)
1244 cck_power_table = rtl8225z2_tx_power_cck_ch14;
1245 - else
1246 + else
1247 cck_power_table = rtl8225z2_tx_power_cck;
1248 -
1249 -
1250 +
1251 + if(cck_power_level >= 20 && cck_power_level < 30)
1252 + cck_power_level = 19;
1253 +
1254 for(i=0;i<8;i++){
1255 -
1256 power = cck_power_table[i];
1257 write_phy_cck(dev, 0x44 + i, power);
1258 }
1259 -
1260 +
1261 //write_nic_byte(dev, TX_GAIN_CCK, power);
1262 //2005.11.17,
1263 write_nic_byte(dev, TX_GAIN_CCK, ZEBRA2_CCK_OFDM_GAIN_SETTING[cck_power_level]);
1264 -
1265 +
1266 force_pci_posting(dev);
1267 mdelay(1);
1268 -
1269 +
1270 /* OFDM power setting */
1271 // Old:
1272 // if(ofdm_power_level > max_ofdm_power_level)
1273 @@ -454,26 +482,26 @@
1274 ofdm_power_level = max_ofdm_power_level;
1275 else
1276 ofdm_power_level += min_ofdm_power_level;
1277 -
1278 +
1279 ofdm_power_level += priv->ofdm_txpwr_base;
1280 -
1281 +
1282 if(ofdm_power_level > 35)
1283 ofdm_power_level = 35;
1284 -
1285 +
1286 rtl8185_set_anaparam2(dev,RTL8225_ANAPARAM2_ON);
1287 -
1288 +
1289 write_phy_ofdm(dev,2,0x42);
1290 write_phy_ofdm(dev,5,0);
1291 write_phy_ofdm(dev,6,0x40);
1292 write_phy_ofdm(dev,7,0);
1293 - write_phy_ofdm(dev,8,0x40);
1294 -
1295 + write_phy_ofdm(dev,8,0x40);
1296 +
1297  
1298 //write_nic_byte(dev, TX_GAIN_OFDM, ofdm_power_level);
1299 //2005.11.17,
1300 write_nic_byte(dev, TX_GAIN_OFDM, ZEBRA2_CCK_OFDM_GAIN_SETTING[ofdm_power_level]);
1301  
1302 -
1303 +
1304 force_pci_posting(dev);
1305 mdelay(1);
1306 //write_nic_byte(dev, TX_AGC_CONTROL,4);
1307 @@ -483,39 +511,39 @@
1308 void rtl8225_set_mode(struct net_device *dev, short modeb)
1309 {
1310 write_phy_ofdm(dev, 0x15, (modeb ? 0x0 : 0x40));
1311 - write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
1312 + write_phy_ofdm(dev, 0x17, (modeb ? 0x0 : 0x40));
1313 }
1314 #endif
1315  
1316 void rtl8225z2_rf_set_chan(struct net_device *dev, short ch)
1317 {
1318 - struct r8180_priv *priv = ieee80211_priv(dev);
1319 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1320 short gset = (priv->ieee80211->state == IEEE80211_LINKED &&
1321 - ieee80211_is_54g(priv->ieee80211->current_network)) ||
1322 + ieee80211_is_54g_rtl7(priv->ieee80211->current_network)) ||
1323 priv->ieee80211->iw_mode == IW_MODE_MONITOR;
1324 -
1325 +
1326 rtl8225z2_SetTXPowerLevel(dev, ch);
1327 -
1328 +
1329 write_rtl8225(dev, 0x7, rtl8225_chan[ch]);
1330 -
1331 +
1332 force_pci_posting(dev);
1333 mdelay(10);
1334 -
1335 +
1336 write_nic_byte(dev,SIFS,0x22);// SIFS: 0x22
1337 -
1338 +
1339 if(gset)
1340 - write_nic_byte(dev,DIFS,20); //DIFS: 20
1341 + write_nic_byte(dev,DIFS,20); //DIFS: 20
1342 else
1343 - write_nic_byte(dev,DIFS,0x24); //DIFS: 36
1344 -
1345 + write_nic_byte(dev,DIFS,0x24); //DIFS: 36
1346 +
1347 if(priv->ieee80211->state == IEEE80211_LINKED &&
1348 - ieee80211_is_shortslot(priv->ieee80211->current_network))
1349 + ieee80211_is_shortslot_rtl7(priv->ieee80211->current_network))
1350 write_nic_byte(dev,SLOT,0x9); //SLOT: 9
1351 -
1352 +
1353 else
1354 write_nic_byte(dev,SLOT,0x14); //SLOT: 20 (0x14)
1355 -
1356 -
1357 +
1358 +
1359 if(gset){
1360 write_nic_byte(dev,EIFS,91 - 20); // EIFS: 91 (0x5B)
1361 write_nic_byte(dev,CW_VAL,0x73); //CW VALUE: 0x37
1362 @@ -529,68 +557,68 @@
1363  
1364 }
1365 #if 0
1366 -void rtl8225_host_pci_init(struct net_device *dev)
1367 +void rtl8225_host_pci_init(struct net_device *dev)
1368 {
1369 write_nic_word(dev, RFPinsOutput, 0x480);
1370 -
1371 +
1372 rtl8185_rf_pins_enable(dev);
1373 -
1374 +
1375 //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */
1376 //write_nic_word(dev, RFPinsSelect, 0x88);
1377 //else
1378 write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */
1379 -
1380 +
1381 write_nic_byte(dev, GP_ENABLE, 0);
1382 -
1383 +
1384 force_pci_posting(dev);
1385 mdelay(200);
1386 -
1387 +
1388 write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */
1389  
1390 -
1391 +
1392 }
1393  
1394 -void rtl8225_host_usb_init(struct net_device *dev)
1395 +void rtl8225_host_usb_init(struct net_device *dev)
1396 {
1397 write_nic_byte(dev,RFPinsSelect+1,0);
1398  
1399 write_nic_byte(dev,GPIO,0);
1400 -
1401 +
1402 write_nic_byte_E(dev,0x53,read_nic_byte_E(dev,0x53) | (1<<7));
1403 -
1404 +
1405 write_nic_byte(dev,RFPinsSelect+1,4);
1406  
1407 write_nic_byte(dev,GPIO,0x20);
1408  
1409 write_nic_byte(dev,GP_ENABLE,0);
1410  
1411 -
1412 - /* Config BB & RF */
1413 +
1414 + /* Config BB & RF */
1415 write_nic_word(dev, RFPinsOutput, 0x80);
1416  
1417 write_nic_word(dev, RFPinsSelect, 0x80);
1418  
1419 write_nic_word(dev, RFPinsEnable, 0x80);
1420  
1421 -
1422 +
1423 mdelay(100);
1424  
1425 - mdelay(1000);
1426 + mdelay(1000);
1427  
1428 }
1429 #endif
1430 -void rtl8225z2_rf_init(struct net_device *dev)
1431 +void rtl8225z2_rf_init(struct net_device *dev)
1432 {
1433 - struct r8180_priv *priv = ieee80211_priv(dev);
1434 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1435 int i;
1436 short channel = 1;
1437 u16 brsr;
1438 u32 data,addr;
1439 -
1440 +
1441 priv->chan = channel;
1442  
1443 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1444 -
1445 +
1446  
1447 if(priv->card_type == USB)
1448 rtl8225_host_usb_init(dev);
1449 @@ -598,42 +626,42 @@
1450 rtl8225_host_pci_init(dev);
1451  
1452 write_nic_dword(dev, RF_TIMING, 0x000a8008);
1453 -
1454 +
1455 brsr = read_nic_word(dev, BRSR);
1456 -
1457 - write_nic_word(dev, BRSR, 0xffff);
1458 +
1459 + write_nic_word(dev, BRSR, 0xffff);
1460  
1461  
1462 write_nic_dword(dev, RF_PARA, 0x100044);
1463 -
1464 +
1465 #if 1 //0->1
1466 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
1467 write_nic_byte(dev, CONFIG3, 0x44);
1468 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
1469 #endif
1470 -
1471 -
1472 +
1473 +
1474 rtl8185_rf_pins_enable(dev);
1475  
1476 // mdelay(1000);
1477  
1478 write_rtl8225(dev, 0x0, 0x2bf); mdelay(1);
1479 -
1480 -
1481 +
1482 +
1483 write_rtl8225(dev, 0x1, 0xee0); mdelay(1);
1484  
1485 write_rtl8225(dev, 0x2, 0x44d); mdelay(1);
1486  
1487 write_rtl8225(dev, 0x3, 0x441); mdelay(1);
1488  
1489 -
1490 +
1491 write_rtl8225(dev, 0x4, 0x8c3);mdelay(1);
1492 -
1493 -
1494 -
1495 +
1496 +
1497 +
1498 write_rtl8225(dev, 0x5, 0xc72);mdelay(1);
1499 // }
1500 -
1501 +
1502 write_rtl8225(dev, 0x6, 0xe6); mdelay(1);
1503  
1504 write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1);
1505 @@ -653,28 +681,28 @@
1506  
1507 write_rtl8225(dev, 0xe, 0x2b); mdelay(1);
1508  
1509 - write_rtl8225(dev, 0xf, 0x114);
1510 -
1511 -
1512 + write_rtl8225(dev, 0xf, 0x114);
1513 +
1514 +
1515 mdelay(100);
1516 -
1517 -
1518 +
1519 +
1520 //if(priv->card_type != USB) /* maybe not needed even for 8185 */
1521 -// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1522 -
1523 +// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1524 +
1525 write_rtl8225(dev, 0x0, 0x1b7);
1526 -
1527 +
1528 for(i=0;i<95;i++){
1529 write_rtl8225(dev, 0x1, (u8)(i+1));
1530 -
1531 +
1532 #if 0
1533 - if(priv->phy_ver == 1)
1534 + if(priv->phy_ver == 1)
1535 /* version A */
1536 write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]);
1537 else
1538 #endif
1539 /* version B & C & D*/
1540 -
1541 +
1542 write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]);
1543 }
1544 write_rtl8225(dev, 0x3, 0x80);
1545 @@ -683,16 +711,16 @@
1546 write_rtl8225(dev, 0x0, 0xb7);
1547  
1548 write_rtl8225(dev, 0x2, 0xc4d);
1549 -
1550 +
1551 if(priv->card_type == USB){
1552 // force_pci_posting(dev);
1553 mdelay(200);
1554 -
1555 +
1556 write_rtl8225(dev, 0x2, 0x44d);
1557 -
1558 +
1559 // force_pci_posting(dev);
1560 mdelay(100);
1561 -
1562 +
1563 }//End of if(priv->card_type == USB)
1564 /* FIXME!! rtl8187 we have to check if calibrarion
1565 * is successful and eventually cal. again (repeat
1566 @@ -713,23 +741,23 @@
1567 }
1568 }
1569 //force_pci_posting(dev);
1570 -
1571 - mdelay(200); //200 for 8187
1572 -
1573 -
1574 +
1575 + mdelay(200); //200 for 8187
1576 +
1577 +
1578 // //if(priv->card_type != USB){
1579 // write_rtl8225(dev, 0x2, 0x44d);
1580 // write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
1581 // write_rtl8225(dev, 0x2, 0x47d);
1582 -//
1583 +//
1584 // force_pci_posting(dev);
1585 // mdelay(100);
1586 -//
1587 +//
1588 // write_rtl8225(dev, 0x2, 0x44d);
1589 // //}
1590 -
1591 - write_rtl8225(dev, 0x0, 0x2bf);
1592 -
1593 +
1594 + write_rtl8225(dev, 0x0, 0x2bf);
1595 +
1596 if(priv->card_type != USB)
1597 rtl8185_rf_pins_enable(dev);
1598 //set up ZEBRA AGC table, 2005.11.17,
1599 @@ -744,20 +772,20 @@
1600  
1601 mdelay(1);
1602 }
1603 -#if 0
1604 +#if 0
1605 for(i=0;i<128;i++){
1606 write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
1607 -
1608 - mdelay(1);
1609 +
1610 + mdelay(1);
1611 write_phy_ofdm(dev, 0xa, (u8)i+ 0x80);
1612 -
1613 - mdelay(1);
1614 +
1615 + mdelay(1);
1616 }
1617 #endif
1618 -
1619 +
1620 force_pci_posting(dev);
1621 mdelay(1);
1622 -
1623 +
1624 write_phy_ofdm(dev, 0x0, 0x1); mdelay(1);
1625 write_phy_ofdm(dev, 0x1, 0x2); mdelay(1);
1626 write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1);
1627 @@ -771,20 +799,20 @@
1628  
1629 write_phy_ofdm(dev, 0xa, 0x8); mdelay(1);
1630  
1631 - //write_phy_ofdm(dev, 0x18, 0xef);
1632 + //write_phy_ofdm(dev, 0x18, 0xef);
1633 // }
1634 //}
1635 write_phy_ofdm(dev, 0xb, 0x80); mdelay(1);
1636  
1637 write_phy_ofdm(dev, 0xc, 0x1);mdelay(1);
1638  
1639 -
1640 +
1641 //if(priv->card_type != USB)
1642 - write_phy_ofdm(dev, 0xd, 0x43);
1643 -
1644 + write_phy_ofdm(dev, 0xd, 0x43);
1645 +
1646 write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1);
1647  
1648 -
1649 +
1650 #if 0
1651 if(priv->card_8185 == 1){
1652 if(priv->card_8185_Bversion)
1653 @@ -796,17 +824,17 @@
1654 write_phy_ofdm(dev, 0xf, 0x38);mdelay(1);
1655 /*ver D & 8187*/
1656 // }
1657 -
1658 +
1659 // if(priv->card_8185 == 1 && priv->card_8185_Bversion)
1660 // write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/
1661 // else
1662 write_phy_ofdm(dev, 0x10, 0x84);mdelay(1);
1663 /*ver C & D & 8187*/
1664 -
1665 +
1666 write_phy_ofdm(dev, 0x11, 0x07);mdelay(1);
1667 /*agc resp time 700*/
1668  
1669 -
1670 +
1671 // if(priv->card_8185 == 2){
1672 /* Ver D & 8187*/
1673 write_phy_ofdm(dev, 0x12, 0x20);mdelay(1);
1674 @@ -824,47 +852,46 @@
1675 write_phy_ofdm(dev, 0x15, 0x40); mdelay(1);
1676 write_phy_ofdm(dev, 0x16, 0x0); mdelay(1);
1677 write_phy_ofdm(dev, 0x17, 0x40); mdelay(1);
1678 -
1679 +
1680 // if (priv->card_type == USB)
1681 // write_phy_ofdm(dev, 0x18, 0xef);
1682 -
1683 +
1684 write_phy_ofdm(dev, 0x18, 0xef);mdelay(1);
1685 -
1686 +
1687  
1688 write_phy_ofdm(dev, 0x19, 0x19); mdelay(1);
1689 write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1);
1690 write_phy_ofdm(dev, 0x1b, 0x15);mdelay(1);
1691 -
1692 +
1693 write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1);
1694  
1695 write_phy_ofdm(dev, 0x1d, 0xc5);mdelay(1); //2005.11.17,
1696 -
1697 +
1698 write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1);
1699  
1700 write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
1701  
1702 // }
1703 -
1704 +
1705 write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1);
1706  
1707 write_phy_ofdm(dev, 0x21, 0x17);mdelay(1);
1708 -
1709 +
1710 write_phy_ofdm(dev, 0x22, 0x16);mdelay(1);
1711  
1712 // if(priv->card_type != USB)
1713 write_phy_ofdm(dev, 0x23, 0x80);mdelay(1); //FIXME maybe not needed // <>
1714 -
1715 +
1716 write_phy_ofdm(dev, 0x24, 0x46); mdelay(1);
1717 write_phy_ofdm(dev, 0x25, 0x00); mdelay(1);
1718 write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
1719  
1720 write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);
1721  
1722 -
1723 +
1724 // <> Set init. gain to m74dBm.
1725 -
1726 rtl8225z2_set_gain(dev,4);
1727 -
1728 +
1729 write_phy_cck(dev, 0x0, 0x98); mdelay(1);
1730 write_phy_cck(dev, 0x3, 0x20); mdelay(1);
1731 write_phy_cck(dev, 0x4, 0x7e); mdelay(1);
1732 @@ -875,6 +902,9 @@
1733 /* Ver C & D & 8187*/
1734  
1735 write_phy_cck(dev, 0x8, 0x2e);mdelay(1);
1736 + write_phy_cck(dev, 0x9, 0x11);mdelay(1);
1737 + write_phy_cck(dev, 0xa, 0x17);mdelay(1);
1738 + write_phy_cck(dev, 0xb, 0x11);mdelay(1);
1739  
1740 write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1);
1741 write_phy_cck(dev, 0x11, 0x88); mdelay(1);
1742 @@ -885,52 +915,59 @@
1743 else
1744 #endif
1745 write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
1746 -
1747 - write_phy_cck(dev, 0x19, 0x0);
1748 - write_phy_cck(dev, 0x1a, 0xa0);
1749 - write_phy_cck(dev, 0x1b, 0x8);
1750 - write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
1751 -
1752 - write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
1753  
1754 -
1755 +// write_phy_cck(dev, 0x19, 0x0);
1756 +// write_phy_cck(dev, 0x1a, 0xa0);
1757 +// write_phy_cck(dev, 0x1b, 0x8);
1758 +// write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
1759 + write_phy_cck(dev, 0x19, 0x0); mdelay(1);
1760 + write_phy_cck(dev, 0x1a, 0xa0); mdelay(1);
1761 + write_phy_cck(dev, 0x1b, 0x8); mdelay(1);
1762 + write_phy_cck(dev, 0x1d, 0x0); mdelay(1);
1763 + write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */ mdelay(1);
1764 + write_phy_cck(dev, 0x41, 0x86); mdelay(1);
1765 +
1766 +
1767 +// write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
1768 +
1769 +
1770 write_phy_cck(dev, 0x42, 0x15); mdelay(1);
1771 write_phy_cck(dev, 0x43, 0x18); mdelay(1);
1772 -
1773 -
1774 +
1775 +
1776 write_phy_cck(dev, 0x44, 0x36); mdelay(1);
1777 write_phy_cck(dev, 0x45, 0x35); mdelay(1);
1778 write_phy_cck(dev, 0x46, 0x2e); mdelay(1);
1779 write_phy_cck(dev, 0x47, 0x25); mdelay(1);
1780 write_phy_cck(dev, 0x48, 0x1c); mdelay(1);
1781 write_phy_cck(dev, 0x49, 0x12); mdelay(1);
1782 - write_phy_cck(dev, 0x4a, 0x9); mdelay(1);
1783 - write_phy_cck(dev, 0x4b, 0x4); mdelay(1);
1784 + write_phy_cck(dev, 0x4a, 0x09); mdelay(1);
1785 + write_phy_cck(dev, 0x4b, 0x04); mdelay(1);
1786 write_phy_cck(dev, 0x4c, 0x5);mdelay(1);
1787  
1788  
1789 write_nic_byte(dev, 0x5b, 0x0d); mdelay(1);
1790  
1791 -
1792 +
1793  
1794 // <>
1795 // // TESTR 0xb 8187
1796 // write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
1797 -//
1798 +//
1799 // //if(priv->card_type != USB){
1800 // write_phy_ofdm(dev, 0x2, 0x62);
1801 // write_phy_ofdm(dev, 0x6, 0x0);
1802 // write_phy_ofdm(dev, 0x8, 0x0);
1803 // //}
1804 -
1805 +
1806 rtl8225z2_SetTXPowerLevel(dev, channel);
1807 -
1808 +
1809 write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
1810 write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */
1811 -
1812 +
1813 rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */
1814 -
1815 - /* switch to high-speed 3-wire
1816 +
1817 + /* switch to high-speed 3-wire
1818 * last digit. 2 for both cck and ofdm
1819 */
1820 if(priv->card_type == USB)
1821 @@ -943,23 +980,23 @@
1822 // if(priv->card_type != USB)
1823 // rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <>
1824 // rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <>
1825 -//
1826 +//
1827 // /* make sure is waken up! */
1828 // write_rtl8225(dev,0x4, 0x9ff);
1829 -// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1830 +// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
1831 // rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
1832 -
1833 +
1834 rtl8225_rf_set_chan(dev, priv->chan);
1835  
1836 //write_nic_word(dev,BRSR,brsr);
1837 -
1838 +
1839 //rtl8225z2_rf_set_mode(dev);
1840 }
1841  
1842 -void rtl8225z2_rf_set_mode(struct net_device *dev)
1843 +void rtl8225z2_rf_set_mode(struct net_device *dev)
1844 {
1845 - struct r8180_priv *priv = ieee80211_priv(dev);
1846 -
1847 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1848 +
1849 if(priv->ieee80211->mode == IEEE_A)
1850 {
1851 write_rtl8225(dev, 0x5, 0x1865);
1852 @@ -970,15 +1007,15 @@
1853 write_phy_ofdm(dev, 0xb, 0x99);
1854 write_phy_ofdm(dev, 0xf, 0x20);
1855 write_phy_ofdm(dev, 0x11, 0x7);
1856 -
1857 +
1858 rtl8225z2_set_gain(dev,4);
1859 -
1860 +
1861 write_phy_ofdm(dev,0x15, 0x40);
1862 write_phy_ofdm(dev,0x17, 0x40);
1863 -
1864 +
1865 write_nic_dword(dev, 0x94,0x10000000);
1866 }else{
1867 -
1868 +
1869 write_rtl8225(dev, 0x5, 0x1864);
1870 write_nic_dword(dev, RF_PARA, 0x10044);
1871 write_nic_dword(dev, RF_TIMING, 0xa8008);
1872 @@ -987,12 +1024,12 @@
1873 write_phy_ofdm(dev, 0xb, 0x99);
1874 write_phy_ofdm(dev, 0xf, 0x20);
1875 write_phy_ofdm(dev, 0x11, 0x7);
1876 -
1877 +
1878 rtl8225z2_set_gain(dev,4);
1879 -
1880 +
1881 write_phy_ofdm(dev,0x15, 0x40);
1882 write_phy_ofdm(dev,0x17, 0x40);
1883 -
1884 +
1885 write_nic_dword(dev, 0x94,0x04000002);
1886 }
1887 }
1888 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c
1889 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8180_wx.c 2006-06-05 22:58:02.000000000 -0400
1890 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.c 2008-08-12 13:11:32.000000000 -0400
1891 @@ -1,19 +1,19 @@
1892 -/*
1893 +/*
1894 This file contains wireless extension handlers.
1895  
1896 This is part of rtl8180 OpenSource driver.
1897 - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
1898 + Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
1899 Released under the terms of GPL (General Public Licence)
1900 -
1901 - Parts of this driver are based on the GPL part
1902 +
1903 + Parts of this driver are based on the GPL part
1904 of the official realtek driver.
1905 -
1906 - Parts of this driver are based on the rtl8180 driver skeleton
1907 +
1908 + Parts of this driver are based on the rtl8180 driver skeleton
1909 from Patric Schenke & Andres Salomon.
1910  
1911 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver.
1912 -
1913 - We want to tanks the Authors of those projects and the Ndiswrapper
1914 +
1915 + We want to tanks the Authors of those projects and the Ndiswrapper
1916 project Authors.
1917 */
1918  
1919 @@ -21,20 +21,21 @@
1920  
1921 #include "r8187.h"
1922 #include "r8180_hw.h"
1923 +#include "r8180_rtl8225.h"
1924  
1925  
1926 #define RATE_COUNT 4
1927 u32 rtl8180_rates[] = {1000000,2000000,5500000,11000000,
1928 6000000,9000000,12000000,18000000,24000000,36000000,48000000,54000000};
1929 -
1930 +
1931  
1932 static int r8180_wx_get_freq(struct net_device *dev,
1933 struct iw_request_info *a,
1934 union iwreq_data *wrqu, char *b)
1935 {
1936 - struct r8180_priv *priv = ieee80211_priv(dev);
1937 -
1938 - return ieee80211_wx_get_freq(priv->ieee80211,a,wrqu,b);
1939 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1940 +
1941 + return ieee80211_wx_get_freq_rtl7(priv->ieee80211,a,wrqu,b);
1942 }
1943  
1944  
1945 @@ -45,28 +46,28 @@
1946 {
1947 int *parms = (int *)b;
1948 int bi = parms[0];
1949 -
1950 - struct r8180_priv *priv = ieee80211_priv(dev);
1951 -
1952 +
1953 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
1954 +
1955 down(&priv->wx_sem);
1956 DMESG("setting beacon interval to %x",bi);
1957 -
1958 +
1959 priv->ieee80211->beacon_interval=bi;
1960 rtl8180_commit(dev);
1961 up(&priv->wx_sem);
1962 -
1963 - return 0;
1964 +
1965 + return 0;
1966 }
1967  
1968  
1969 static int r8180_wx_set_forceassociate(struct net_device *dev, struct iw_request_info *aa,
1970 union iwreq_data *wrqu, char *extra)
1971 {
1972 - struct r8180_priv *priv=ieee80211_priv(dev);
1973 + struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
1974 int *parms = (int *)extra;
1975 -
1976 +
1977 priv->ieee80211->force_associate = (parms[0] > 0);
1978 -
1979 +
1980  
1981 return 0;
1982 }
1983 @@ -75,108 +76,228 @@
1984 static int r8180_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
1985 union iwreq_data *wrqu, char *b)
1986 {
1987 - struct r8180_priv *priv=ieee80211_priv(dev);
1988 + struct r8180_priv *priv=ieee80211_priv_rtl7(dev);
1989  
1990 - return ieee80211_wx_get_mode(priv->ieee80211,a,wrqu,b);
1991 + return ieee80211_wx_get_mode_rtl7(priv->ieee80211,a,wrqu,b);
1992 }
1993  
1994  
1995  
1996 -static int r8180_wx_get_rate(struct net_device *dev,
1997 - struct iw_request_info *info,
1998 +static int r8180_wx_get_rate(struct net_device *dev,
1999 + struct iw_request_info *info,
2000 union iwreq_data *wrqu, char *extra)
2001 {
2002 - struct r8180_priv *priv = ieee80211_priv(dev);
2003 - return ieee80211_wx_get_rate(priv->ieee80211,info,wrqu,extra);
2004 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2005 + return ieee80211_wx_get_rate_rtl7(priv->ieee80211,info,wrqu,extra);
2006 }
2007  
2008  
2009  
2010 -static int r8180_wx_set_rate(struct net_device *dev,
2011 - struct iw_request_info *info,
2012 +static int r8180_wx_set_rate(struct net_device *dev,
2013 + struct iw_request_info *info,
2014 union iwreq_data *wrqu, char *extra)
2015 {
2016 int ret;
2017 - struct r8180_priv *priv = ieee80211_priv(dev);
2018 -
2019 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2020 +
2021 down(&priv->wx_sem);
2022 + ret = ieee80211_wx_set_rate_rtl7(priv->ieee80211,info,wrqu,extra);
2023  
2024 - ret = ieee80211_wx_set_rate(priv->ieee80211,info,wrqu,extra);
2025 -
2026 up(&priv->wx_sem);
2027 -
2028 +
2029 return ret;
2030 }
2031  
2032 -static int r8180_wx_set_rawtx(struct net_device *dev,
2033 - struct iw_request_info *info,
2034 - union iwreq_data *wrqu, char *extra)
2035 +static int r8180_wx_get_txpow(struct net_device *dev,
2036 + struct iw_request_info *info,
2037 + union iwreq_data *wrqu, char *extra)
2038 {
2039 - struct r8180_priv *priv = ieee80211_priv(dev);
2040 - int ret;
2041 -
2042 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2043 + int i=0;
2044 down(&priv->wx_sem);
2045 -
2046 - ret = ieee80211_wx_set_rawtx(priv->ieee80211, info, wrqu, extra);
2047 -
2048 + wrqu->power.value = 0;
2049 + for(i=0; i<15; i++)
2050 + {
2051 + if(priv->chtxpwr[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr[i];
2052 + if(priv->chtxpwr_ofdm[i] > wrqu->power.value) wrqu->power.value = priv->chtxpwr_ofdm[i];
2053 + }
2054 + wrqu->power.fixed = 1;
2055 + wrqu->power.flags = IW_TXPOW_DBM;
2056 + wrqu->power.disabled = 0;
2057 up(&priv->wx_sem);
2058 -
2059 +
2060 + return 0;
2061 +}
2062 +
2063 +#if 1
2064 +static int r8180_wx_set_txpow(struct net_device *dev,
2065 + struct iw_request_info *info,
2066 + union iwreq_data *wrqu, char *extra)
2067 +{
2068 + int ret = 0, i=0;
2069 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2070 +
2071 + down(&priv->wx_sem);
2072 +
2073 + if (wrqu->power.flags != IW_TXPOW_DBM)
2074 + {
2075 + ret = -EINVAL;
2076 + goto out;
2077 + }
2078 +
2079 + if(!(priv->highpower) && wrqu->power.value > priv->txpwr_max)
2080 + {
2081 + ret = -EINVAL;
2082 + goto out;
2083 + }
2084 +
2085 + if(wrqu->power.value > 35)
2086 + {
2087 + ret = -EINVAL;
2088 + goto out;
2089 + }
2090 +
2091 + if(wrqu->power.value < 0)
2092 + {
2093 + ret = -EINVAL;
2094 + goto out;
2095 + }
2096 +
2097 + for(i=1;i<15;i++)
2098 + {
2099 + priv->chtxpwr[i] = priv->chtxpwr_orig[i] - (priv->txpwr_max - wrqu->power.value);
2100 +// if(priv->chtxpwr[i] > priv->chtxpwr_orig[i]) priv->chtxpwr[i] = 0;
2101 +
2102 + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i] - (priv->txpwr_max - wrqu->power.value);
2103 +// if(priv->chtxpwr_ofdm[i] > priv->chtxpwr_ofdm_orig[i]) priv->chtxpwr_ofdm[i] = 0;
2104 + }
2105 + rtl8225z2_SetTXPowerLevel(dev, 1);
2106 +
2107 + out:
2108 + up(&priv->wx_sem);
2109 +
2110 return ret;
2111 -
2112 +
2113 }
2114 +#endif
2115  
2116 -static int r8180_wx_set_crcmon(struct net_device *dev,
2117 - struct iw_request_info *info,
2118 +static int r8180_wx_set_crcmon(struct net_device *dev,
2119 + struct iw_request_info *info,
2120 union iwreq_data *wrqu, char *extra)
2121 {
2122 - struct r8180_priv *priv = ieee80211_priv(dev);
2123 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2124 int *parms = (int *)extra;
2125 int enable = (parms[0] > 0);
2126 short prev = priv->crcmon;
2127  
2128 down(&priv->wx_sem);
2129 -
2130 - if(enable)
2131 +
2132 + if(enable)
2133 priv->crcmon=1;
2134 - else
2135 + else
2136 priv->crcmon=0;
2137  
2138 - DMESG("bad CRC in monitor mode are %s",
2139 + DMESG("bad CRC in monitor mode are %s",
2140 priv->crcmon ? "accepted" : "rejected");
2141  
2142 if(prev != priv->crcmon && priv->up){
2143 rtl8180_down(dev);
2144 rtl8180_up(dev);
2145 }
2146 -
2147 +
2148 + up(&priv->wx_sem);
2149 +
2150 + return 0;
2151 +}
2152 +
2153 +static int r8180_wx_set_fasttx(struct net_device *dev,
2154 + struct iw_request_info *info,
2155 + union iwreq_data *wrqu, char *extra)
2156 +{
2157 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2158 + int *parms = (int *)extra;
2159 + int enable = (parms[0] > 0);
2160 + short prev = priv->fasttx;
2161 +
2162 + down(&priv->wx_sem);
2163 +
2164 + if(enable)
2165 + priv->fasttx=1;
2166 + else
2167 + priv->fasttx=0;
2168 +
2169 + DMESG("Transmission method (regarding speed) set to: %s",
2170 + priv->fasttx ? "fast" : "normal");
2171 +
2172 + if(prev != priv->fasttx && priv->up){
2173 + rtl8180_down(dev);
2174 + rtl8180_up(dev);
2175 + }
2176 +
2177 up(&priv->wx_sem);
2178 -
2179 +
2180 + return 0;
2181 +}
2182 +
2183 +static int r8180_wx_set_highpower(struct net_device *dev,
2184 + struct iw_request_info *info,
2185 + union iwreq_data *wrqu, char *extra)
2186 +{
2187 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2188 + int *parms = (int *)extra;
2189 + int enable = (parms[0] > 0);
2190 + int i=0;
2191 + short prev = priv->highpower;
2192 +
2193 + down(&priv->wx_sem);
2194 +
2195 + if(enable)
2196 + priv->highpower=1;
2197 + else
2198 + priv->highpower=0;
2199 +
2200 + DMESG("Increasable transmission power %s",
2201 + priv->highpower ? "enabled" : "disabled");
2202 +
2203 + if( (prev != priv->highpower) && !(priv->highpower) && (priv->chtxpwr[1] > priv->chtxpwr_orig[1]) )
2204 + {
2205 + for(i=1;i<15;i++)
2206 + {
2207 + priv->chtxpwr[i] = priv->chtxpwr_orig[i];
2208 + priv->chtxpwr_ofdm[i] = priv->chtxpwr_ofdm_orig[i];
2209 + }
2210 + rtl8225z2_SetTXPowerLevel(dev, 1);
2211 + wrqu->power.value = priv->txpwr_max;
2212 + }
2213 +
2214 + up(&priv->wx_sem);
2215 +
2216 return 0;
2217 }
2218  
2219 static int r8180_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
2220 union iwreq_data *wrqu, char *b)
2221 {
2222 - struct r8180_priv *priv = ieee80211_priv(dev);
2223 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2224 int ret;
2225 -
2226 +
2227 down(&priv->wx_sem);
2228 -
2229 - ret = ieee80211_wx_set_mode(priv->ieee80211,a,wrqu,b);
2230 -
2231 +
2232 + ret = ieee80211_wx_set_mode_rtl7(priv->ieee80211,a,wrqu,b);
2233 +
2234 rtl8187_set_rxconf(dev);
2235 -
2236 +
2237 up(&priv->wx_sem);
2238 return ret;
2239 }
2240  
2241  
2242 -static int rtl8180_wx_get_range(struct net_device *dev,
2243 - struct iw_request_info *info,
2244 +static int rtl8180_wx_get_range(struct net_device *dev,
2245 + struct iw_request_info *info,
2246 union iwreq_data *wrqu, char *extra)
2247 {
2248 struct iw_range *range = (struct iw_range *)extra;
2249 - struct r8180_priv *priv = ieee80211_priv(dev);
2250 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2251 u16 val;
2252 int i;
2253  
2254 @@ -186,26 +307,26 @@
2255 /* Let's try to keep this struct in the same order as in
2256 * linux/include/wireless.h
2257 */
2258 -
2259 +
2260 /* TODO: See what values we can set, and remove the ones we can't
2261 * set, or fill them with some default data.
2262 */
2263  
2264 /* ~5 Mb/s real (802.11b) */
2265 - range->throughput = 5 * 1000 * 1000;
2266 + range->throughput = 5 * 1000 * 1000;
2267  
2268 // TODO: Not used in 802.11b?
2269 // range->min_nwid; /* Minimal NWID we are able to set */
2270 // TODO: Not used in 802.11b?
2271 // range->max_nwid; /* Maximal NWID we are able to set */
2272 -
2273 +
2274 /* Old Frequency (backward compat - moved lower ) */
2275 -// range->old_num_channels;
2276 +// range->old_num_channels;
2277 // range->old_num_frequency;
2278 // range->old_freq[6]; /* Filler to keep "version" at the same offset */
2279 if(priv->rf_set_sens != NULL)
2280 range->sensitivity = priv->max_sens; /* signal level threshold range */
2281 -
2282 +
2283 range->max_qual.qual = 100;
2284 /* TODO: Find real max RSSI and stick here */
2285 range->max_qual.level = 0;
2286 @@ -219,14 +340,14 @@
2287 range->avg_qual.updated = 7; /* Updated all three */
2288  
2289 range->num_bitrates = RATE_COUNT;
2290 -
2291 +
2292 for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) {
2293 range->bitrate[i] = rtl8180_rates[i];
2294 }
2295 -
2296 +
2297 range->min_frag = MIN_FRAG_THRESHOLD;
2298 range->max_frag = MAX_FRAG_THRESHOLD;
2299 -
2300 +
2301 range->pm_capa = 0;
2302  
2303 range->we_version_compiled = WIRELESS_EXT;
2304 @@ -243,18 +364,18 @@
2305 range->num_channels = 14;
2306  
2307 for (i = 0, val = 0; i < 14; i++) {
2308 -
2309 +
2310 // Include only legal frequencies for some countries
2311 if ((priv->challow)[i+1]) {
2312 range->freq[val].i = i + 1;
2313 - range->freq[val].m = ieee80211_wlan_frequencies[i] * 100000;
2314 + range->freq[val].m = ieee80211_wlan_frequencies_rtl7[i] * 100000;
2315 range->freq[val].e = 1;
2316 val++;
2317 } else {
2318 // FIXME: do we need to set anything for channels
2319 // we don't use ?
2320 }
2321 -
2322 +
2323 if (val == IW_MAX_FREQUENCIES)
2324 break;
2325 }
2326 @@ -267,15 +388,15 @@
2327 static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
2328 union iwreq_data *wrqu, char *b)
2329 {
2330 - struct r8180_priv *priv = ieee80211_priv(dev);
2331 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2332 int ret;
2333 -
2334 +
2335 if(!priv->up) return -1;
2336 -
2337 +
2338 down(&priv->wx_sem);
2339 -
2340 - ret = ieee80211_wx_set_scan(priv->ieee80211,a,wrqu,b);
2341 -
2342 +
2343 + ret = ieee80211_wx_set_scan_rtl7(priv->ieee80211,a,wrqu,b);
2344 +
2345 up(&priv->wx_sem);
2346 return ret;
2347 }
2348 @@ -286,50 +407,50 @@
2349 {
2350  
2351 int ret;
2352 - struct r8180_priv *priv = ieee80211_priv(dev);
2353 -
2354 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2355 +
2356 if(!priv->up) return -1;
2357 -
2358 +
2359 down(&priv->wx_sem);
2360  
2361 - ret = ieee80211_wx_get_scan(priv->ieee80211,a,wrqu,b);
2362 -
2363 + ret = ieee80211_wx_get_scan_rtl7(priv->ieee80211,a,wrqu,b);
2364 +
2365 up(&priv->wx_sem);
2366 -
2367 +
2368 return ret;
2369 }
2370  
2371  
2372 -static int r8180_wx_set_essid(struct net_device *dev,
2373 +static int r8180_wx_set_essid(struct net_device *dev,
2374 struct iw_request_info *a,
2375 union iwreq_data *wrqu, char *b)
2376 {
2377 - struct r8180_priv *priv = ieee80211_priv(dev);
2378 -
2379 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2380 +
2381 int ret;
2382 -
2383 +
2384 down(&priv->wx_sem);
2385 -
2386 - ret = ieee80211_wx_set_essid(priv->ieee80211,a,wrqu,b);
2387 -
2388 +
2389 + ret = ieee80211_wx_set_essid_rtl7(priv->ieee80211,a,wrqu,b);
2390 +
2391 up(&priv->wx_sem);
2392 return ret;
2393 }
2394  
2395  
2396 -static int r8180_wx_get_essid(struct net_device *dev,
2397 +static int r8180_wx_get_essid(struct net_device *dev,
2398 struct iw_request_info *a,
2399 union iwreq_data *wrqu, char *b)
2400 {
2401 int ret;
2402 - struct r8180_priv *priv = ieee80211_priv(dev);
2403 -
2404 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2405 +
2406 down(&priv->wx_sem);
2407 -
2408 - ret = ieee80211_wx_get_essid(priv->ieee80211, a, wrqu, b);
2409 +
2410 + ret = ieee80211_wx_get_essid_rtl7(priv->ieee80211, a, wrqu, b);
2411  
2412 up(&priv->wx_sem);
2413 -
2414 +
2415 return ret;
2416 }
2417  
2418 @@ -338,30 +459,30 @@
2419 union iwreq_data *wrqu, char *b)
2420 {
2421 int ret;
2422 - struct r8180_priv *priv = ieee80211_priv(dev);
2423 -
2424 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2425 +
2426 down(&priv->wx_sem);
2427 -
2428 - ret = ieee80211_wx_set_freq(priv->ieee80211, a, wrqu, b);
2429 -
2430 +
2431 + ret = ieee80211_wx_set_freq_rtl7(priv->ieee80211, a, wrqu, b);
2432 +
2433 up(&priv->wx_sem);
2434 return ret;
2435 }
2436  
2437 -static int r8180_wx_get_name(struct net_device *dev,
2438 - struct iw_request_info *info,
2439 +static int r8180_wx_get_name(struct net_device *dev,
2440 + struct iw_request_info *info,
2441 union iwreq_data *wrqu, char *extra)
2442 {
2443 - struct r8180_priv *priv = ieee80211_priv(dev);
2444 - return ieee80211_wx_get_name(priv->ieee80211, info, wrqu, extra);
2445 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2446 + return ieee80211_wx_get_name_rtl7(priv->ieee80211, info, wrqu, extra);
2447 }
2448  
2449  
2450 -static int r8180_wx_set_frag(struct net_device *dev,
2451 - struct iw_request_info *info,
2452 +static int r8180_wx_set_frag(struct net_device *dev,
2453 + struct iw_request_info *info,
2454 union iwreq_data *wrqu, char *extra)
2455 {
2456 - struct r8180_priv *priv = ieee80211_priv(dev);
2457 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2458  
2459 if (wrqu->frag.disabled)
2460 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
2461 @@ -369,7 +490,7 @@
2462 if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
2463 wrqu->frag.value > MAX_FRAG_THRESHOLD)
2464 return -EINVAL;
2465 -
2466 +
2467 priv->ieee80211->fts = wrqu->frag.value & ~0x1;
2468 }
2469  
2470 @@ -377,11 +498,11 @@
2471 }
2472  
2473  
2474 -static int r8180_wx_get_frag(struct net_device *dev,
2475 - struct iw_request_info *info,
2476 +static int r8180_wx_get_frag(struct net_device *dev,
2477 + struct iw_request_info *info,
2478 union iwreq_data *wrqu, char *extra)
2479 {
2480 - struct r8180_priv *priv = ieee80211_priv(dev);
2481 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2482  
2483 wrqu->frag.value = priv->ieee80211->fts;
2484 wrqu->frag.fixed = 0; /* no auto select */
2485 @@ -397,49 +518,49 @@
2486 char *extra)
2487 {
2488 int ret;
2489 - struct r8180_priv *priv = ieee80211_priv(dev);
2490 -
2491 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2492 +
2493 down(&priv->wx_sem);
2494 -
2495 - ret = ieee80211_wx_set_wap(priv->ieee80211,info,awrq,extra);
2496 -
2497 +
2498 + ret = ieee80211_wx_set_wap_rtl7(priv->ieee80211,info,awrq,extra);
2499 +
2500 up(&priv->wx_sem);
2501 return ret;
2502 -
2503 +
2504 }
2505 -
2506  
2507 -static int r8180_wx_get_wap(struct net_device *dev,
2508 - struct iw_request_info *info,
2509 +
2510 +static int r8180_wx_get_wap(struct net_device *dev,
2511 + struct iw_request_info *info,
2512 union iwreq_data *wrqu, char *extra)
2513 {
2514 - struct r8180_priv *priv = ieee80211_priv(dev);
2515 -
2516 - return ieee80211_wx_get_wap(priv->ieee80211,info,wrqu,extra);
2517 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2518 +
2519 + return ieee80211_wx_get_wap_rtl7(priv->ieee80211,info,wrqu,extra);
2520 }
2521  
2522  
2523 -static int r8180_wx_get_enc(struct net_device *dev,
2524 - struct iw_request_info *info,
2525 +static int r8180_wx_get_enc(struct net_device *dev,
2526 + struct iw_request_info *info,
2527 union iwreq_data *wrqu, char *key)
2528 {
2529 - struct r8180_priv *priv = ieee80211_priv(dev);
2530 -
2531 - return ieee80211_wx_get_encode(priv->ieee80211, info, wrqu, key);
2532 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2533 +
2534 + return ieee80211_wx_get_encode_rtl7(priv->ieee80211, info, wrqu, key);
2535 }
2536  
2537 -static int r8180_wx_set_enc(struct net_device *dev,
2538 - struct iw_request_info *info,
2539 +static int r8180_wx_set_enc(struct net_device *dev,
2540 + struct iw_request_info *info,
2541 union iwreq_data *wrqu, char *key)
2542 {
2543 - struct r8180_priv *priv = ieee80211_priv(dev);
2544 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2545 int ret;
2546 -
2547 +
2548 down(&priv->wx_sem);
2549 -
2550 +
2551 DMESG("Setting SW wep key");
2552 - ret = ieee80211_wx_set_encode(priv->ieee80211,info,wrqu,key);
2553 -
2554 + ret = ieee80211_wx_set_encode_rtl7(priv->ieee80211,info,wrqu,key);
2555 +
2556 up(&priv->wx_sem);
2557 return ret;
2558 }
2559 @@ -447,28 +568,28 @@
2560  
2561 static int r8180_wx_set_scan_type(struct net_device *dev, struct iw_request_info *aa, union
2562 iwreq_data *wrqu, char *p){
2563 -
2564 - struct r8180_priv *priv = ieee80211_priv(dev);
2565 +
2566 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2567 int *parms=(int*)p;
2568 int mode=parms[0];
2569 -
2570 +
2571 priv->ieee80211->active_scan = mode;
2572 -
2573 +
2574 return 1;
2575 }
2576  
2577  
2578  
2579 -static int r8180_wx_set_retry(struct net_device *dev,
2580 - struct iw_request_info *info,
2581 +static int r8180_wx_set_retry(struct net_device *dev,
2582 + struct iw_request_info *info,
2583 union iwreq_data *wrqu, char *extra)
2584 {
2585 - struct r8180_priv *priv = ieee80211_priv(dev);
2586 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2587 int err = 0;
2588 -
2589 +
2590 down(&priv->wx_sem);
2591 -
2592 - if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
2593 +
2594 + if (wrqu->retry.flags & IW_RETRY_LIFETIME ||
2595 wrqu->retry.disabled){
2596 err = -EINVAL;
2597 goto exit;
2598 @@ -485,13 +606,13 @@
2599 if (wrqu->retry.flags & IW_RETRY_MAX) {
2600 priv->retry_rts = wrqu->retry.value;
2601 DMESG("Setting retry for RTS/CTS data to %d", wrqu->retry.value);
2602 -
2603 +
2604 }else {
2605 priv->retry_data = wrqu->retry.value;
2606 DMESG("Setting retry for non RTS/CTS data to %d", wrqu->retry.value);
2607 }
2608 -
2609 - /* FIXME !
2610 +
2611 + /* FIXME !
2612 * We might try to write directly the TX config register
2613 * or to restart just the (R)TX process.
2614 * I'm unsure if whole reset is really needed
2615 @@ -503,28 +624,28 @@
2616 rtl8180_rtx_disable(dev);
2617 rtl8180_rx_enable(dev);
2618 rtl8180_tx_enable(dev);
2619 -
2620 +
2621 }
2622 */
2623 exit:
2624 up(&priv->wx_sem);
2625 -
2626 +
2627 return err;
2628 }
2629  
2630 -static int r8180_wx_get_retry(struct net_device *dev,
2631 - struct iw_request_info *info,
2632 +static int r8180_wx_get_retry(struct net_device *dev,
2633 + struct iw_request_info *info,
2634 union iwreq_data *wrqu, char *extra)
2635 {
2636 - struct r8180_priv *priv = ieee80211_priv(dev);
2637 -
2638 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2639 +
2640  
2641 wrqu->retry.disabled = 0; /* can't be disabled */
2642  
2643 - if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
2644 - IW_RETRY_LIFETIME)
2645 + if ((wrqu->retry.flags & IW_RETRY_TYPE) ==
2646 + IW_RETRY_LIFETIME)
2647 return -EINVAL;
2648 -
2649 +
2650 if (wrqu->retry.flags & IW_RETRY_MAX) {
2651 wrqu->retry.flags = IW_RETRY_LIMIT & IW_RETRY_MAX;
2652 wrqu->retry.value = priv->retry_rts;
2653 @@ -533,30 +654,30 @@
2654 wrqu->retry.value = priv->retry_data;
2655 }
2656 //DMESG("returning %d",wrqu->retry.value);
2657 -
2658 +
2659  
2660 return 0;
2661 }
2662  
2663 -static int r8180_wx_get_sens(struct net_device *dev,
2664 - struct iw_request_info *info,
2665 +static int r8180_wx_get_sens(struct net_device *dev,
2666 + struct iw_request_info *info,
2667 union iwreq_data *wrqu, char *extra)
2668 {
2669 - struct r8180_priv *priv = ieee80211_priv(dev);
2670 - if(priv->rf_set_sens == NULL)
2671 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2672 + if(priv->rf_set_sens == NULL)
2673 return -1; /* we have not this support for this radio */
2674 wrqu->sens.value = priv->sens;
2675 return 0;
2676 }
2677  
2678  
2679 -static int r8180_wx_set_sens(struct net_device *dev,
2680 - struct iw_request_info *info,
2681 +static int r8180_wx_set_sens(struct net_device *dev,
2682 + struct iw_request_info *info,
2683 union iwreq_data *wrqu, char *extra)
2684 {
2685 -
2686 - struct r8180_priv *priv = ieee80211_priv(dev);
2687 -
2688 +
2689 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2690 +
2691 short err = 0;
2692 down(&priv->wx_sem);
2693 //DMESG("attempt to set sensivity to %ddb",wrqu->sens.value);
2694 @@ -571,7 +692,7 @@
2695  
2696 exit:
2697 up(&priv->wx_sem);
2698 -
2699 +
2700 return err;
2701 }
2702  
2703 @@ -623,50 +744,55 @@
2704 dummy, /* SIOCGIWRTS */
2705 r8180_wx_set_frag, /* SIOCSIWFRAG */
2706 r8180_wx_get_frag, /* SIOCGIWFRAG */
2707 - dummy, /* SIOCSIWTXPOW */
2708 - dummy, /* SIOCGIWTXPOW */
2709 + r8180_wx_set_txpow, /* SIOCSIWTXPOW */
2710 + r8180_wx_get_txpow, /* SIOCGIWTXPOW */
2711 r8180_wx_set_retry, /* SIOCSIWRETRY */
2712 r8180_wx_get_retry, /* SIOCGIWRETRY */
2713 r8180_wx_set_enc, /* SIOCSIWENCODE */
2714 r8180_wx_get_enc, /* SIOCGIWENCODE */
2715 dummy, /* SIOCSIWPOWER */
2716 dummy, /* SIOCGIWPOWER */
2717 -};
2718 +};
2719  
2720  
2721 -static const struct iw_priv_args r8180_private_args[] = {
2722 -
2723 +static const struct iw_priv_args r8180_private_args[] = {
2724 {
2725 - SIOCIWFIRSTPRIV + 0x0,
2726 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
2727 - },
2728 -
2729 + SIOCIWFIRSTPRIV + 0x0,
2730 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "fasttx"
2731 + },
2732 +
2733 {
2734 SIOCIWFIRSTPRIV + 0x1,
2735 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
2736 -
2737 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "highpower"
2738 },
2739 +
2740 {
2741 - SIOCIWFIRSTPRIV + 0x2,
2742 - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "rawtx"
2743 + SIOCIWFIRSTPRIV + 0x2,
2744 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "badcrc"
2745 + },
2746 +
2747 + {
2748 + SIOCIWFIRSTPRIV + 0x3,
2749 + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "activescan"
2750 +
2751 }
2752 };
2753  
2754  
2755 static iw_handler r8180_private_handler[] = {
2756 -// r8180_wx_set_monitor, /* SIOCIWFIRSTPRIV */
2757 + r8180_wx_set_fasttx, /* SIOCIWFIRSTPRIV */
2758 + r8180_wx_set_highpower, /*SIOCIWSECONDPRIV*/
2759 r8180_wx_set_crcmon, /*SIOCIWSECONDPRIV*/
2760 // r8180_wx_set_forceassociate,
2761 // r8180_wx_set_beaconinterval,
2762 // r8180_wx_set_monitor_type,
2763 r8180_wx_set_scan_type,
2764 - r8180_wx_set_rawtx,
2765 };
2766  
2767 -#if WIRELESS_EXT >= 17
2768 +#if WIRELESS_EXT >= 17
2769 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
2770 {
2771 - struct r8180_priv *priv = ieee80211_priv(dev);
2772 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
2773  
2774 return &priv->wstats;
2775 }
2776 @@ -679,8 +805,8 @@
2777 .private = r8180_private_handler,
2778 .num_private = sizeof(r8180_private_handler) / sizeof(iw_handler),
2779 .num_private_args = sizeof(r8180_private_args) / sizeof(struct iw_priv_args),
2780 -#if WIRELESS_EXT >= 17
2781 +#if WIRELESS_EXT >= 17
2782 .get_wireless_stats = r8180_get_wireless_stats,
2783 #endif
2784 - .private_args = (struct iw_priv_args *)r8180_private_args,
2785 + .private_args = (struct iw_priv_args *)r8180_private_args,
2786 };
2787 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c
2788 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c 2006-06-22 01:43:30.000000000 -0400
2789 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c 2008-08-12 13:11:32.000000000 -0400
2790 @@ -1,27 +1,27 @@
2791 /*
2792 This is part of rtl8187 OpenSource driver - v 0.1
2793 - Copyright (C) Andrea Merello 2005 <andreamrl@tiscali.it>
2794 + Copyright (C) Andrea Merello 2005 <andreamrl@tiscali.it>
2795 Released under the terms of GPL (General Public License)
2796 -
2797 -
2798 - Parts of this driver are based on the rtl8180 driver skeleton
2799 +
2800 +
2801 + Parts of this driver are based on the rtl8180 driver skeleton
2802 from Patric Schenke & Andres Salomon.
2803  
2804 Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers.
2805 -
2806 +
2807 some ideas might be derived from David Young rtl8180 netbsd driver.
2808 -
2809 +
2810 Parts of the usb code are from the r8150.c driver in linux kernel
2811 -
2812 +
2813 Some ideas borrowed from the 8139too.c driver included in linux kernel.
2814 -
2815 - We (I?) want to thanks the Authors of those projecs and also the
2816 +
2817 + We (I?) want to thanks the Authors of those projecs and also the
2818 Ndiswrapper's project Authors.
2819 -
2820 - A special big thanks goes also to Realtek corp. for their help in my
2821 - attempt to add RTL8187 and RTL8225 support, and to David Young also.
2822  
2823 - - Please note that this file is a modified version from rtl8180-sa2400
2824 + A special big thanks goes also to Realtek corp. for their help in my
2825 + attempt to add RTL8187 and RTL8225 support, and to David Young also.
2826 +
2827 + - Please note that this file is a modified version from rtl8180-sa2400
2828 drv. So some other people have contributed to this project, and they are
2829 thanked in the rtl8180-sa2400 CHANGELOG.
2830 */
2831 @@ -57,6 +57,7 @@
2832 #undef DEBUG_IRQ_TASKLET
2833 #undef DEBUG_TX_ALLOC
2834 #undef DEBUG_TX_DESC
2835 +#undef DEBUG_TX_POWER
2836  
2837 //#define CONFIG_RTL8180_IO_MAP
2838  
2839 @@ -66,6 +67,9 @@
2840 #include "r8180_93cx6.h" /* Card EEPROM */
2841 #include "r8180_wx.h"
2842  
2843 +#if !(defined(CONFIG_USB_EHCI_HCD) || defined (CONFIG_USB_EHCI_HCD_MODULE))
2844 + #error Build your kernel with ehci_hcd support!
2845 +#endif
2846  
2847 // FIXME: check if 2.6.7 is ok
2848 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
2849 @@ -98,6 +102,10 @@
2850 #endif
2851 static int channels = 0x3fff;
2852  
2853 +// #define DEBUG_EPROM
2854 +// #define DEBUG_REGISTERS
2855 +// #define DEBUG_TX_POWER
2856 +
2857 MODULE_LICENSE("GPL");
2858 MODULE_VERSION("V 1.1");
2859 MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl);
2860 @@ -137,7 +145,7 @@
2861  
2862 static int __devinit rtl8187_usb_probe(struct usb_interface *intf,
2863 const struct usb_device_id *id);
2864 -
2865 +
2866 static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf);
2867  
2868 static struct usb_driver rtl8187_usb_driver = {
2869 @@ -158,13 +166,12 @@
2870 #endif
2871 };
2872  
2873 -
2874 void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
2875 {
2876 -
2877 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2878 +
2879 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2880 struct usb_device *udev = priv->udev;
2881 -
2882 +
2883 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2884 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2885 indx|0xfe00, 0, &data, 1, HZ / 2);
2886 @@ -173,10 +180,10 @@
2887  
2888 void write_nic_byte(struct net_device *dev, int indx, u8 data)
2889 {
2890 -
2891 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2892 +
2893 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2894 struct usb_device *udev = priv->udev;
2895 -
2896 +
2897 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2898 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2899 indx|0xff00, 0, &data, 1, HZ / 2);
2900 @@ -185,10 +192,10 @@
2901  
2902 void write_nic_word(struct net_device *dev, int indx, u16 data)
2903 {
2904 -
2905 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2906 +
2907 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2908 struct usb_device *udev = priv->udev;
2909 -
2910 +
2911 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2912 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2913 indx|0xff00, 0, &data, 2, HZ / 2);
2914 @@ -197,23 +204,23 @@
2915  
2916 void write_nic_dword(struct net_device *dev, int indx, u32 data)
2917 {
2918 -
2919 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2920 +
2921 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2922 struct usb_device *udev = priv->udev;
2923 -
2924 +
2925 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2926 RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
2927 indx|0xff00, 0, &data, 4, HZ / 2);
2928 }
2929 -
2930 -
2931 -
2932 +
2933 +
2934 +
2935 u8 read_nic_byte(struct net_device *dev, int indx)
2936 {
2937 u8 data;
2938 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2939 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2940 struct usb_device *udev = priv->udev;
2941 -
2942 +
2943 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2944 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2945 indx|0xff00, 0, &data, 1, HZ / 2);
2946 @@ -223,22 +230,22 @@
2947 u8 read_nic_byte_E(struct net_device *dev, int indx)
2948 {
2949 u8 data;
2950 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2951 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2952 struct usb_device *udev = priv->udev;
2953 -
2954 +
2955 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2956 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2957 indx|0xfe00, 0, &data, 1, HZ / 2);
2958 return data;
2959 }
2960  
2961 -
2962 +
2963 u16 read_nic_word(struct net_device *dev, int indx)
2964 {
2965 u16 data;
2966 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2967 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2968 struct usb_device *udev = priv->udev;
2969 -
2970 +
2971 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2972 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2973 indx|0xff00, 0, &data, 2, HZ / 2);
2974 @@ -249,16 +256,16 @@
2975 u32 read_nic_dword(struct net_device *dev, int indx)
2976 {
2977 u32 data;
2978 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
2979 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
2980 struct usb_device *udev = priv->udev;
2981 -
2982 +
2983 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2984 RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
2985 indx|0xff00, 0, &data, 4, HZ / 2);
2986 return data;
2987 }
2988  
2989 -/* this might still called in what was the PHY rtl8185/rtl8187 common code
2990 +/* this might still called in what was the PHY rtl8185/rtl8187 common code
2991 * plans are to possibilty turn it again in one common code...
2992 */
2993 inline void force_pci_posting(struct net_device *dev)
2994 @@ -271,7 +278,12 @@
2995 //void set_nic_txring(struct net_device *dev);
2996 static struct net_device_stats *rtl8180_stats(struct net_device *dev);
2997 void rtl8180_commit(struct net_device *dev);
2998 +
2999 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
3000 +void rtl8180_restart(struct work_struct *work);
3001 +#else
3002 void rtl8180_restart(struct net_device *dev);
3003 +#endif
3004  
3005 /****************************************************************************
3006 -----------------------------PROCFS STUFF-------------------------
3007 @@ -284,13 +296,13 @@
3008 int *eof, void *data)
3009 {
3010 struct net_device *dev = data;
3011 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3012 -
3013 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3014 +
3015 int len = 0;
3016 int i,n;
3017 -
3018 +
3019 int max=0xff;
3020 -
3021 +
3022 /* This dump the current register page */
3023 for(n=0;n<=max;)
3024 {
3025 @@ -307,7 +319,7 @@
3026 len += snprintf(page + len, count - len,"\n");
3027  
3028  
3029 -
3030 +
3031 *eof = 1;
3032 return len;
3033  
3034 @@ -319,16 +331,16 @@
3035 int *eof, void *data)
3036 {
3037 struct net_device *dev = data;
3038 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3039 -
3040 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3041 +
3042 int len = 0;
3043 -
3044 +
3045 len += snprintf(page + len, count - len,
3046 "NIC int: %lu\n"
3047 "Total int: %lu\n",
3048 priv->stats.ints,
3049 priv->stats.shints);
3050 -
3051 +
3052 *eof = 1;
3053 return len;
3054 }
3055 @@ -339,10 +351,10 @@
3056 int *eof, void *data)
3057 {
3058 struct net_device *dev = data;
3059 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3060 -
3061 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3062 +
3063 int len = 0;
3064 -
3065 +
3066 len += snprintf(page + len, count - len,
3067 "TX normal priority ok int: %lu\n"
3068 "TX normal priority error int: %lu\n"
3069 @@ -359,7 +371,7 @@
3070 "TX HW queue: %d\n"
3071 "TX lp dropped: %lu\n"
3072 "TX np dropped: %lu\n"
3073 - "TX total data packets %lu\n",
3074 + "TX total data packets %lu\n",
3075 // "TX beacon aborted: %lu\n",
3076 priv->stats.txnpokint,
3077 priv->stats.txnperr,
3078 @@ -379,10 +391,10 @@
3079 priv->stats.txdatapkt
3080 // priv->stats.txbeaconerr
3081 );
3082 -
3083 +
3084 *eof = 1;
3085 return len;
3086 -}
3087 +}
3088  
3089  
3090  
3091 @@ -391,10 +403,10 @@
3092 int *eof, void *data)
3093 {
3094 struct net_device *dev = data;
3095 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3096 -
3097 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3098 +
3099 int len = 0;
3100 -
3101 +
3102 len += snprintf(page + len, count - len,
3103 "RX packets: %lu\n"
3104 "RX urb status error: %lu\n"
3105 @@ -402,35 +414,44 @@
3106 priv->stats.rxok,
3107 priv->stats.rxstaterr,
3108 priv->stats.rxurberr);
3109 -
3110 +
3111 *eof = 1;
3112 return len;
3113 -}
3114 -
3115 +}
3116  
3117 +#if WIRELESS_EXT < 17
3118 static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
3119 {
3120 - struct r8180_priv *priv = ieee80211_priv(dev);
3121 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3122  
3123 return &priv->wstats;
3124 }
3125 +#endif
3126  
3127 void rtl8180_proc_module_init(void)
3128 -{
3129 +{
3130 DMESG("Initializing proc filesystem");
3131 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
3132 rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net);
3133 +#else
3134 + rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, init_net.proc_net);
3135 +#endif
3136 }
3137  
3138  
3139 void rtl8180_proc_module_remove(void)
3140 {
3141 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
3142 remove_proc_entry(RTL8187_MODULE_NAME, proc_net);
3143 +#else
3144 + remove_proc_entry(RTL8187_MODULE_NAME, init_net.proc_net);
3145 +#endif
3146 }
3147  
3148  
3149 void rtl8180_proc_remove_one(struct net_device *dev)
3150 {
3151 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3152 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3153 if (priv->dir_dev) {
3154 // remove_proc_entry("stats-hw", priv->dir_dev);
3155 remove_proc_entry("stats-tx", priv->dir_dev);
3156 @@ -447,9 +468,9 @@
3157 void rtl8180_proc_init_one(struct net_device *dev)
3158 {
3159 struct proc_dir_entry *e;
3160 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3161 - priv->dir_dev = create_proc_entry(dev->name,
3162 - S_IFDIR | S_IRUGO | S_IXUGO,
3163 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3164 + priv->dir_dev = create_proc_entry(dev->name,
3165 + S_IFDIR | S_IRUGO | S_IXUGO,
3166 rtl8180_proc);
3167 if (!priv->dir_dev) {
3168 DMESGE("Unable to initialize /proc/net/rtl8187/%s\n",
3169 @@ -459,7 +480,7 @@
3170 #if 0
3171 e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
3172 priv->dir_dev, proc_get_stats_hw, dev);
3173 -
3174 +
3175 if (!e) {
3176 DMESGE("Unable to initialize "
3177 "/proc/net/rtl8187/%s/stats-hw\n",
3178 @@ -468,17 +489,17 @@
3179 #endif
3180 e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
3181 priv->dir_dev, proc_get_stats_rx, dev);
3182 -
3183 +
3184 if (!e) {
3185 DMESGE("Unable to initialize "
3186 "/proc/net/rtl8187/%s/stats-rx\n",
3187 dev->name);
3188 }
3189 -
3190 -
3191 +
3192 +
3193 e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
3194 priv->dir_dev, proc_get_stats_tx, dev);
3195 -
3196 +
3197 if (!e) {
3198 DMESGE("Unable to initialize "
3199 "/proc/net/rtl8187/%s/stats-tx\n",
3200 @@ -487,27 +508,27 @@
3201 #if 0
3202 e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
3203 priv->dir_dev, proc_get_stats_ieee, dev);
3204 -
3205 +
3206 if (!e) {
3207 DMESGE("Unable to initialize "
3208 "/proc/net/rtl8187/%s/stats-ieee\n",
3209 dev->name);
3210 }
3211 -
3212 -
3213 +
3214 +
3215 e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
3216 priv->dir_dev, proc_get_stats_ap, dev);
3217 -
3218 +
3219 if (!e) {
3220 DMESGE("Unable to initialize "
3221 "/proc/net/rtl8187/%s/stats-ap\n",
3222 dev->name);
3223 }
3224 #endif
3225 -
3226 +
3227 e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
3228 priv->dir_dev, proc_get_registers, dev);
3229 -
3230 +
3231 if (!e) {
3232 DMESGE("Unable to initialize "
3233 "/proc/net/rtl8187/%s/registers\n",
3234 @@ -523,14 +544,14 @@
3235 {
3236 int i;
3237 u8 *buf =(u8*)buffer;
3238 -
3239 +
3240 printk("ASCII BUFFER DUMP (len: %x):\n",len);
3241 -
3242 +
3243 for(i=0;i<len;i++)
3244 printk("%c",buf[i]);
3245 -
3246 +
3247 printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
3248 -
3249 +
3250 for(i=0;i<len;i++)
3251 printk("%x",buf[i]);
3252  
3253 @@ -539,17 +560,17 @@
3254  
3255 short check_nic_enought_desc(struct net_device *dev, priority_t priority)
3256 {
3257 - struct r8180_priv *priv = ieee80211_priv(dev);
3258 -
3259 - int used = atomic_read((priority == NORM_PRIORITY) ?
3260 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3261 +
3262 + int used = atomic_read((priority == NORM_PRIORITY) ?
3263 &priv->tx_np_pending : &priv->tx_lp_pending);
3264 -
3265 +
3266 return (used < MAX_TX_URB);
3267 }
3268  
3269 void tx_timeout(struct net_device *dev)
3270 {
3271 - struct r8180_priv *priv = ieee80211_priv(dev);
3272 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3273 //rtl8180_commit(dev);
3274 schedule_work(&priv->reset_wq);
3275 //DMESG("TXTIMEOUT");
3276 @@ -561,7 +582,20 @@
3277 {
3278 int i;
3279 for(i=0; i<63; i++)
3280 - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
3281 + DMESG("EEPROM addr %02X : %04X", i, eprom_read(dev,i));
3282 +}
3283 +
3284 +/* this is only for debug */
3285 +void dump_tx_power(struct net_device *dev)
3286 +{
3287 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3288 + int i;
3289 + DMESG("CCK TX-Power (b-mode):");
3290 + for(i=1; i<=14; i++)
3291 + DMESG("Channel %d: %d", i, priv->chtxpwr[i]);
3292 + DMESG("OFDM TX-Power (g-mode):");
3293 + for(i=1; i<=14; i++)
3294 + DMESG("Channel %d: %d", i, priv->chtxpwr_ofdm[i]);
3295 }
3296  
3297 /* this is only for debug */
3298 @@ -570,14 +604,14 @@
3299 int i;
3300 int n;
3301 int max=0xff;
3302 -
3303 - DMESG("Dumping NIC register map");
3304 -
3305 +
3306 + DMESG("Dumping NIC register map");
3307 +
3308 for(n=0;n<=max;)
3309 {
3310 - printk( "\nD: %2x> ", n);
3311 + printk( "\nD: %02X> ", n);
3312 for(i=0;i<16 && n<=max;i++,n++)
3313 - printk("%2x ",read_nic_byte(dev,n));
3314 + printk("%02X ",read_nic_byte(dev,n));
3315 }
3316 printk("\n");
3317 }
3318 @@ -589,11 +623,11 @@
3319  
3320 void rtl8180_irq_enable(struct net_device *dev)
3321 {
3322 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3323 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3324 //priv->irq_enabled = 1;
3325 /*
3326 - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
3327 - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
3328 + write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
3329 + INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
3330 INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
3331 INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
3332 */
3333 @@ -603,7 +637,7 @@
3334  
3335 void rtl8180_irq_disable(struct net_device *dev)
3336 {
3337 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3338 +// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3339  
3340 write_nic_word(dev,INTA_MASK,0);
3341 force_pci_posting(dev);
3342 @@ -625,115 +659,119 @@
3343  
3344 void rtl8180_update_msr(struct net_device *dev)
3345 {
3346 - struct r8180_priv *priv = ieee80211_priv(dev);
3347 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3348 u8 msr;
3349 -
3350 +
3351 msr = read_nic_byte(dev, MSR);
3352 msr &= ~ MSR_LINK_MASK;
3353 -
3354 +
3355 /* do not change in link_state != WLAN_LINK_ASSOCIATED.
3356 - * msr must be updated if the state is ASSOCIATING.
3357 + * msr must be updated if the state is ASSOCIATING.
3358 * this is intentional and make sense for ad-hoc and
3359 * master (see the create BSS/IBSS func)
3360 */
3361 - if (priv->ieee80211->state == IEEE80211_LINKED){
3362 -
3363 + if (priv->ieee80211->state == IEEE80211_LINKED){
3364 +
3365 if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
3366 msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
3367 else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
3368 msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
3369 else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
3370 msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
3371 -
3372 +
3373 }else
3374 msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
3375 -
3376 +
3377 write_nic_byte(dev, MSR, msr);
3378 }
3379  
3380 void rtl8180_set_chan(struct net_device *dev,short ch)
3381 {
3382 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3383 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3384 u32 tx;
3385 priv->chan=ch;
3386 #if 0
3387 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
3388 + if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
3389 priv->ieee80211->iw_mode == IW_MODE_MASTER){
3390 -
3391 - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
3392 +
3393 + priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
3394 priv->ieee80211->master_chan = ch;
3395 - rtl8180_update_beacon_ch(dev);
3396 + rtl8180_update_beacon_ch(dev);
3397 }
3398 #endif
3399 -
3400 +
3401 /* this hack should avoid frame TX during channel setting*/
3402 tx = read_nic_dword(dev,TX_CONF);
3403 tx &= ~TX_LOOPBACK_MASK;
3404  
3405 -#ifndef LOOP_TEST
3406 +#ifndef LOOP_TEST
3407 write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
3408 -
3409 priv->rf_set_chan(dev,priv->chan);
3410 mdelay(10);
3411 - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
3412 + write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
3413 #endif
3414 }
3415 +
3416 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3417 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs);
3418 +#else
3419 +void rtl8187_rx_isr(struct urb *rx_urb);
3420 +#endif
3421  
3422  
3423 void rtl8187_rx_urbsubmit(struct net_device *dev, struct urb* rx_urb)
3424 {
3425 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3426 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3427 int err;
3428 -
3429 +
3430 // u8 *rx;
3431 -
3432 +
3433 //DMESG("starting RX");
3434 /*rx = kmalloc(RX_URB_SIZE*sizeof(u8),GFP_ATOMIC);
3435 - if(!rx){
3436 + if(!rx){
3437 DMESGE("unable to allocate RX buffer");
3438 return;
3439 }*/
3440 -
3441 +
3442 usb_fill_bulk_urb(rx_urb,priv->udev,
3443 usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer,
3444 RX_URB_SIZE,rtl8187_rx_isr,dev);
3445 - err = usb_submit_urb(rx_urb, GFP_ATOMIC);
3446 + err = usb_submit_urb(rx_urb, GFP_ATOMIC);
3447 if(err && err != -EPERM){
3448 DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status);
3449 -
3450 +
3451 }
3452 -
3453 +
3454 }
3455  
3456  
3457 void rtl8187_rx_initiate(struct net_device *dev)
3458 {
3459 int i;
3460 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3461 -
3462 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3463 +
3464 if(!priv->rx_urb)
3465 DMESGE("Cannot intiate RX urb mechanism");
3466 - for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3467 + for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
3468 rtl8187_rx_urbsubmit(dev,priv->rx_urb[i]);
3469 -
3470 +
3471 }
3472  
3473 void rtl8187_set_rxconf(struct net_device *dev)
3474 {
3475 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3476 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3477 u32 rxconf;
3478 -
3479 +
3480 rxconf=read_nic_dword(dev,RX_CONF);
3481 rxconf = rxconf &~ MAC_FILTER_MASK;
3482 rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
3483 rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
3484 rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
3485 rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
3486 - rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3487 + rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
3488  
3489 if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
3490 -
3491 +
3492 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
3493 dev->flags & IFF_PROMISC){
3494 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3495 @@ -741,40 +779,40 @@
3496 rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
3497 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3498 }
3499 -
3500 +
3501 /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
3502 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
3503 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
3504 }*/
3505 -
3506 +
3507 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
3508 rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
3509 rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
3510 }
3511 -
3512 +
3513 if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
3514 rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
3515 -
3516 -
3517 +
3518 +
3519 rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
3520 rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
3521 -
3522 -
3523 +
3524 +
3525 rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
3526 -
3527 +
3528 rxconf = rxconf &~ MAX_RX_DMA_MASK;
3529 rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
3530 -
3531 +
3532 rxconf = rxconf | RCR_ONLYERLPKT;
3533 -
3534 +
3535 // rxconf = rxconf &~ RCR_CS_MASK;
3536 // rxconf = rxconf | (1<<RCR_CS_SHIFT);
3537  
3538 - write_nic_dword(dev, RX_CONF, rxconf);
3539 -
3540 + write_nic_dword(dev, RX_CONF, rxconf);
3541 +
3542 // V rtl suggested V //
3543 // write_nic_dword(dev, RX_CONF, 0x901ce70e);
3544 -
3545 +
3546 //fix_rx_fifo(dev);
3547 // //set_nic_rxring(dev);
3548 #ifdef DEBUG_RX
3549 @@ -785,23 +823,23 @@
3550 void rtl8180_rx_enable(struct net_device *dev)
3551 {
3552 u8 cmd;
3553 -
3554 -
3555 +
3556 +
3557 rtl8187_rx_initiate(dev);
3558  
3559 - rtl8187_set_rxconf(dev);
3560 + rtl8187_set_rxconf(dev);
3561  
3562 cmd=read_nic_byte(dev,CMD);
3563 write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
3564 #if 0
3565 - /* In rtl8139 driver seems that DMA threshold has to be written
3566 - * after enabling RX, so we rewrite RX_CONFIG register
3567 + /* In rtl8139 driver seems that DMA threshold has to be written
3568 + * after enabling RX, so we rewrite RX_CONFIG register
3569 */
3570 //mdelay(100);
3571 - write_nic_dword(dev, RX_CONF, rxconf);
3572 -
3573 + write_nic_dword(dev, RX_CONF, rxconf);
3574 +
3575 #endif
3576 -
3577 +
3578 }
3579  
3580  
3581 @@ -810,37 +848,37 @@
3582 u8 cmd;
3583 u8 byte;
3584 u32 txconf;
3585 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3586 -
3587 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3588 +
3589 byte = read_nic_byte(dev,CW_CONF);
3590 byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
3591 byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
3592 write_nic_byte(dev, CW_CONF, byte);
3593 -
3594 +
3595 byte = read_nic_byte(dev, TX_AGC_CTL);
3596 byte &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
3597 byte &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
3598 byte &= ~(1<<TX_AGC_CTL_FEEDBACK_ANT);
3599 write_nic_byte(dev, TX_AGC_CTL, byte);
3600 -
3601 +
3602 txconf= read_nic_dword(dev,TX_CONF);
3603 -
3604 +
3605 #if 0
3606 if(priv->card_8185){
3607 -
3608 +
3609 txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
3610 -
3611 +
3612 }else{
3613 -
3614 - if(priv->ieee80211->hw_seq)
3615 +
3616 + if(priv->ieee80211->hw_seq)
3617 txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3618 - else
3619 + else
3620 txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
3621 }
3622 #endif
3623  
3624 txconf = txconf &~ TX_LOOPBACK_MASK;
3625 -
3626 +
3627 #ifndef LOOP_TEST
3628 txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
3629 #else
3630 @@ -848,23 +886,26 @@
3631 #endif
3632 txconf = txconf &~ TCR_DPRETRY_MASK;
3633 txconf = txconf &~ TCR_RTSRETRY_MASK;
3634 -
3635 - txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3636 - txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3637 -
3638 +
3639 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR)
3640 + {
3641 + txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
3642 + txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
3643 + }
3644 +
3645 txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
3646 -
3647 +
3648 txconf = txconf &~ TCR_MXDMA_MASK;
3649 txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
3650 -
3651 +
3652 txconf = txconf | TCR_CWMIN;
3653 txconf = txconf | TCR_DISCW;
3654 txconf = txconf &~ TCR_SWPLCPLEN;
3655 -
3656 +
3657 txconf=txconf | (1<<TX_NOICV_SHIFT);
3658 -
3659 +
3660 write_nic_dword(dev,TX_CONF,txconf);
3661 -
3662 +
3663 // V RTL suggested V //
3664 // write_nic_dword(dev,TX_CONF,0x00e00707);
3665  
3666 @@ -872,9 +913,9 @@
3667 #ifdef DEBUG_TX
3668 DMESG("txconf: %x %x",txconf,read_nic_dword(dev,TX_CONF));
3669 #endif
3670 -
3671 +
3672 cmd=read_nic_byte(dev,CMD);
3673 - write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3674 + write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
3675  
3676 // mdelay(100);
3677 //write_nic_dword(dev,TX_CONF,txconf);
3678 @@ -889,18 +930,18 @@
3679 #if 0
3680 void rtl8180_beacon_tx_enable(struct net_device *dev)
3681 {
3682 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3683 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3684 priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
3685 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3686 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3687 + write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3688 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
3689 }
3690  
3691  
3692 void rtl8180_
3693 -_disable(struct net_device *dev)
3694 +_disable(struct net_device *dev)
3695 {
3696 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3697 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3698 priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
3699 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3700 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3701 @@ -914,8 +955,8 @@
3702 {
3703 u8 cmd;
3704 int i;
3705 - struct r8180_priv *priv = ieee80211_priv(dev);
3706 -
3707 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3708 +
3709 cmd=read_nic_byte(dev,CMD);
3710 write_nic_byte(dev, CMD, cmd &~ \
3711 ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT)));
3712 @@ -926,9 +967,9 @@
3713 usb_kill_urb(priv->rx_urb[i]);
3714 }
3715 /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT))
3716 - udelay(10);
3717 + udelay(10);
3718 */
3719 -
3720 +
3721 // if(!priv->rx_skb_complete)
3722 // dev_kfree_skb_any(priv->rx_skb);
3723 }
3724 @@ -939,14 +980,14 @@
3725 #if 0
3726 int i;
3727 u32 *tmp;
3728 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3729 -
3730 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3731 +
3732 priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
3733 - sizeof(u32)*8*count,
3734 + sizeof(u32)*8*count,
3735 &priv->txbeaconringdma);
3736 if (!priv->txbeaconring) return -1;
3737 for (tmp=priv->txbeaconring,i=0;i<count;i++){
3738 - *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3739 + *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
3740 /*
3741 *(tmp+2) = (u32)dma_tmp;
3742 *(tmp+3) = bufsize;
3743 @@ -955,7 +996,7 @@
3744 *(tmp+4) = (u32)priv->txbeaconringdma+((i+1)*8*4);
3745 else
3746 *(tmp+4) = (u32)priv->txbeaconringdma;
3747 -
3748 +
3749 tmp=tmp+8;
3750 }
3751 #endif
3752 @@ -965,15 +1006,15 @@
3753  
3754 void rtl8180_reset(struct net_device *dev)
3755 {
3756 -
3757 +
3758 u8 cr;
3759 -
3760 +
3761 /* make sure the analog power is on before
3762 * reset, otherwise reset may fail
3763 */
3764 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3765 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3766 -
3767 +
3768 rtl8180_irq_disable(dev);
3769  
3770 mdelay(200);
3771 @@ -981,19 +1022,19 @@
3772 write_nic_byte_E(dev,0x18,0x11);
3773 write_nic_byte_E(dev,0x18,0x00);
3774 mdelay(200);
3775 -
3776 +
3777 cr=read_nic_byte(dev,CMD);
3778 cr = cr & 2;
3779 cr = cr | (1<<CMD_RST_SHIFT);
3780 write_nic_byte(dev,CMD,cr);
3781 -
3782 +
3783 force_pci_posting(dev);
3784 -
3785 +
3786 mdelay(200);
3787 -
3788 - if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3789 +
3790 + if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
3791 DMESGW("Card reset timeout!");
3792 - else
3793 + else
3794 DMESG("Card successfully reset");
3795  
3796 rtl8180_set_mode(dev,EPROM_CMD_LOAD);
3797 @@ -1005,13 +1046,13 @@
3798 */
3799 rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
3800 rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
3801 -
3802 +
3803 }
3804  
3805 inline u16 ieeerate2rtlrate(int rate)
3806 {
3807 switch(rate){
3808 - case 10:
3809 + case 10:
3810 return 0;
3811 case 20:
3812 return 1;
3813 @@ -1037,32 +1078,42 @@
3814 return 11;
3815 default:
3816 return 3;
3817 -
3818 +
3819 }
3820 }
3821 static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
3822 inline u16 rtl8180_rate2rate(short rate)
3823 {
3824 if (rate >11) return 0;
3825 - return rtl_rate[rate];
3826 + return rtl_rate[rate];
3827 +}
3828 +
3829 +inline u8 rtl8180_IsWirelessBMode(u16 rate)
3830 +{
3831 + if( ((rate <= 110) && (rate != 60) && (rate != 90)) || (rate == 220) )
3832 + return 1;
3833 + else return 0;
3834 }
3835 -
3836  
3837 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
3838 void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs)
3839 +#else
3840 +void rtl8187_rx_isr(struct urb *rx_urb)
3841 +#endif
3842 {
3843 struct net_device *dev = (struct net_device*)rx_urb->context;
3844 - struct r8180_priv *priv = ieee80211_priv(dev);
3845 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
3846  
3847 priv->rxurb_task = rx_urb;
3848 // DMESGW("David: Rx tasklet start!");
3849 - tasklet_schedule(&priv->irq_rx_tasklet);
3850 + tasklet_schedule(&priv->irq_rx_tasklet);
3851 // DMESGW("=David: Rx tasklet finish!");
3852 }
3853  
3854 #if 0
3855 void rtl8180_tx_queues_stop(struct net_device *dev)
3856 {
3857 - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3858 + //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3859 u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3860 dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
3861 dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
3862 @@ -1078,7 +1129,7 @@
3863 {
3864 //FIXME !!
3865 #if 0
3866 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3867 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3868 priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3869 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3870 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3871 @@ -1091,7 +1142,7 @@
3872 {
3873 // FIXME !!
3874 #if 0
3875 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3876 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3877 priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
3878 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
3879 write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
3880 @@ -1105,14 +1156,19 @@
3881 */
3882 void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
3883 {
3884 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3885 -
3886 - short morefrag = 0;
3887 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3888 +
3889 + short morefrag = 0;
3890 unsigned long flags;
3891 struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data;
3892  
3893 - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3894 - morefrag = 1;
3895 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->ieee80211->raw_tx != 1)
3896 + {
3897 + if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
3898 + {
3899 + morefrag = 1;
3900 + }
3901 + }
3902 // DMESG("%x %x", h->frame_ctl, h->seq_ctl);
3903 /*
3904 * This function doesn't require lock because we make
3905 @@ -1121,24 +1177,29 @@
3906 * the ieee stack, or from the try_wake_queue (again trought
3907 * the ieee stack.
3908 */
3909 - spin_lock_irqsave(&priv->tx_lock,flags);
3910 -
3911 - //DMESG("TX");
3912 - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3913 - DMESG("Error: no TX slot ");
3914 - ieee80211_stop_queue(priv->ieee80211);
3915 - }
3916 -
3917 - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3918 - ieeerate2rtlrate(rate));
3919 -
3920 - priv->stats.txdatapkt++;
3921 -
3922 - if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3923 - ieee80211_stop_queue(priv->ieee80211);
3924 -
3925 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3926 -
3927 +
3928 + if(priv->ieee80211->iw_mode != IW_MODE_MONITOR || priv->fasttx == 0)
3929 + {
3930 + spin_lock_irqsave(&priv->tx_lock,flags);
3931 + //DMESG("TX");
3932 + if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
3933 + DMESG("Error: no TX slot ");
3934 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3935 + }
3936 + rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
3937 + ieeerate2rtlrate(rate));
3938 +
3939 + priv->stats.txdatapkt++;
3940 +
3941 + if (!check_nic_enought_desc(dev, LOW_PRIORITY))
3942 + ieee80211_stop_queue_rtl7(priv->ieee80211);
3943 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3944 + }
3945 + else
3946 + {
3947 + rtl8180_tx_fast(dev, (u32*)skb->data, skb->len, ieeerate2rtlrate(rate));
3948 + }
3949 +
3950 }
3951 #if 0
3952 /* This is a rough attempt to TX a frame
3953 @@ -1148,12 +1209,12 @@
3954 */
3955 int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
3956 {
3957 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
3958 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
3959 int ret;
3960 unsigned long flags;
3961 -
3962 +
3963 spin_lock_irqsave(&priv->tx_lock,flags);
3964 -
3965 +
3966 ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE);
3967 /*
3968 int i;
3969 @@ -1163,9 +1224,9 @@
3970 */
3971 priv->ieee80211->stats.tx_bytes+=skb->len;
3972 priv->ieee80211->stats.tx_packets++;
3973 -
3974 - spin_unlock_irqrestore(&priv->tx_lock,flags);
3975 -
3976 +
3977 + spin_unlock_irqrestore(&priv->tx_lock,flags);
3978 +
3979 dev_kfree_skb_any(skb);
3980 return ret;
3981 }
3982 @@ -1178,7 +1239,7 @@
3983 u16 duration;
3984 u16 drift;
3985 *ext=0;
3986 -
3987 +
3988 switch(rate){
3989 case 0://1mbps
3990 *ext=0;
3991 @@ -1187,7 +1248,7 @@
3992 if(drift ==0 ) break;
3993 duration++;
3994 break;
3995 -
3996 +
3997 case 1://2mbps
3998 *ext=0;
3999 duration = ((len+4)<<4) /0x4;
4000 @@ -1195,40 +1256,44 @@
4001 if(drift ==0 ) break;
4002 duration++;
4003 break;
4004 -
4005 +
4006 case 2: //5.5mbps
4007 *ext=0;
4008 duration = ((len+4)<<4) /0xb;
4009 drift = ((len+4)<<4) % 0xb;
4010 - if(drift ==0 )
4011 + if(drift ==0 )
4012 break;
4013 duration++;
4014 break;
4015 -
4016 +
4017 default:
4018 - case 3://11mbps
4019 + case 3://11mbps
4020 *ext=0;
4021 duration = ((len+4)<<4) /0x16;
4022 drift = ((len+4)<<4) % 0x16;
4023 - if(drift ==0 )
4024 + if(drift ==0 )
4025 break;
4026 duration++;
4027 - if(drift > 6)
4028 + if(drift > 6)
4029 break;
4030 *ext=1;
4031 break;
4032 }
4033 -
4034 +
4035 return duration;
4036 }
4037 #endif
4038  
4039 void rtl8180_try_wake_queue(struct net_device *dev, int pri);
4040  
4041 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
4042 void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs)
4043 +#else
4044 +void rtl8187_lptx_isr(struct urb *tx_urb)
4045 +#endif
4046 {
4047 struct net_device *dev = (struct net_device*)tx_urb->context;
4048 - struct r8180_priv *priv = ieee80211_priv(dev);
4049 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4050 if(tx_urb->status == 0)
4051 priv->stats.txlpokint++;
4052 else
4053 @@ -1239,6 +1304,15 @@
4054 rtl8180_try_wake_queue(dev,LOW_PRIORITY);
4055 }
4056  
4057 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
4058 +void rtl8187_lptx_isr_fast(struct urb *tx_urb, struct pt_regs *regs)
4059 +#else
4060 +void rtl8187_lptx_isr_fast(struct urb *tx_urb)
4061 +#endif
4062 +{
4063 + kfree(tx_urb->transfer_buffer);
4064 + usb_free_urb(tx_urb);
4065 +}
4066  
4067 void rtl8187_beacon_stop(struct net_device *dev)
4068 {
4069 @@ -1249,55 +1323,55 @@
4070 if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
4071 (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
4072 write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
4073 - write_nic_byte(dev, MSR, msr);
4074 + write_nic_byte(dev, MSR, msr);
4075 }
4076 -
4077 -
4078 +
4079 +
4080 }
4081  
4082  
4083 void rtl8187_net_update(struct net_device *dev)
4084 {
4085  
4086 - struct r8180_priv *priv = ieee80211_priv(dev);
4087 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4088 struct ieee80211_network *net;
4089 net = & priv->ieee80211->current_network;
4090 -
4091 -
4092 +
4093 +
4094 write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]);
4095 write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]);
4096 //for(i=0;i<ETH_ALEN;i++)
4097 // write_nic_byte(dev,BSSID+i,net->bssid[i]);
4098  
4099 rtl8180_update_msr(dev);
4100 -
4101 +
4102 // rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
4103 write_nic_word(dev, AtimWnd, 2);
4104 - write_nic_word(dev, AtimtrItv, 100);
4105 + write_nic_word(dev, AtimtrItv, 100);
4106 write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval);
4107 write_nic_word(dev, BcnIntTime, 100);
4108 -
4109 +
4110  
4111 }
4112  
4113 void rtl8187_beacon_tx(struct net_device *dev)
4114 {
4115  
4116 - struct r8180_priv *priv = ieee80211_priv(dev);
4117 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4118 struct sk_buff *skb;
4119 int i = 0;
4120 -
4121 +
4122 rtl8187_net_update(dev);
4123 -
4124 - skb = ieee80211_get_beacon(priv->ieee80211);
4125 -
4126 -
4127 - if(!skb){
4128 +
4129 + skb = ieee80211_get_beacon_rtl7(priv->ieee80211);
4130 +
4131 +
4132 + if(!skb){
4133 DMESG("not enought memory for allocating beacon");
4134 return;
4135 }
4136 -
4137 -#if 0
4138 +
4139 +#if 0
4140 while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){
4141 msleep_interruptible_rtl(HZ/2);
4142 if(i++ > 20){
4143 @@ -1307,7 +1381,7 @@
4144 }
4145 #endif
4146 write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7));
4147 -
4148 +
4149 i=0;
4150 //while(!read_nic_byte(dev,BQREQ & (1<<7)))
4151 while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 )
4152 @@ -1318,16 +1392,20 @@
4153 return ;
4154 }
4155 }
4156 -
4157 +
4158 rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY,
4159 0, priv->ieee80211->basic_rate);
4160 -
4161 +
4162 }
4163  
4164 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
4165 void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs)
4166 +#else
4167 +void rtl8187_nptx_isr(struct urb *tx_urb)
4168 +#endif
4169 {
4170 struct net_device *dev = (struct net_device*)tx_urb->context;
4171 - struct r8180_priv *priv = ieee80211_priv(dev);
4172 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4173 if(tx_urb->status == 0)
4174 priv->stats.txnpokint++;
4175 else
4176 @@ -1339,10 +1417,10 @@
4177 }
4178  
4179  
4180 -/* This function do the real dirty work: it sends a TX command
4181 - * descriptor plus data URB
4182 +/* This function do the real dirty work: it sends a TX command
4183 + * descriptor plus data URB
4184 */
4185 -
4186 +
4187 short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority,
4188 short morefrag, short rate)
4189 {
4190 @@ -1352,12 +1430,12 @@
4191 int pend ;
4192 int status;
4193 struct urb *tx_urb;
4194 - int urb_len;
4195 - struct r8180_priv *priv = ieee80211_priv(dev);
4196 + int urb_len;
4197 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4198 // int rate = ieeerate2rtlrate(priv->ieee80211->rate);
4199  
4200 - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
4201 - /* we are locked here so the two atomic_read and inc are executed without interleaves */
4202 + pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
4203 + /* we are locked here so the two atomic_read and inc are executed without interleaves */
4204 if( pend > MAX_TX_URB){
4205 if(priority == NORM_PRIORITY)
4206 priv->stats.txnpdrop++;
4207 @@ -1365,52 +1443,38 @@
4208 priv->stats.txlpdrop++;
4209 return -1;
4210 }
4211 -
4212 -
4213 +
4214 //tx = kmalloc((len + 4*3), GFP_ATOMIC);
4215 urb_len = len + 4*3;
4216 if((0 == urb_len%64)||(0 == urb_len%512)) {
4217 - urb_len += 1;
4218 + urb_len += 1;
4219 }
4220 tx = kmalloc(urb_len, GFP_ATOMIC);
4221 if(!tx) return -ENOMEM;
4222 - //printk(KERN_WARNING "urb_len = %d\n", urb_len);
4223 + //printk(KERN_WARNING "urb_len = %d\n", urb_len);
4224 tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
4225 -
4226 +
4227 if(!tx_urb){
4228 -
4229 +
4230 kfree(tx);
4231 return -ENOMEM;
4232 }
4233 -
4234 +
4235 memcpy(tx+3,txbuf,len);
4236 tx[0] = 0;
4237 tx[0] |= len & 0xfff;
4238 tx[0] |= (1<<15);
4239 -
4240 -// if(priv->shortpre)
4241 -// tx[0] |= (1<<16);
4242 -
4243 - //if(len > priv->rts_threshold){
4244 -// tx[0] |= (1<<23); //ENABLE RTS
4245 -// tx[0] |= (1<<18); //ENABLE CTS
4246 - //}
4247 +
4248 if(morefrag) tx[0] |= (1<<17);
4249 tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
4250 tx[0] |= (rate << 24);
4251 tx[1] = 0;
4252 -
4253 -// duration = rtl8180_len2duration(len,
4254 -// rate,&ext);
4255 -// tx[1] |= (duration & 0x7fff) <<16;
4256 -// if(ext) tx[1] |= (1<<31);
4257  
4258 -
4259 // tx[2] = 0x303020;
4260 tx[2] = 3; // CW min
4261 tx[2] |= (7<<4); //CW max
4262 tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim
4263 -
4264 +
4265 // printk("%x\n%x\n",tx[0],tx[1]);
4266  
4267 #ifdef DUMP_TX
4268 @@ -1421,7 +1485,7 @@
4269 printk("---------------\n");
4270 #endif
4271  
4272 -
4273 +
4274 /* FIXME check what EP is for low/norm PRI */
4275 usb_fill_bulk_urb(tx_urb,priv->udev,
4276 usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx,
4277 @@ -1438,54 +1502,97 @@
4278 }
4279 }
4280  
4281 -
4282 +/* This function do the real dirty work: it sends a TX command
4283 + * descriptor plus data URB (fast)
4284 + */
4285 +
4286 +short rtl8180_tx_fast(struct net_device *dev, u32* txbuf, int len, short rate)
4287 +{
4288 + u32 *tx;
4289 + int status;
4290 + struct urb *tx_urb;
4291 + int urb_len;
4292 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4293 +
4294 + urb_len = len + 4*3;
4295 + if((0 == urb_len%64)||(0 == urb_len%512)) {
4296 + urb_len += 1;
4297 + }
4298 + tx = kmalloc(urb_len, GFP_ATOMIC);
4299 + if(!tx) return -ENOMEM;
4300 +
4301 + tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
4302 +
4303 + if(!tx_urb){
4304 + kfree(tx);
4305 + return -ENOMEM;
4306 + }
4307 +
4308 + memcpy(tx+3,txbuf,len);
4309 + tx[0] = (len & 0xfff) + 0x8000;
4310 + tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
4311 + tx[0] |= (rate << 24);
4312 + tx[1] = 0;
4313 + tx[2] = 2931;
4314 +
4315 + /* FIXME check what EP is for low/norm PRI */
4316 + usb_fill_bulk_urb(tx_urb,priv->udev,
4317 + usb_sndbulkpipe(priv->udev, 2), tx, urb_len, rtl8187_lptx_isr_fast, dev);
4318 + status = usb_submit_urb(tx_urb, GFP_ATOMIC);
4319 + if (!status){
4320 + return 0;
4321 + }else{
4322 + return -1;
4323 + }
4324 +}
4325 +
4326  
4327 void rtl8180_irq_rx_tasklet(struct r8180_priv * priv);
4328  
4329  
4330 short rtl8187_usb_initendpoints(struct net_device *dev)
4331 {
4332 - struct r8180_priv *priv = ieee80211_priv(dev);
4333 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4334 int i;
4335 -
4336 +
4337 priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL);
4338 -
4339 +
4340 for(i=0;i<MAX_RX_URB;i++){
4341 priv->rx_urb[i] = usb_alloc_urb(0,GFP_KERNEL);
4342 - if(!priv->rx_urb[i])
4343 + if(!priv->rx_urb[i])
4344 goto destroy;
4345 -
4346 +
4347 priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
4348 - if(!priv->rx_urb[i]->transfer_buffer)
4349 + if(!priv->rx_urb[i]->transfer_buffer)
4350 goto destroy1;
4351 -
4352 +
4353 priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
4354 }
4355 -
4356 +
4357 return 0;
4358 -
4359 +
4360 destroy1:
4361 usb_free_urb(priv->rx_urb[i]);
4362 -
4363 +
4364 destroy:
4365 while (--i >= 0){
4366 kfree(priv->rx_urb[i]->transfer_buffer);
4367 usb_free_urb(priv->rx_urb[i]);
4368 }
4369 -
4370 +
4371 kfree(priv->rx_urb);
4372 -
4373 +
4374 priv->rx_urb = NULL;
4375 DMESGE("Endpoint Alloc Failure");
4376 return -ENOMEM;
4377 -
4378 +
4379 }
4380  
4381 void rtl8187_usb_deleteendpoints(struct net_device *dev)
4382 {
4383 - struct r8180_priv *priv = ieee80211_priv(dev);
4384 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4385 int i;
4386 -
4387 +
4388 if(priv->rx_urb){
4389 for(i=0;i<MAX_RX_URB;i++){
4390 usb_kill_urb(priv->rx_urb[i]);
4391 @@ -1494,9 +1601,9 @@
4392 }
4393 kfree(priv->rx_urb);
4394 priv->rx_urb = NULL;
4395 -
4396 +
4397 }
4398 -
4399 +
4400 }
4401  
4402  
4403 @@ -1505,16 +1612,16 @@
4404 int i;
4405 u16 word;
4406 int basic_rate,min_rr_rate,max_rr_rate;
4407 -
4408 -// struct r8180_priv *priv = ieee80211_priv(dev);
4409 -
4410 - //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
4411 +
4412 +// struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4413 +
4414 + //if (ieee80211_is_54g_rtl7(priv->ieee80211->current_network) &&
4415 // priv->ieee80211->state == IEEE80211_LINKED){
4416 basic_rate = ieeerate2rtlrate(240);
4417 min_rr_rate = ieeerate2rtlrate(60);
4418 max_rr_rate = ieeerate2rtlrate(240);
4419 -
4420 -//
4421 +
4422 +//
4423 // }else{
4424 // basic_rate = ieeerate2rtlrate(20);
4425 // min_rr_rate = ieeerate2rtlrate(10);
4426 @@ -1526,21 +1633,21 @@
4427  
4428 word = read_nic_word(dev, BRSR);
4429 word &= ~BRSR_MBR_8185;
4430 -
4431 +
4432  
4433 for(i=0;i<=basic_rate;i++)
4434 word |= (1<<i);
4435  
4436 write_nic_word(dev, BRSR, word);
4437 - //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
4438 + DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
4439 }
4440  
4441  
4442 void rtl8187_link_change(struct net_device *dev)
4443 {
4444 // int i;
4445 -
4446 - struct r8180_priv *priv = ieee80211_priv(dev);
4447 +
4448 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4449 //write_nic_word(dev, BintrItv, net->beacon_interval);
4450 rtl8187_net_update(dev);
4451 /*update timing params*/
4452 @@ -1553,24 +1660,24 @@
4453  
4454 short rtl8180_init(struct net_device *dev)
4455 {
4456 -
4457 - struct r8180_priv *priv = ieee80211_priv(dev);
4458 +
4459 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4460 int i, j;
4461 u16 word;
4462 - int ch;
4463 + int ch, chans;
4464 //u16 version;
4465 - //u8 hw_version;
4466 - //u8 config3;
4467 -
4468 + u8 hw_version;
4469 + u8 config3;
4470 +
4471 //FIXME: these constants are placed in a bad pleace.
4472  
4473 // priv->txbuffsize = 1024;
4474 // priv->txringcount = 32;
4475 // priv->rxbuffersize = 1024;
4476 -// priv->rxringcount = 32;
4477 +// priv->rxringcount = 32;
4478 // priv->txbeaconcount = 3;
4479 // priv->rx_skb_complete = 1;
4480 - //priv->txnp_pending.ispending=0;
4481 + //priv->txnp_pending.ispending=0;
4482 /* ^^ the SKB does not containt a partial RXed
4483 * packet (is empty)
4484 */
4485 @@ -1580,15 +1687,24 @@
4486 return -1;
4487 }
4488 ch=channels;
4489 + chans=0;
4490 + for (i=1; i<=14; i++) {
4491 + if( (u8)(ch & 0x01) ) chans++;
4492 + ch >>= 1;
4493 + }
4494 + DMESG("Enabling %d channels.", chans);
4495 + ch=channels;
4496 // set channels 1..14 allowed in given locale
4497 for (i=1; i<=14; i++) {
4498 (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
4499 ch >>= 1;
4500 }
4501 //memcpy(priv->stats,0,sizeof(struct Stats));
4502 -
4503 +
4504 //priv->irq_enabled=0;
4505 -
4506 +
4507 + priv->dev = dev;
4508 +
4509 // priv->stats.rxdmafail=0;
4510 priv->stats.txrdu=0;
4511 // priv->stats.rxrdu=0;
4512 @@ -1612,33 +1728,37 @@
4513 // priv->stats.txbeaconerr=0;
4514 priv->stats.txlperr=0;
4515 priv->stats.txlpokint=0;
4516 -
4517 +
4518 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4519 -
4520 +
4521 priv->retry_rts = DEFAULT_RETRY_RTS;
4522 priv->retry_data = DEFAULT_RETRY_DATA;
4523 priv->ieee80211->rate = 110; //11 mbps
4524 priv->ieee80211->short_slot = 1;
4525 - priv->ieee80211->mode = IEEE_G;
4526 + priv->ieee80211->mode = IEEE_G|IEEE_B;
4527 priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
4528 spin_lock_init(&priv->tx_lock);
4529 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
4530 INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev);
4531 +#else
4532 + INIT_WORK(&priv->reset_wq, rtl8180_restart);
4533 +#endif
4534 sema_init(&priv->wx_sem,1);
4535 tasklet_init(&priv->irq_rx_tasklet,
4536 (void(*)(unsigned long))rtl8180_irq_rx_tasklet,
4537 (unsigned long)priv);
4538  
4539 - //priv->ieee80211->func =
4540 + //priv->ieee80211->func =
4541 // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL);
4542 //memset(priv->ieee80211->func, 0,
4543 // sizeof(struct ieee80211_helper_functions));
4544 - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4545 + priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
4546 priv->ieee80211->iw_mode = IW_MODE_INFRA;
4547 - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4548 - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4549 + priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
4550 + IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
4551 IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
4552 /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE;
4553 -
4554 +
4555 priv->ieee80211->active_scan = 1;
4556 priv->ieee80211->rate = 110; //11 mbps
4557 priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
4558 @@ -1655,51 +1775,51 @@
4559 priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume;
4560 //priv->ieee80211->start_send_beacons = NULL;
4561 //priv->ieee80211->stop_send_beacons = NULL;
4562 -
4563 +
4564 priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
4565 -
4566 +
4567 priv->card_8185 = 2;
4568 priv->phy_ver = 2;
4569 priv->card_type = USB;
4570 -
4571 +
4572 #if 0
4573 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4574 -
4575 +
4576 switch (hw_version){
4577 case HW_VERID_R8185_ABC:
4578 - DMESG("MAC controller is a RTL8185 b/g");
4579 + DMESG("MAC controller is a RTL8185 b/g");
4580 priv->card_8185 = 1;
4581 /* you should not find a card with 8225 PHY ver < C*/
4582 priv->phy_ver = 2;
4583 break;
4584 -
4585 +
4586 case HW_VERID_R8185_D:
4587 - DMESG("MAC controller is a RTL8185 b/g (V. D)");
4588 + DMESG("MAC controller is a RTL8185 b/g (V. D)");
4589 priv->card_8185 = 2;
4590 /* you should not find a card with 8225 PHY ver < C*/
4591 priv->phy_ver = 2;
4592 break;
4593 -
4594 +
4595 case HW_VERID_R8180_ABCD:
4596 DMESG("MAC controller is a RTL8180");
4597 priv->card_8185 = 0;
4598 break;
4599 -
4600 +
4601 case HW_VERID_R8180_F:
4602 DMESG("MAC controller is a RTL8180 (v. F)");
4603 priv->card_8185 = 0;
4604 break;
4605 -
4606 +
4607 default:
4608 DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
4609 priv->card_8185 = 0;
4610 break;
4611 }
4612 -
4613 -
4614 +
4615 +
4616 /* you should not found any 8185 Ver B Card */
4617 priv->card_8185_Bversion = 0;
4618 -
4619 +
4620 config3 = read_nic_byte(dev, CONFIG3);
4621 if(config3 & 0x8){
4622 priv->card_type = CARDBUS;
4623 @@ -1715,13 +1835,19 @@
4624 #endif
4625 priv->enable_gpio0 = 0;
4626  
4627 -
4628 +
4629 + hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
4630 + config3 = read_nic_byte(dev, CONFIG3);
4631 +
4632 + DMESG("MAC chip version: %02X", hw_version);
4633 + DMESG("Card type: %02X", config3);
4634 +
4635 /* commented out just because we already do
4636 this when resetting the card
4637 andrea 20050924
4638 */
4639 #if 0
4640 -
4641 +
4642 u8 txcr, txreg50;
4643 u32 txreg54, txreg60;
4644  
4645 @@ -1757,8 +1883,8 @@
4646 // DMESG("<<txcr:%x>>", txcr);
4647  
4648 #endif
4649 -
4650 - /*the eeprom type is stored in RCR register bit #6 */
4651 +
4652 + /*the eeprom type is stored in RCR register bit #6 */
4653 if (RCR_9356SEL & read_nic_dword(dev, RCR)){
4654 priv->epromtype=EPROM_93c56;
4655 DMESG("Reported EEPROM chip is a 93c56 (2Kbit)");
4656 @@ -1766,58 +1892,73 @@
4657 priv->epromtype=EPROM_93c46;
4658 DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
4659 }
4660 -
4661 +
4662 dev->get_stats = rtl8180_stats;
4663 -
4664 +
4665 dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
4666 dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
4667 dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
4668 dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
4669 dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
4670 dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
4671 -
4672 +
4673 DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr));
4674 -
4675 +
4676 for(i=1,j=0; i<6; i+=2,j++){
4677 -
4678 +
4679 word = eprom_read(dev,EPROM_TXPW0 + j);
4680 priv->chtxpwr[i]=word & 0xf;
4681 priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4;
4682 priv->chtxpwr[i+1]=(word & 0xf00)>>8;
4683 priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12;
4684 }
4685 -
4686 +
4687 for(i=1,j=0; i<4; i+=2,j++){
4688 -
4689 +
4690 word = eprom_read(dev,EPROM_TXPW1 + j);
4691 priv->chtxpwr[i+6]=word & 0xf;
4692 priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4;
4693 priv->chtxpwr[i+6+1]=(word & 0xf00)>>8;
4694 priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12;
4695 }
4696 -
4697 +
4698 for(i=1,j=0; i<4; i+=2,j++){
4699 -
4700 +
4701 word = eprom_read(dev,EPROM_TXPW2 + j);
4702 priv->chtxpwr[i+6+4]=word & 0xf;
4703 priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4;
4704 priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8;
4705 priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12;
4706 }
4707 -
4708 -
4709 +
4710 +
4711 priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID);
4712 -
4713 +
4714 +#ifdef DEBUG_TX_POWER
4715 + dump_tx_power(dev);
4716 +#endif
4717 +
4718 + DMESG("RF Chip ID: %02X", priv->rf_chip);
4719 +
4720 word = eprom_read(dev,EPROM_TXPW_BASE);
4721 priv->cck_txpwr_base = word & 0xf;
4722 priv->ofdm_txpwr_base = (word>>4) & 0xf;
4723 -
4724 +
4725 + priv->txpwr_max = 0;
4726 + for(i=1; i<15; i++)
4727 + {
4728 + if(priv->chtxpwr[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr[i];
4729 + if(priv->chtxpwr_ofdm[i] > priv->txpwr_max) priv->txpwr_max = priv->chtxpwr_ofdm[i];
4730 + priv->chtxpwr_orig[i] = priv->chtxpwr[i];
4731 + priv->chtxpwr_ofdm_orig[i] = priv->chtxpwr_ofdm[i];
4732 + }
4733 +
4734 /* check RF frontend chipset */
4735 -
4736 +
4737 switch (priv->rf_chip) {
4738 -
4739 +
4740 case EPROM_RFCHIPID_RTL8225U:
4741 -
4742 +
4743 DMESG("Card reports RF frontend Realtek 8225");
4744 DMESGW("This driver has EXPERIMENTAL support for this chipset.");
4745 DMESGW("use it with care and at your own risk and");
4746 @@ -1834,28 +1975,28 @@
4747 DMESG("This seems a legacy 1st version radio");
4748 }
4749 priv->rf_close = rtl8225_rf_close;
4750 -
4751 +
4752 priv->max_sens = RTL8225_RF_MAX_SENS;
4753 priv->sens = RTL8225_RF_DEF_SENS;
4754 break;
4755 -
4756 +
4757 default:
4758 DMESGW("Unknown RF module %x",priv->rf_chip);
4759 DMESGW("Exiting...");
4760 return -1;
4761 -
4762 +
4763 }
4764 -
4765 +
4766 // DMESG("Energy threshold: %x",priv->cs_treshold);
4767 DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7);
4768 //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2));
4769 -
4770 - if(rtl8187_usb_initendpoints(dev)!=0){
4771 +
4772 + if(rtl8187_usb_initendpoints(dev)!=0){
4773 DMESG("Endopoints initialization failed");
4774 return -ENOMEM;
4775 }
4776 -#if 0
4777 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4778 +#if 0
4779 + if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
4780 return -ENOMEM;
4781  
4782 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4783 @@ -1869,16 +2010,16 @@
4784 if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
4785 TX_LOWPRIORITY_RING_ADDR))
4786 return -ENOMEM;
4787 -
4788 -
4789 +
4790 +
4791 if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount))
4792 return -ENOMEM;
4793 #endif
4794 -
4795 +
4796  
4797 #ifdef DEBUG_EPROM
4798 dump_eprom(dev);
4799 -#endif
4800 +#endif
4801 return 0;
4802  
4803 }
4804 @@ -1898,7 +2039,7 @@
4805 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4806  
4807 conf3 = read_nic_byte(dev, CONFIG3);
4808 - write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4809 + write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4810  
4811 write_nic_dword(dev, ANAPARAM2, a);
4812  
4813 @@ -1918,23 +2059,23 @@
4814  
4815 conf3 = read_nic_byte(dev, CONFIG3);
4816 write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
4817 -
4818 +
4819 write_nic_dword(dev, ANAPARAM, a);
4820  
4821 conf3 = read_nic_byte(dev, CONFIG3);
4822 write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
4823  
4824 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4825 -
4826 +
4827 }
4828  
4829  
4830 void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
4831 {
4832 - write_nic_byte(dev, TX_ANTENNA, ant);
4833 + write_nic_byte(dev, TX_ANTENNA, ant);
4834 force_pci_posting(dev);
4835 mdelay(1);
4836 -}
4837 +}
4838  
4839  
4840 void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data)
4841 @@ -1942,26 +2083,26 @@
4842 //u8 phyr;
4843 u32 phyw;
4844 // int i;
4845 -
4846 +
4847 adr |= 0x80;
4848 -
4849 +
4850 phyw= ((data<<8) | adr);
4851 -
4852 -
4853 -
4854 - // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4855 +
4856 +
4857 +
4858 + // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
4859 write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24));
4860 write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16));
4861 write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8));
4862 write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) ));
4863  
4864 //read_nic_dword(dev, PHY_ADR);
4865 -#if 0
4866 +#if 0
4867 for(i=0;i<10;i++){
4868 write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw);
4869 phyr = read_nic_byte(dev, PHY_READ);
4870 if(phyr == (data&0xff)) break;
4871 -
4872 +
4873 }
4874 #endif
4875 /* this is ok to fail when we write AGC table. check for AGC table might be
4876 @@ -1988,60 +2129,60 @@
4877  
4878 void rtl8180_adapter_start(struct net_device *dev)
4879 {
4880 - struct r8180_priv *priv = ieee80211_priv(dev);
4881 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
4882 //u32 anaparam;
4883 //u8 config3;
4884 -
4885 +
4886 //rtl8180_rtx_disable(dev);
4887 rtl8180_reset(dev);
4888  
4889 write_nic_byte(dev,0x85,0);
4890 write_nic_byte(dev,0x91,0);
4891 -
4892 +
4893 /* light blink! */
4894 write_nic_byte(dev,0x85,4);
4895 write_nic_byte(dev,0x91,1);
4896 write_nic_byte(dev,0x90,0);
4897 -
4898 +
4899 priv->irq_mask = 0xffff;
4900 /*
4901 priv->dma_poll_mask = 0;
4902 priv->dma_poll_mask|= (1<<TX_DMA_STOP_BEACON_SHIFT);
4903 -*/
4904 +*/
4905 // rtl8180_beacon_tx_disable(dev);
4906 -
4907 +
4908 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4909 write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]);
4910 write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff );
4911  
4912 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
4913 rtl8180_update_msr(dev);
4914 -
4915 +
4916 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
4917 -
4918 +
4919 write_nic_word(dev,0xf4,0xffff);
4920 write_nic_byte(dev,
4921 - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4922 + CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
4923  
4924 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
4925 -
4926 - write_nic_dword(dev,INT_TIMEOUT,0);
4927 +
4928 + write_nic_dword(dev,INT_TIMEOUT,0);
4929  
4930 #ifdef DEBUG_REGISTERS
4931 - rtl8180_dump_reg(dev);
4932 + rtl8180_dump_reg(dev);
4933 #endif
4934 -
4935 -
4936 - write_nic_byte(dev, WPA_CONFIG, 0);
4937 +
4938 +
4939 + write_nic_byte(dev, WPA_CONFIG, 0);
4940  
4941 write_nic_byte(dev, RATE_FALLBACK, 0x81);
4942 rtl8187_set_rate(dev);
4943 -
4944 - priv->rf_init(dev);
4945 +
4946 + priv->rf_init(dev);
4947  
4948 if(priv->rf_set_sens != NULL)
4949 - priv->rf_set_sens(dev,priv->sens);
4950 -
4951 + priv->rf_set_sens(dev,priv->sens);
4952 +
4953 write_nic_word(dev,0x5e,1);
4954  
4955 #if 1
4956 @@ -2054,13 +2195,13 @@
4957 write_nic_byte(dev, 0xff, 0x60);
4958  
4959 write_nic_word(dev,0x5e,0);
4960 -
4961 -
4962 +
4963 +
4964 rtl8180_irq_enable(dev);
4965 /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY));
4966 -
4967 +
4968 DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY));
4969 -
4970 +
4971 DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY));
4972 if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK");
4973 if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK");
4974 @@ -2077,8 +2218,8 @@
4975 void rtl8180_start_tx_beacon(struct net_device *dev)
4976 {
4977 int i;
4978 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
4979 - u16 word;
4980 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
4981 + u16 word;
4982 DMESG("Enabling beacon TX");
4983 //write_nic_byte(dev, 0x42,0xe6);// TCR
4984 //rtl8180_init_beacon(dev);
4985 @@ -2091,41 +2232,41 @@
4986 //write_nic_word(dev,0x7a,0);
4987 //write_nic_word(dev,0x7a,0x8000);
4988  
4989 -
4990 +
4991 word = read_nic_word(dev, BcnItv);
4992 word &= ~BcnItv_BcnItv; // clear Bcn_Itv
4993 write_nic_word(dev, BcnItv, word);
4994  
4995 - write_nic_word(dev, AtimWnd,
4996 + write_nic_word(dev, AtimWnd,
4997 read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd);
4998 -
4999 +
5000 word = read_nic_word(dev, BintrItv);
5001 word &= ~BintrItv_BintrItv;
5002 -
5003 - //word |= priv->ieee80211->beacon_interval *
5004 +
5005 + //word |= priv->ieee80211->beacon_interval *
5006 // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
5007 // FIXME:FIXME check if correct ^^ worked with 0x3e8;
5008 -
5009 +
5010 write_nic_word(dev, BintrItv, word);
5011 -
5012 +
5013 //write_nic_word(dev,0x2e,0xe002);
5014 //write_nic_dword(dev,0x30,0xb8c7832e);
5015 for(i=0; i<ETH_ALEN; i++)
5016 write_nic_byte(dev, BSSID+i, priv->ieee80211->beacon_cell_ssid[i]);
5017 -
5018 +
5019 // rtl8180_update_msr(dev);
5020  
5021 -
5022 +
5023 //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
5024 -
5025 +
5026 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
5027 -
5028 +
5029 rtl8180_irq_enable(dev);
5030 -
5031 +
5032 /* VV !!!!!!!!!! VV*/
5033 /*
5034 rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
5035 - write_nic_byte(dev,0x9d,0x00);
5036 + write_nic_byte(dev,0x9d,0x00);
5037 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
5038 */
5039 }
5040 @@ -2135,137 +2276,138 @@
5041 ***************************************************************************/
5042 static struct net_device_stats *rtl8180_stats(struct net_device *dev)
5043 {
5044 - struct r8180_priv *priv = ieee80211_priv(dev);
5045 -
5046 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5047 +
5048 return &priv->ieee80211->stats;
5049 }
5050  
5051  
5052 int _rtl8180_up(struct net_device *dev)
5053 {
5054 - struct r8180_priv *priv = ieee80211_priv(dev);
5055 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5056  
5057 priv->up=1;
5058 -
5059 - //DMESG("Bringing up iface");
5060 +
5061 +// DMESG("Bringing up iface");
5062  
5063 rtl8180_adapter_start(dev);
5064 -
5065 rtl8180_rx_enable(dev);
5066 -
5067 rtl8180_tx_enable(dev);
5068 -
5069 - ieee80211_softmac_start_protocol(priv->ieee80211);
5070 -
5071 - ieee80211_reset_queue(priv->ieee80211);
5072 + ieee80211_softmac_start_protocol_rtl7(priv->ieee80211);
5073 + ieee80211_reset_queue_rtl7(priv->ieee80211);
5074 if(!netif_queue_stopped(dev))
5075 netif_start_queue(dev);
5076 else
5077 netif_wake_queue(dev);
5078 -
5079 return 0;
5080 }
5081  
5082  
5083 int rtl8180_open(struct net_device *dev)
5084 {
5085 - struct r8180_priv *priv = ieee80211_priv(dev);
5086 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5087 int ret;
5088 -
5089 +
5090 down(&priv->wx_sem);
5091 +
5092 ret = rtl8180_up(dev);
5093 up(&priv->wx_sem);
5094 return ret;
5095 -
5096 +
5097 }
5098  
5099  
5100 int rtl8180_up(struct net_device *dev)
5101 {
5102 - struct r8180_priv *priv = ieee80211_priv(dev);
5103 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5104  
5105 if (priv->up == 1) return -1;
5106 -
5107 +
5108 return _rtl8180_up(dev);
5109 }
5110  
5111  
5112 int rtl8180_close(struct net_device *dev)
5113 {
5114 - struct r8180_priv *priv = ieee80211_priv(dev);
5115 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5116 int ret;
5117 -
5118 +
5119 down(&priv->wx_sem);
5120 -
5121 +
5122 ret = rtl8180_down(dev);
5123 -
5124 +
5125 up(&priv->wx_sem);
5126 -
5127 +
5128 return ret;
5129  
5130 }
5131  
5132 int rtl8180_down(struct net_device *dev)
5133 {
5134 - struct r8180_priv *priv = ieee80211_priv(dev);
5135 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5136  
5137 if (priv->up == 0) return -1;
5138 -
5139 +
5140 priv->up=0;
5141  
5142 /* FIXME */
5143 if (!netif_queue_stopped(dev))
5144 netif_stop_queue(dev);
5145 -
5146 +
5147 rtl8180_rtx_disable(dev);
5148 rtl8180_irq_disable(dev);
5149  
5150 - ieee80211_softmac_stop_protocol(priv->ieee80211);
5151 -
5152 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
5153 +
5154 return 0;
5155 }
5156  
5157  
5158 void rtl8180_commit(struct net_device *dev)
5159 {
5160 - struct r8180_priv *priv = ieee80211_priv(dev);
5161 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5162  
5163 if (priv->up == 0) return ;
5164 -
5165 - ieee80211_softmac_stop_protocol(priv->ieee80211);
5166 -
5167 +
5168 + ieee80211_softmac_stop_protocol_rtl7(priv->ieee80211);
5169 +
5170 rtl8180_irq_disable(dev);
5171 rtl8180_rtx_disable(dev);
5172 _rtl8180_up(dev);
5173 }
5174  
5175 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
5176 +void rtl8180_restart(struct work_struct *work)
5177 +{
5178 + struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
5179 + struct net_device *dev = priv->dev;
5180 +#else
5181 void rtl8180_restart(struct net_device *dev)
5182 {
5183 - struct r8180_priv *priv = ieee80211_priv(dev);
5184 -
5185 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5186 +#endif
5187 down(&priv->wx_sem);
5188 -
5189 rtl8180_commit(dev);
5190 -
5191 +
5192 up(&priv->wx_sem);
5193 }
5194  
5195 static void r8180_set_multicast(struct net_device *dev)
5196 {
5197 - struct r8180_priv *priv = ieee80211_priv(dev);
5198 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5199 short promisc;
5200  
5201 //down(&priv->wx_sem);
5202 -
5203 +
5204 /* FIXME FIXME */
5205 -
5206 +
5207 promisc = (dev->flags & IFF_PROMISC) ? 1:0;
5208 -
5209 +
5210 if (promisc != priv->promisc)
5211 // rtl8180_commit(dev);
5212 -
5213 +
5214 priv->promisc = promisc;
5215 -
5216 +
5217 //schedule_work(&priv->reset_wq);
5218 //up(&priv->wx_sem);
5219 }
5220 @@ -2273,17 +2415,17 @@
5221  
5222 int r8180_set_mac_adr(struct net_device *dev, void *mac)
5223 {
5224 - struct r8180_priv *priv = ieee80211_priv(dev);
5225 + struct r8180_priv *priv = ieee80211_priv_rtl7(dev);
5226 struct sockaddr *addr = mac;
5227 -
5228 +
5229 down(&priv->wx_sem);
5230 -
5231 +
5232 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
5233 -
5234 +
5235 schedule_work(&priv->reset_wq);
5236 -
5237 +
5238 up(&priv->wx_sem);
5239 -
5240 +
5241 return 0;
5242 }
5243  
5244 @@ -2291,16 +2433,18 @@
5245 /* based on ipw2200 driver */
5246 int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
5247 {
5248 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5249 -
5250 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5251 + struct iwreq *wrq;
5252 + int ret;
5253 +
5254 down(&priv->wx_sem);
5255 -
5256 - struct iwreq *wrq = (struct iwreq *)rq;
5257 -
5258 - int ret=-1;
5259 +
5260 + wrq = (struct iwreq *)rq;
5261 +
5262 + ret=-1;
5263 switch (cmd) {
5264 case RTL_IOCTL_WPA_SUPPLICANT:
5265 - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
5266 + ret = ieee80211_wpa_supplicant_ioctl_rtl7(priv->ieee80211, &wrq->u.data);
5267 break;
5268  
5269 default:
5270 @@ -2309,7 +2453,7 @@
5271 }
5272  
5273 up(&priv->wx_sem);
5274 -
5275 +
5276 return ret;
5277 }
5278  
5279 @@ -2320,10 +2464,11 @@
5280 struct net_device *dev = (struct net_device*)rx_urb->context;
5281 int status,len,flen;
5282 struct sk_buff *skb;
5283 - u32 *desc;
5284 -
5285 + u8 *desc;
5286 + u8 signal,quality,rate;
5287 +
5288 //DMESG("rtl8187_rx_isr");
5289 -
5290 +
5291 struct ieee80211_rx_stats stats = {
5292 .signal = 0,
5293 .noise = -98,
5294 @@ -2332,43 +2477,109 @@
5295 .freq = IEEE80211_24GHZ_BAND,
5296 };
5297  
5298 +
5299 //DMESG("RX %d ",rx_urb->status);
5300 status = rx_urb->status;
5301 if(status == 0){
5302 -
5303 +
5304 len = rx_urb->actual_length;
5305 - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
5306 + // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
5307 len -= 4*4;/* 4 dword and 4 byte CRC */
5308 -
5309 +#if 0
5310 desc = (u32*)(rx_urb->transfer_buffer + len);
5311 -
5312 +
5313 flen = desc[0] & 0xfff;
5314 -
5315 +
5316 if( flen <= rx_urb->actual_length){
5317 -
5318 - stats.signal = (desc[1] & 0x7f00)>>8;
5319 - stats.noise = desc[1] &0xff;
5320 - stats.rate = desc[0] >> 20 & 0xf;
5321 +
5322 + //stats.signal = (desc[1] & 0x7f00)>>8;
5323 + //stats.noise = desc[1] &0xff;
5324 + signal=(desc[1]& (0xff0000))>>16;
5325 + signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
5326 +
5327 + quality=(desc[1] & (0xff));
5328 +
5329 + rate=(desc[0] &((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20;
5330 + // printk(KERN_INFO "rate is %d!\n",rate);
5331 + stats.rate = rtl8180_rate2rate(rate);
5332 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
5333 + //stats.rate = desc[0] >> 20 & 0xf;
5334 stats.mac_time[0] = desc[2];
5335 stats.mac_time[1] = desc[3];
5336 +#endif
5337 +
5338 + desc = rx_urb->transfer_buffer + len;
5339 +
5340 + flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff);
5341 +
5342 + if( flen <= rx_urb->actual_length){
5343 + //stats.signal = (desc[1] & 0x7f00)>>8;
5344 + //stats.noise = desc[1] &0xff;
5345 + signal=(desc[6]& 0xfe)>>1;
5346 + //signal=(signal&0xfe)>>1; // Modify by hikaru 6.6
5347 +
5348 + quality=desc[4] & 0xff;
5349 +
5350 + //rate=(desc[2] &((1<<7)|(1<<6)|(1<<5)|(1<<4)))>>4;
5351 + rate=(desc[2] & 0xf0)>>4;
5352 + // printk(KERN_INFO "rate is %d!\n",rate);
5353 + stats.rate = rtl8180_rate2rate(rate);
5354 + // printk(KERN_INFO "stats.rate is %d!\n",stats.rate);
5355 + //stats.rate = desc[0] >> 20 & 0xf;
5356 + stats.mac_time[0] = desc[8] + (desc[9]<<8) + (desc[10]<<16) + (desc[11]<<24);
5357 + stats.mac_time[1] = desc[12] + (desc[13]<<8) + (desc[14]<<16) + (desc[15]<<24);
5358 +
5359 +
5360 + //calculate link quality begin
5361 + if(!rtl8180_IsWirelessBMode(stats.rate) )
5362 + { // OFDM rate.
5363 + if(signal>90)
5364 + signal=90;
5365 + else if(signal<25)
5366 + signal=25;
5367 + signal = (90-signal)*100/65;
5368 + }
5369 + else
5370 + { // CCK rate.
5371 + if(signal>95)
5372 + signal = 95;
5373 + else if(signal<30)
5374 + signal = 30;
5375 + signal =(95-signal )*100/65;
5376 + }
5377 + priv->wstats.qual.level = signal;
5378 + // printk(KERN_INFO "signal is %d!\n",signal);
5379 + if(quality > 64)
5380 + priv ->wstats.qual.qual = 0;
5381 + else
5382 + priv ->wstats.qual.qual = ((64-quality) * 100) / 64; // SQ value is the SIGNAL_QUALITY returned to IORequest,
5383 + //and this value only appear when STA is associated to AP or
5384 + // STA is in IBSS mode
5385 + // printk(KERN_INFO "quality is %d!\n",priv->wstats.qual.qual);
5386 + priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual;
5387 + priv->wstats.qual.updated = 7;
5388 + if(priv->ieee80211->iw_mode == IW_MODE_MONITOR)
5389 + {
5390 + stats.signal = priv->wstats.qual.level;
5391 + stats.noise = priv->wstats.qual.noise;
5392 + }
5393 + //calculate link quality end
5394 skb = dev_alloc_skb(flen-4);
5395 - //skb_reserve(skb,2);
5396 - if(skb){
5397 + if(skb){
5398 memcpy(skb_put(skb,flen-4),
5399 rx_urb->transfer_buffer,flen -4);
5400 -
5401 +
5402 #ifdef DUMP_RX
5403 int i;
5404 for(i=0;i<flen-4;i++)
5405 printk("%2x ",((u8*)(rx_urb->transfer_buffer))[i]);
5406 printk("------RATE %x:w---------------\n",stats.rate);
5407 -
5408 +
5409 #endif
5410 priv->stats.rxok++;
5411 // priv->rxskb = skb;
5412 // priv->tempstats = &stats;
5413 -
5414 - if(!ieee80211_rx(priv->ieee80211,
5415 + if(!ieee80211_rx_rtl7(priv->ieee80211,
5416 skb, &stats))
5417 dev_kfree_skb_any(skb);
5418 }
5419 @@ -2376,9 +2587,8 @@
5420 }else{
5421 priv->stats.rxstaterr++;
5422 priv->ieee80211->stats.rx_errors++;
5423 -
5424 }
5425 -
5426 +
5427 if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb);
5428 else DMESG("RX process aborted due to explicit shutdown");
5429 }
5430 @@ -2396,20 +2606,22 @@
5431 struct r8180_priv *priv= NULL;
5432 struct usb_device *udev = interface_to_usbdev(intf);
5433  
5434 -//printk("===> rtl8187_usb_probe()\n");
5435 -
5436 - dev = alloc_ieee80211(sizeof(struct r8180_priv));
5437 -
5438 +//printk("===> rtl8187_usb_probe()\n");
5439 +
5440 + dev = alloc_ieee80211_rtl7(sizeof(struct r8180_priv));
5441 +
5442 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
5443 SET_MODULE_OWNER(dev);
5444 - usb_set_intfdata(intf, dev);
5445 -
5446 +#endif
5447 + usb_set_intfdata(intf, dev);
5448 +
5449 SET_NETDEV_DEV(dev, &intf->dev);
5450  
5451 - priv = ieee80211_priv(dev);
5452 + priv = ieee80211_priv_rtl7(dev);
5453 priv->ieee80211 = netdev_priv(dev);
5454 -
5455 +
5456 priv->udev=udev;
5457 -
5458 +
5459 dev->open = rtl8180_open;
5460 dev->stop = rtl8180_close;
5461 //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit;
5462 @@ -2418,41 +2630,46 @@
5463 dev->do_ioctl = rtl8180_ioctl;
5464 dev->set_multicast_list = r8180_set_multicast;
5465 dev->set_mac_address = r8180_set_mac_adr;
5466 +#if WIRELESS_EXT >= 12
5467 +#if WIRELESS_EXT < 17
5468 dev->get_wireless_stats = r8180_get_wireless_stats;
5469 +#endif
5470 + dev->wireless_handlers = (struct iw_handler_def *) &r8180_wx_handlers_def;
5471 +#endif
5472 dev->type=ARPHRD_ETHER;
5473 -
5474 +
5475 if (dev_alloc_name(dev, ifname) < 0){
5476 DMESG("Oops: devname already taken! Trying wlan%%d...\n");
5477 ifname = "wlan%d";
5478 dev_alloc_name(dev, ifname);
5479 }
5480 -
5481 +
5482 // dev->open=rtl8180_init;
5483 -
5484 - if(rtl8180_init(dev)!=0){
5485 +
5486 + if(rtl8180_init(dev)!=0){
5487 DMESG("Initialization failed");
5488 goto fail;
5489 }
5490 -
5491 +
5492 netif_carrier_off(dev);
5493 netif_stop_queue(dev);
5494 -
5495 +
5496 register_netdev(dev);
5497 -
5498 +
5499 rtl8180_proc_init_one(dev);
5500 -
5501 -
5502 +
5503 +
5504 DMESG("Driver probe completed\n");
5505 - return 0;
5506 + return 0;
5507 +
5508  
5509 -
5510 fail:
5511 - free_ieee80211(dev);
5512 -
5513 + free_ieee80211_rtl7(dev);
5514 +
5515 DMESG("wlan driver load failed\n");
5516 -
5517 +
5518 return -ENODEV;
5519 -
5520 +
5521 }
5522  
5523  
5524 @@ -2461,13 +2678,13 @@
5525 struct r8180_priv *priv;
5526 struct net_device *dev = usb_get_intfdata(intf);
5527 if(dev){
5528 -
5529 +
5530 unregister_netdev(dev);
5531 -
5532 - priv=ieee80211_priv(dev);
5533 -
5534 +
5535 + priv=ieee80211_priv_rtl7(dev);
5536 +
5537 rtl8180_proc_remove_one(dev);
5538 -
5539 +
5540 rtl8180_down(dev);
5541 priv->rf_close(dev);
5542 //rtl8180_rtx_disable(dev);
5543 @@ -2478,12 +2695,12 @@
5544  
5545 }
5546 // pci_disable_device(pdev);
5547 - free_ieee80211(dev);
5548 + free_ieee80211_rtl7(dev);
5549 DMESG("wlan driver removed\n");
5550 }
5551  
5552  
5553 -static int __init rtl8187_usb_module_init(void)
5554 +static int __init rtl8187_usb_module_init_rtl7(void)
5555 {
5556 printk(KERN_INFO "\nLinux kernel driver for RTL8187 \
5557 based WLAN cards\n");
5558 @@ -2495,7 +2712,7 @@
5559 }
5560  
5561  
5562 -static void __exit rtl8187_usb_module_exit(void)
5563 +static void __exit rtl8187_usb_module_exit_rtl7(void)
5564 {
5565 usb_deregister(&rtl8187_usb_driver);
5566  
5567 @@ -2508,14 +2725,14 @@
5568 {
5569 unsigned long flags;
5570 short enough_desc;
5571 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5572 -
5573 + struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv_rtl7(dev);
5574 +
5575 spin_lock_irqsave(&priv->tx_lock,flags);
5576 enough_desc = check_nic_enought_desc(dev,pri);
5577 - spin_unlock_irqrestore(&priv->tx_lock,flags);
5578 -
5579 + spin_unlock_irqrestore(&priv->tx_lock,flags);
5580 +
5581 if(enough_desc)
5582 - ieee80211_wake_queue(priv->ieee80211);
5583 + ieee80211_wake_queue_rtl7(priv->ieee80211);
5584 }
5585  
5586  
5587 @@ -2523,5 +2740,5 @@
5588 /***************************************************************************
5589 ------------------- module init / exit stubs ----------------
5590 ****************************************************************************/
5591 -module_init(rtl8187_usb_module_init);
5592 -module_exit(rtl8187_usb_module_exit);
5593 +module_init(rtl8187_usb_module_init_rtl7);
5594 +module_exit(rtl8187_usb_module_exit_rtl7);
5595 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~
5596 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187_core.c~ 2006-06-22 01:40:10.000000000 -0400
5597 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.c~ 1969-12-31 19:00:00.000000000 -0500
5598 @@ -1,2527 +0,0 @@
5599 -/*
5600 - This is part of rtl8187 OpenSource driver - v 0.1
5601 - Copyright (C) Andrea Merello 2005 <andreamrl@tiscali.it>
5602 - Released under the terms of GPL (General Public License)
5603 -
5604 -
5605 - Parts of this driver are based on the rtl8180 driver skeleton
5606 - from Patric Schenke & Andres Salomon.
5607 -
5608 - Parts of this driver are based on the Intel Pro Wireless 2*00 GPL drivers.
5609 -
5610 - some ideas might be derived from David Young rtl8180 netbsd driver.
5611 -
5612 - Parts of the usb code are from the r8150.c driver in linux kernel
5613 -
5614 - Some ideas borrowed from the 8139too.c driver included in linux kernel.
5615 -
5616 - We (I?) want to thanks the Authors of those projecs and also the
5617 - Ndiswrapper's project Authors.
5618 -
5619 - A special big thanks goes also to Realtek corp. for their help in my
5620 - attempt to add RTL8187 and RTL8225 support, and to David Young also.
5621 -
5622 - - Please note that this file is a modified version from rtl8180-sa2400
5623 - drv. So some other people have contributed to this project, and they are
5624 - thanked in the rtl8180-sa2400 CHANGELOG.
5625 -*/
5626 -
5627 -#ifndef CONFIG_FORCE_HARD_FLOAT
5628 -double __floatsidf (int i) { return i; }
5629 -unsigned int __fixunsdfsi (double d) { return d; }
5630 -double __adddf3(double a, double b) { return a+b; }
5631 -double __addsf3(float a, float b) { return a+b; }
5632 -double __subdf3(double a, double b) { return a-b; }
5633 -double __extendsfdf2(float a) {return a;}
5634 -#endif
5635 -
5636 -#undef LOOP_TEST
5637 -#undef DUMP_RX
5638 -#undef DUMP_TX
5639 -#undef DEBUG_TX_DESC2
5640 -#undef RX_DONT_PASS_UL
5641 -#undef DEBUG_EPROM
5642 -#undef DEBUG_RX_VERBOSE
5643 -#undef DUMMY_RX
5644 -#undef DEBUG_ZERO_RX
5645 -#undef DEBUG_RX_SKB
5646 -#undef DEBUG_TX_FRAG
5647 -#undef DEBUG_RX_FRAG
5648 -#undef DEBUG_TX_FILLDESC
5649 -#undef DEBUG_TX
5650 -#undef DEBUG_IRQ
5651 -#undef DEBUG_RX
5652 -#undef DEBUG_RXALLOC
5653 -#undef DEBUG_REGISTERS
5654 -#undef DEBUG_RING
5655 -#undef DEBUG_IRQ_TASKLET
5656 -#undef DEBUG_TX_ALLOC
5657 -#undef DEBUG_TX_DESC
5658 -
5659 -//#define CONFIG_RTL8180_IO_MAP
5660 -
5661 -#include "r8180_hw.h"
5662 -#include "r8187.h"
5663 -#include "r8180_rtl8225.h" /* RTL8225 Radio frontend */
5664 -#include "r8180_93cx6.h" /* Card EEPROM */
5665 -#include "r8180_wx.h"
5666 -
5667 -
5668 -// FIXME: check if 2.6.7 is ok
5669 -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
5670 -#define usb_kill_urb usb_unlink_urb
5671 -#endif
5672 -
5673 -#ifdef CONFIG_RTL8180_PM
5674 -#include "r8180_pm.h"
5675 -#endif
5676 -
5677 -#ifndef USB_VENDOR_ID_REALTEK
5678 -#define USB_VENDOR_ID_REALTEK 0x0bda
5679 -#endif
5680 -#ifndef USB_VENDOR_ID_NETGEAR
5681 -#define USB_VENDOR_ID_NETGEAR 0x0846
5682 -#endif
5683 -
5684 -static struct usb_device_id rtl8187_usb_id_tbl[] = {
5685 - {USB_DEVICE(USB_VENDOR_ID_REALTEK, 0x8187)},
5686 - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6100)},
5687 - {USB_DEVICE(USB_VENDOR_ID_NETGEAR, 0x6a00)},
5688 -
5689 - {}
5690 -};
5691 -
5692 -static char* ifname = "wlan%d";
5693 -#if 0
5694 -static int hwseqnum = 0;
5695 -static int hwwep = 0;
5696 -#endif
5697 -static int channels = 0x3fff;
5698 -
5699 -MODULE_LICENSE("GPL");
5700 -MODULE_VERSION("V 1.1");
5701 -MODULE_DEVICE_TABLE(usb, rtl8187_usb_id_tbl);
5702 -MODULE_AUTHOR("Andrea Merello <andreamrl@tiscali.it>");
5703 -MODULE_DESCRIPTION("Linux driver for Realtek RTL8187 WiFi cards");
5704 -
5705 -#if 0
5706 -MODULE_PARM(ifname,"s");
5707 -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default");
5708 -
5709 -MODULE_PARM(hwseqnum,"i");
5710 -MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
5711 -
5712 -MODULE_PARM(hwwep,"i");
5713 -MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards");
5714 -
5715 -MODULE_PARM(channels,"i");
5716 -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
5717 -#endif
5718 -
5719 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 9)
5720 -module_param(ifname, charp, S_IRUGO|S_IWUSR );
5721 -//module_param(hwseqnum,int, S_IRUGO|S_IWUSR);
5722 -//module_param(hwwep,int, S_IRUGO|S_IWUSR);
5723 -module_param(channels,int, S_IRUGO|S_IWUSR);
5724 -#else
5725 -MODULE_PARM(ifname, "s");
5726 -//MODULE_PARM(hwseqnum,"i");
5727 -//MODULE_PARM(hwwep,"i");
5728 -MODULE_PARM(channels,"i");
5729 -#endif
5730 -
5731 -MODULE_PARM_DESC(devname," Net interface name, wlan%d=default");
5732 -//MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
5733 -//MODULE_PARM_DESC(hwwep," Try to use hardware WEP support. Still broken and not available on all cards");
5734 -MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI");
5735 -
5736 -static int __devinit rtl8187_usb_probe(struct usb_interface *intf,
5737 - const struct usb_device_id *id);
5738 -
5739 -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf);
5740 -
5741 -static struct usb_driver rtl8187_usb_driver = {
5742 -
5743 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
5744 - .owner = THIS_MODULE,
5745 -#endif
5746 - .name = RTL8187_MODULE_NAME, /* Driver name */
5747 - .id_table = rtl8187_usb_id_tbl, /* PCI_ID table */
5748 - .probe = rtl8187_usb_probe, /* probe fn */
5749 - .disconnect = rtl8187_usb_disconnect, /* remove fn */
5750 -#ifdef CONFIG_RTL8180_PM
5751 - .suspend = rtl8180_suspend, /* PM suspend fn */
5752 - .resume = rtl8180_resume, /* PM resume fn */
5753 -#else
5754 - .suspend = NULL, /* PM suspend fn */
5755 - .resume = NULL, /* PM resume fn */
5756 -#endif
5757 -};
5758 -
5759 -
5760 -void write_nic_byte_E(struct net_device *dev, int indx, u8 data)
5761 -{
5762 -
5763 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5764 - struct usb_device *udev = priv->udev;
5765 -
5766 - usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
5767 - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
5768 - indx|0xfe00, 0, &data, 1, HZ / 2);
5769 -}
5770 -
5771 -
5772 -void write_nic_byte(struct net_device *dev, int indx, u8 data)
5773 -{
5774 -
5775 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5776 - struct usb_device *udev = priv->udev;
5777 -
5778 - usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
5779 - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
5780 - indx|0xff00, 0, &data, 1, HZ / 2);
5781 -}
5782 -
5783 -
5784 -void write_nic_word(struct net_device *dev, int indx, u16 data)
5785 -{
5786 -
5787 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5788 - struct usb_device *udev = priv->udev;
5789 -
5790 - usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
5791 - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
5792 - indx|0xff00, 0, &data, 2, HZ / 2);
5793 -}
5794 -
5795 -
5796 -void write_nic_dword(struct net_device *dev, int indx, u32 data)
5797 -{
5798 -
5799 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5800 - struct usb_device *udev = priv->udev;
5801 -
5802 - usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
5803 - RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE,
5804 - indx|0xff00, 0, &data, 4, HZ / 2);
5805 -}
5806 -
5807 -
5808 -
5809 -u8 read_nic_byte(struct net_device *dev, int indx)
5810 -{
5811 - u8 data;
5812 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5813 - struct usb_device *udev = priv->udev;
5814 -
5815 - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
5816 - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
5817 - indx|0xff00, 0, &data, 1, HZ / 2);
5818 - return data;
5819 -}
5820 -
5821 -u8 read_nic_byte_E(struct net_device *dev, int indx)
5822 -{
5823 - u8 data;
5824 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5825 - struct usb_device *udev = priv->udev;
5826 -
5827 - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
5828 - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
5829 - indx|0xfe00, 0, &data, 1, HZ / 2);
5830 - return data;
5831 -}
5832 -
5833 -
5834 -u16 read_nic_word(struct net_device *dev, int indx)
5835 -{
5836 - u16 data;
5837 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5838 - struct usb_device *udev = priv->udev;
5839 -
5840 - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
5841 - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
5842 - indx|0xff00, 0, &data, 2, HZ / 2);
5843 - return data;
5844 -}
5845 -
5846 -
5847 -u32 read_nic_dword(struct net_device *dev, int indx)
5848 -{
5849 - u32 data;
5850 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5851 - struct usb_device *udev = priv->udev;
5852 -
5853 - usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
5854 - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ,
5855 - indx|0xff00, 0, &data, 4, HZ / 2);
5856 - return data;
5857 -}
5858 -
5859 -/* this might still called in what was the PHY rtl8185/rtl8187 common code
5860 - * plans are to possibilty turn it again in one common code...
5861 - */
5862 -inline void force_pci_posting(struct net_device *dev)
5863 -{
5864 -}
5865 -
5866 -
5867 -//irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs);
5868 -//void set_nic_rxring(struct net_device *dev);
5869 -//void set_nic_txring(struct net_device *dev);
5870 -static struct net_device_stats *rtl8180_stats(struct net_device *dev);
5871 -void rtl8180_commit(struct net_device *dev);
5872 -void rtl8180_restart(struct net_device *dev);
5873 -
5874 -/****************************************************************************
5875 - -----------------------------PROCFS STUFF-------------------------
5876 -*****************************************************************************/
5877 -
5878 -static struct proc_dir_entry *rtl8180_proc = NULL;
5879 -
5880 -static int proc_get_registers(char *page, char **start,
5881 - off_t offset, int count,
5882 - int *eof, void *data)
5883 -{
5884 - struct net_device *dev = data;
5885 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5886 -
5887 - int len = 0;
5888 - int i,n;
5889 -
5890 - int max=0xff;
5891 -
5892 - /* This dump the current register page */
5893 - for(n=0;n<=max;)
5894 - {
5895 - //printk( "\nD: %2x> ", n);
5896 - len += snprintf(page + len, count - len,
5897 - "\nD: %2x > ",n);
5898 -
5899 - for(i=0;i<16 && n<=max;i++,n++)
5900 - len += snprintf(page + len, count - len,
5901 - "%2x ",read_nic_byte(dev,n));
5902 -
5903 - // printk("%2x ",read_nic_byte(dev,n));
5904 - }
5905 - len += snprintf(page + len, count - len,"\n");
5906 -
5907 -
5908 -
5909 - *eof = 1;
5910 - return len;
5911 -
5912 -}
5913 -
5914 -#if 0
5915 -static int proc_get_stats_hw(char *page, char **start,
5916 - off_t offset, int count,
5917 - int *eof, void *data)
5918 -{
5919 - struct net_device *dev = data;
5920 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5921 -
5922 - int len = 0;
5923 -
5924 - len += snprintf(page + len, count - len,
5925 - "NIC int: %lu\n"
5926 - "Total int: %lu\n",
5927 - priv->stats.ints,
5928 - priv->stats.shints);
5929 -
5930 - *eof = 1;
5931 - return len;
5932 -}
5933 -#endif
5934 -
5935 -static int proc_get_stats_tx(char *page, char **start,
5936 - off_t offset, int count,
5937 - int *eof, void *data)
5938 -{
5939 - struct net_device *dev = data;
5940 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5941 -
5942 - int len = 0;
5943 -
5944 - len += snprintf(page + len, count - len,
5945 - "TX normal priority ok int: %lu\n"
5946 - "TX normal priority error int: %lu\n"
5947 -// "TX high priority ok int: %lu\n"
5948 -// "TX high priority failed error int: %lu\n"
5949 - "TX low priority ok int: %lu\n"
5950 - "TX low priority failed error int: %lu\n"
5951 - "TX queue resume: %lu\n"
5952 - "TX queue stopped?: %d\n"
5953 - "TX fifo overflow: %lu\n"
5954 -// "TX beacon: %lu\n"
5955 - "TX lp queue: %d\n"
5956 - "TX np queue: %d\n"
5957 - "TX HW queue: %d\n"
5958 - "TX lp dropped: %lu\n"
5959 - "TX np dropped: %lu\n"
5960 - "TX total data packets %lu\n",
5961 -// "TX beacon aborted: %lu\n",
5962 - priv->stats.txnpokint,
5963 - priv->stats.txnperr,
5964 -// priv->stats.txhpokint,
5965 -// priv->stats.txhperr,
5966 - priv->stats.txlpokint,
5967 - priv->stats.txlperr,
5968 - priv->stats.txresumed,
5969 - netif_queue_stopped(dev),
5970 - priv->stats.txoverflow,
5971 -// priv->stats.txbeacon,
5972 - atomic_read(&(priv->tx_lp_pending)),
5973 - atomic_read(&(priv->tx_np_pending)),
5974 - read_nic_byte(dev, TXFIFOCOUNT),
5975 - priv->stats.txlpdrop,
5976 - priv->stats.txnpdrop,
5977 - priv->stats.txdatapkt
5978 -// priv->stats.txbeaconerr
5979 - );
5980 -
5981 - *eof = 1;
5982 - return len;
5983 -}
5984 -
5985 -
5986 -
5987 -static int proc_get_stats_rx(char *page, char **start,
5988 - off_t offset, int count,
5989 - int *eof, void *data)
5990 -{
5991 - struct net_device *dev = data;
5992 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
5993 -
5994 - int len = 0;
5995 -
5996 - len += snprintf(page + len, count - len,
5997 - "RX packets: %lu\n"
5998 - "RX urb status error: %lu\n"
5999 - "RX invalid urb error: %lu\n",
6000 - priv->stats.rxok,
6001 - priv->stats.rxstaterr,
6002 - priv->stats.rxurberr);
6003 -
6004 - *eof = 1;
6005 - return len;
6006 -}
6007 -
6008 -
6009 -static struct iw_statistics *r8180_get_wireless_stats(struct net_device *dev)
6010 -{
6011 - struct r8180_priv *priv = ieee80211_priv(dev);
6012 -
6013 - return &priv->wstats;
6014 -}
6015 -
6016 -void rtl8180_proc_module_init(void)
6017 -{
6018 - DMESG("Initializing proc filesystem");
6019 - rtl8180_proc=create_proc_entry(RTL8187_MODULE_NAME, S_IFDIR, proc_net);
6020 -}
6021 -
6022 -
6023 -void rtl8180_proc_module_remove(void)
6024 -{
6025 - remove_proc_entry(RTL8187_MODULE_NAME, proc_net);
6026 -}
6027 -
6028 -
6029 -void rtl8180_proc_remove_one(struct net_device *dev)
6030 -{
6031 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6032 - if (priv->dir_dev) {
6033 - // remove_proc_entry("stats-hw", priv->dir_dev);
6034 - remove_proc_entry("stats-tx", priv->dir_dev);
6035 - remove_proc_entry("stats-rx", priv->dir_dev);
6036 - // remove_proc_entry("stats-ieee", priv->dir_dev);
6037 - // remove_proc_entry("stats-ap", priv->dir_dev);
6038 - remove_proc_entry("registers", priv->dir_dev);
6039 - remove_proc_entry(dev->name, rtl8180_proc);
6040 - priv->dir_dev = NULL;
6041 - }
6042 -}
6043 -
6044 -
6045 -void rtl8180_proc_init_one(struct net_device *dev)
6046 -{
6047 - struct proc_dir_entry *e;
6048 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6049 - priv->dir_dev = create_proc_entry(dev->name,
6050 - S_IFDIR | S_IRUGO | S_IXUGO,
6051 - rtl8180_proc);
6052 - if (!priv->dir_dev) {
6053 - DMESGE("Unable to initialize /proc/net/rtl8187/%s\n",
6054 - dev->name);
6055 - return;
6056 - }
6057 - #if 0
6058 - e = create_proc_read_entry("stats-hw", S_IFREG | S_IRUGO,
6059 - priv->dir_dev, proc_get_stats_hw, dev);
6060 -
6061 - if (!e) {
6062 - DMESGE("Unable to initialize "
6063 - "/proc/net/rtl8187/%s/stats-hw\n",
6064 - dev->name);
6065 - }
6066 - #endif
6067 - e = create_proc_read_entry("stats-rx", S_IFREG | S_IRUGO,
6068 - priv->dir_dev, proc_get_stats_rx, dev);
6069 -
6070 - if (!e) {
6071 - DMESGE("Unable to initialize "
6072 - "/proc/net/rtl8187/%s/stats-rx\n",
6073 - dev->name);
6074 - }
6075 -
6076 -
6077 - e = create_proc_read_entry("stats-tx", S_IFREG | S_IRUGO,
6078 - priv->dir_dev, proc_get_stats_tx, dev);
6079 -
6080 - if (!e) {
6081 - DMESGE("Unable to initialize "
6082 - "/proc/net/rtl8187/%s/stats-tx\n",
6083 - dev->name);
6084 - }
6085 - #if 0
6086 - e = create_proc_read_entry("stats-ieee", S_IFREG | S_IRUGO,
6087 - priv->dir_dev, proc_get_stats_ieee, dev);
6088 -
6089 - if (!e) {
6090 - DMESGE("Unable to initialize "
6091 - "/proc/net/rtl8187/%s/stats-ieee\n",
6092 - dev->name);
6093 - }
6094 -
6095 -
6096 - e = create_proc_read_entry("stats-ap", S_IFREG | S_IRUGO,
6097 - priv->dir_dev, proc_get_stats_ap, dev);
6098 -
6099 - if (!e) {
6100 - DMESGE("Unable to initialize "
6101 - "/proc/net/rtl8187/%s/stats-ap\n",
6102 - dev->name);
6103 - }
6104 - #endif
6105 -
6106 - e = create_proc_read_entry("registers", S_IFREG | S_IRUGO,
6107 - priv->dir_dev, proc_get_registers, dev);
6108 -
6109 - if (!e) {
6110 - DMESGE("Unable to initialize "
6111 - "/proc/net/rtl8187/%s/registers\n",
6112 - dev->name);
6113 - }
6114 -}
6115 -/****************************************************************************
6116 - -----------------------------MISC STUFF-------------------------
6117 -*****************************************************************************/
6118 -
6119 -/* this is only for debugging */
6120 -void print_buffer(u32 *buffer, int len)
6121 -{
6122 - int i;
6123 - u8 *buf =(u8*)buffer;
6124 -
6125 - printk("ASCII BUFFER DUMP (len: %x):\n",len);
6126 -
6127 - for(i=0;i<len;i++)
6128 - printk("%c",buf[i]);
6129 -
6130 - printk("\nBINARY BUFFER DUMP (len: %x):\n",len);
6131 -
6132 - for(i=0;i<len;i++)
6133 - printk("%x",buf[i]);
6134 -
6135 - printk("\n");
6136 -}
6137 -
6138 -short check_nic_enought_desc(struct net_device *dev, priority_t priority)
6139 -{
6140 - struct r8180_priv *priv = ieee80211_priv(dev);
6141 -
6142 - int used = atomic_read((priority == NORM_PRIORITY) ?
6143 - &priv->tx_np_pending : &priv->tx_lp_pending);
6144 -
6145 - return (used < MAX_TX_URB);
6146 -}
6147 -
6148 -void tx_timeout(struct net_device *dev)
6149 -{
6150 - struct r8180_priv *priv = ieee80211_priv(dev);
6151 - //rtl8180_commit(dev);
6152 - schedule_work(&priv->reset_wq);
6153 - //DMESG("TXTIMEOUT");
6154 -}
6155 -
6156 -
6157 -/* this is only for debug */
6158 -void dump_eprom(struct net_device *dev)
6159 -{
6160 - int i;
6161 - for(i=0; i<63; i++)
6162 - DMESG("EEPROM addr %x : %x", i, eprom_read(dev,i));
6163 -}
6164 -
6165 -/* this is only for debug */
6166 -void rtl8180_dump_reg(struct net_device *dev)
6167 -{
6168 - int i;
6169 - int n;
6170 - int max=0xff;
6171 -
6172 - DMESG("Dumping NIC register map");
6173 -
6174 - for(n=0;n<=max;)
6175 - {
6176 - printk( "\nD: %2x> ", n);
6177 - for(i=0;i<16 && n<=max;i++,n++)
6178 - printk("%2x ",read_nic_byte(dev,n));
6179 - }
6180 - printk("\n");
6181 -}
6182 -
6183 -/****************************************************************************
6184 - ------------------------------HW STUFF---------------------------
6185 -*****************************************************************************/
6186 -
6187 -
6188 -void rtl8180_irq_enable(struct net_device *dev)
6189 -{
6190 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6191 - //priv->irq_enabled = 1;
6192 -/*
6193 - write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
6194 - INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
6195 - INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
6196 - INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
6197 -*/
6198 - write_nic_word(dev,INTA_MASK, priv->irq_mask);
6199 -}
6200 -
6201 -
6202 -void rtl8180_irq_disable(struct net_device *dev)
6203 -{
6204 -// struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6205 -
6206 - write_nic_word(dev,INTA_MASK,0);
6207 - force_pci_posting(dev);
6208 -// priv->irq_enabled = 0;
6209 -}
6210 -
6211 -
6212 -void rtl8180_set_mode(struct net_device *dev,int mode)
6213 -{
6214 - u8 ecmd;
6215 - ecmd=read_nic_byte(dev, EPROM_CMD);
6216 - ecmd=ecmd &~ EPROM_CMD_OPERATING_MODE_MASK;
6217 - ecmd=ecmd | (mode<<EPROM_CMD_OPERATING_MODE_SHIFT);
6218 - ecmd=ecmd &~ (1<<EPROM_CS_SHIFT);
6219 - ecmd=ecmd &~ (1<<EPROM_CK_SHIFT);
6220 - write_nic_byte(dev, EPROM_CMD, ecmd);
6221 -}
6222 -
6223 -
6224 -void rtl8180_update_msr(struct net_device *dev)
6225 -{
6226 - struct r8180_priv *priv = ieee80211_priv(dev);
6227 - u8 msr;
6228 -
6229 - msr = read_nic_byte(dev, MSR);
6230 - msr &= ~ MSR_LINK_MASK;
6231 -
6232 - /* do not change in link_state != WLAN_LINK_ASSOCIATED.
6233 - * msr must be updated if the state is ASSOCIATING.
6234 - * this is intentional and make sense for ad-hoc and
6235 - * master (see the create BSS/IBSS func)
6236 - */
6237 - if (priv->ieee80211->state == IEEE80211_LINKED){
6238 -
6239 - if (priv->ieee80211->iw_mode == IW_MODE_INFRA)
6240 - msr |= (MSR_LINK_MANAGED<<MSR_LINK_SHIFT);
6241 - else if (priv->ieee80211->iw_mode == IW_MODE_ADHOC)
6242 - msr |= (MSR_LINK_ADHOC<<MSR_LINK_SHIFT);
6243 - else if (priv->ieee80211->iw_mode == IW_MODE_MASTER)
6244 - msr |= (MSR_LINK_MASTER<<MSR_LINK_SHIFT);
6245 -
6246 - }else
6247 - msr |= (MSR_LINK_NONE<<MSR_LINK_SHIFT);
6248 -
6249 - write_nic_byte(dev, MSR, msr);
6250 -}
6251 -
6252 -void rtl8180_set_chan(struct net_device *dev,short ch)
6253 -{
6254 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6255 - u32 tx;
6256 - priv->chan=ch;
6257 - #if 0
6258 - if(priv->ieee80211->iw_mode == IW_MODE_ADHOC ||
6259 - priv->ieee80211->iw_mode == IW_MODE_MASTER){
6260 -
6261 - priv->ieee80211->link_state = WLAN_LINK_ASSOCIATED;
6262 - priv->ieee80211->master_chan = ch;
6263 - rtl8180_update_beacon_ch(dev);
6264 - }
6265 - #endif
6266 -
6267 - /* this hack should avoid frame TX during channel setting*/
6268 - tx = read_nic_dword(dev,TX_CONF);
6269 - tx &= ~TX_LOOPBACK_MASK;
6270 -
6271 -#ifndef LOOP_TEST
6272 - write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
6273 -
6274 - priv->rf_set_chan(dev,priv->chan);
6275 - mdelay(10);
6276 - write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
6277 -#endif
6278 -}
6279 -void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs);
6280 -
6281 -
6282 -void rtl8187_rx_urbsubmit(struct net_device *dev, struct urb* rx_urb)
6283 -{
6284 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6285 - int err;
6286 -
6287 -// u8 *rx;
6288 -
6289 - //DMESG("starting RX");
6290 - /*rx = kmalloc(RX_URB_SIZE*sizeof(u8),GFP_ATOMIC);
6291 - if(!rx){
6292 - DMESGE("unable to allocate RX buffer");
6293 - return;
6294 - }*/
6295 -
6296 - usb_fill_bulk_urb(rx_urb,priv->udev,
6297 - usb_rcvbulkpipe(priv->udev,0x81), rx_urb->transfer_buffer,
6298 - RX_URB_SIZE,rtl8187_rx_isr,dev);
6299 - err = usb_submit_urb(rx_urb, GFP_ATOMIC);
6300 - if(err && err != -EPERM){
6301 - DMESGE("cannot submit RX command. URB_STATUS %x",rx_urb->status);
6302 -
6303 - }
6304 -
6305 -}
6306 -
6307 -
6308 -void rtl8187_rx_initiate(struct net_device *dev)
6309 -{
6310 - int i;
6311 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6312 -
6313 - if(!priv->rx_urb)
6314 - DMESGE("Cannot intiate RX urb mechanism");
6315 - for(i=0;i<MAX_RX_URB;i++) // RX_MAX_URB is 1
6316 - rtl8187_rx_urbsubmit(dev,priv->rx_urb[i]);
6317 -
6318 -}
6319 -
6320 -void rtl8187_set_rxconf(struct net_device *dev)
6321 -{
6322 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6323 - u32 rxconf;
6324 -
6325 - rxconf=read_nic_dword(dev,RX_CONF);
6326 - rxconf = rxconf &~ MAC_FILTER_MASK;
6327 - rxconf = rxconf | (1<<ACCEPT_MNG_FRAME_SHIFT);
6328 - rxconf = rxconf | (1<<ACCEPT_DATA_FRAME_SHIFT);
6329 - rxconf = rxconf | (1<<ACCEPT_BCAST_FRAME_SHIFT);
6330 - rxconf = rxconf | (1<<ACCEPT_MCAST_FRAME_SHIFT);
6331 - rxconf = rxconf | (1<<ACCEPT_CTL_FRAME_SHIFT);
6332 -
6333 - if (dev->flags & IFF_PROMISC) DMESG ("NIC in promisc mode");
6334 -
6335 - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR || \
6336 - dev->flags & IFF_PROMISC){
6337 - rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
6338 - }else{
6339 - rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
6340 - rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
6341 - }
6342 -
6343 - /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
6344 - rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
6345 - rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
6346 - }*/
6347 -
6348 - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
6349 - rxconf = rxconf | (1<<ACCEPT_ICVERR_FRAME_SHIFT);
6350 - rxconf = rxconf | (1<<ACCEPT_PWR_FRAME_SHIFT);
6351 - }
6352 -
6353 - if( priv->crcmon == 1 && priv->ieee80211->iw_mode == IW_MODE_MONITOR)
6354 - rxconf = rxconf | (1<<ACCEPT_CRCERR_FRAME_SHIFT);
6355 -
6356 -
6357 - rxconf = rxconf &~ RX_FIFO_THRESHOLD_MASK;
6358 - rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<<RX_FIFO_THRESHOLD_SHIFT);
6359 -
6360 -
6361 - rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
6362 -
6363 - rxconf = rxconf &~ MAX_RX_DMA_MASK;
6364 - rxconf = rxconf | (MAX_RX_DMA_2048<<MAX_RX_DMA_SHIFT);
6365 -
6366 - rxconf = rxconf | RCR_ONLYERLPKT;
6367 -
6368 -// rxconf = rxconf &~ RCR_CS_MASK;
6369 -// rxconf = rxconf | (1<<RCR_CS_SHIFT);
6370 -
6371 - write_nic_dword(dev, RX_CONF, rxconf);
6372 -
6373 - // V rtl suggested V //
6374 -// write_nic_dword(dev, RX_CONF, 0x901ce70e);
6375 -
6376 - //fix_rx_fifo(dev);
6377 -// //set_nic_rxring(dev);
6378 - #ifdef DEBUG_RX
6379 - DMESG("rxconf: %x %x",rxconf ,read_nic_dword(dev,RX_CONF));
6380 - #endif
6381 -}
6382 -
6383 -void rtl8180_rx_enable(struct net_device *dev)
6384 -{
6385 - u8 cmd;
6386 -
6387 -
6388 - rtl8187_rx_initiate(dev);
6389 -
6390 - rtl8187_set_rxconf(dev);
6391 -
6392 - cmd=read_nic_byte(dev,CMD);
6393 - write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT));
6394 -#if 0
6395 - /* In rtl8139 driver seems that DMA threshold has to be written
6396 - * after enabling RX, so we rewrite RX_CONFIG register
6397 - */
6398 - //mdelay(100);
6399 - write_nic_dword(dev, RX_CONF, rxconf);
6400 -
6401 -#endif
6402 -
6403 -}
6404 -
6405 -
6406 -void rtl8180_tx_enable(struct net_device *dev)
6407 -{
6408 - u8 cmd;
6409 - u8 byte;
6410 - u32 txconf;
6411 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6412 -
6413 - byte = read_nic_byte(dev,CW_CONF);
6414 - byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
6415 - byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
6416 - write_nic_byte(dev, CW_CONF, byte);
6417 -
6418 - byte = read_nic_byte(dev, TX_AGC_CTL);
6419 - byte &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
6420 - byte &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
6421 - byte &= ~(1<<TX_AGC_CTL_FEEDBACK_ANT);
6422 - write_nic_byte(dev, TX_AGC_CTL, byte);
6423 -
6424 - txconf= read_nic_dword(dev,TX_CONF);
6425 -
6426 - #if 0
6427 - if(priv->card_8185){
6428 -
6429 - txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
6430 -
6431 - }else{
6432 -
6433 - if(priv->ieee80211->hw_seq)
6434 - txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
6435 - else
6436 - txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT);
6437 - }
6438 - #endif
6439 -
6440 - txconf = txconf &~ TX_LOOPBACK_MASK;
6441 -
6442 -#ifndef LOOP_TEST
6443 - txconf = txconf | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT);
6444 -#else
6445 - txconf = txconf | (TX_LOOPBACK_BASEBAND<<TX_LOOPBACK_SHIFT);
6446 -#endif
6447 - txconf = txconf &~ TCR_DPRETRY_MASK;
6448 - txconf = txconf &~ TCR_RTSRETRY_MASK;
6449 -
6450 - txconf = txconf | (priv->retry_data<<TX_DPRETRY_SHIFT); // long
6451 - txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); // short
6452 -
6453 - txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
6454 -
6455 - txconf = txconf &~ TCR_MXDMA_MASK;
6456 - txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
6457 -
6458 - txconf = txconf | TCR_CWMIN;
6459 - txconf = txconf | TCR_DISCW;
6460 - txconf = txconf &~ TCR_SWPLCPLEN;
6461 -
6462 - txconf=txconf | (1<<TX_NOICV_SHIFT);
6463 -
6464 - write_nic_dword(dev,TX_CONF,txconf);
6465 -
6466 - // V RTL suggested V //
6467 -// write_nic_dword(dev,TX_CONF,0x00e00707);
6468 -
6469 -
6470 -#ifdef DEBUG_TX
6471 - DMESG("txconf: %x %x",txconf,read_nic_dword(dev,TX_CONF));
6472 -#endif
6473 -
6474 - cmd=read_nic_byte(dev,CMD);
6475 - write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT));
6476 -
6477 -// mdelay(100);
6478 - //write_nic_dword(dev,TX_CONF,txconf);
6479 -// #endif
6480 -/*
6481 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6482 - write_nic_byte(dev, TX_DMA_POLLING, priv->dma_poll_mask);
6483 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
6484 - */
6485 -}
6486 -
6487 -#if 0
6488 -void rtl8180_beacon_tx_enable(struct net_device *dev)
6489 -{
6490 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6491 - priv->dma_poll_mask &=~(1<<TX_DMA_STOP_BEACON_SHIFT);
6492 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6493 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
6494 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
6495 -}
6496 -
6497 -
6498 -void rtl8180_
6499 -_disable(struct net_device *dev)
6500 -{
6501 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6502 - priv->dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
6503 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6504 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
6505 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
6506 -}
6507 -
6508 -#endif
6509 -
6510 -
6511 -void rtl8180_rtx_disable(struct net_device *dev)
6512 -{
6513 - u8 cmd;
6514 - int i;
6515 - struct r8180_priv *priv = ieee80211_priv(dev);
6516 -
6517 - cmd=read_nic_byte(dev,CMD);
6518 - write_nic_byte(dev, CMD, cmd &~ \
6519 - ((1<<CMD_RX_ENABLE_SHIFT)|(1<<CMD_TX_ENABLE_SHIFT)));
6520 - force_pci_posting(dev);
6521 - mdelay(10);
6522 - if(priv->rx_urb){
6523 - for(i=0;i<MAX_RX_URB;i++)
6524 - usb_kill_urb(priv->rx_urb[i]);
6525 - }
6526 - /*while (read_nic_byte(dev,CMD) & (1<<CMD_RX_ENABLE_SHIFT))
6527 - udelay(10);
6528 - */
6529 -
6530 -// if(!priv->rx_skb_complete)
6531 -// dev_kfree_skb_any(priv->rx_skb);
6532 -}
6533 -
6534 -
6535 -int alloc_tx_beacon_desc_ring(struct net_device *dev, int count)
6536 -{
6537 - #if 0
6538 - int i;
6539 - u32 *tmp;
6540 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6541 -
6542 - priv->txbeaconring = (u32*)pci_alloc_consistent(priv->pdev,
6543 - sizeof(u32)*8*count,
6544 - &priv->txbeaconringdma);
6545 - if (!priv->txbeaconring) return -1;
6546 - for (tmp=priv->txbeaconring,i=0;i<count;i++){
6547 - *tmp = *tmp &~ (1<<31); // descriptor empty, owned by the drv
6548 - /*
6549 - *(tmp+2) = (u32)dma_tmp;
6550 - *(tmp+3) = bufsize;
6551 - */
6552 - if(i+1<count)
6553 - *(tmp+4) = (u32)priv->txbeaconringdma+((i+1)*8*4);
6554 - else
6555 - *(tmp+4) = (u32)priv->txbeaconringdma;
6556 -
6557 - tmp=tmp+8;
6558 - }
6559 - #endif
6560 - return 0;
6561 -}
6562 -
6563 -
6564 -void rtl8180_reset(struct net_device *dev)
6565 -{
6566 -
6567 - u8 cr;
6568 -
6569 - /* make sure the analog power is on before
6570 - * reset, otherwise reset may fail
6571 - */
6572 - rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
6573 - rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
6574 -
6575 - rtl8180_irq_disable(dev);
6576 -
6577 - mdelay(200);
6578 - write_nic_byte_E(dev,0x18,0x10);
6579 - write_nic_byte_E(dev,0x18,0x11);
6580 - write_nic_byte_E(dev,0x18,0x00);
6581 - mdelay(200);
6582 -
6583 - cr=read_nic_byte(dev,CMD);
6584 - cr = cr & 2;
6585 - cr = cr | (1<<CMD_RST_SHIFT);
6586 - write_nic_byte(dev,CMD,cr);
6587 -
6588 - force_pci_posting(dev);
6589 -
6590 - mdelay(200);
6591 -
6592 - if(read_nic_byte(dev,CMD) & (1<<CMD_RST_SHIFT))
6593 - DMESGW("Card reset timeout!");
6594 - else
6595 - DMESG("Card successfully reset");
6596 -
6597 - rtl8180_set_mode(dev,EPROM_CMD_LOAD);
6598 - force_pci_posting(dev);
6599 - mdelay(200);
6600 -
6601 - /* after the eeprom load cycle, make sure we have
6602 - * correct anaparams
6603 - */
6604 - rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
6605 - rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
6606 -
6607 -}
6608 -
6609 -inline u16 ieeerate2rtlrate(int rate)
6610 -{
6611 - switch(rate){
6612 - case 10:
6613 - return 0;
6614 - case 20:
6615 - return 1;
6616 - case 55:
6617 - return 2;
6618 - case 110:
6619 - return 3;
6620 - case 60:
6621 - return 4;
6622 - case 90:
6623 - return 5;
6624 - case 120:
6625 - return 6;
6626 - case 180:
6627 - return 7;
6628 - case 240:
6629 - return 8;
6630 - case 360:
6631 - return 9;
6632 - case 480:
6633 - return 10;
6634 - case 540:
6635 - return 11;
6636 - default:
6637 - return 3;
6638 -
6639 - }
6640 -}
6641 -static u16 rtl_rate[] = {10,20,55,110,60,90,120,180,240,360,480,540};
6642 -inline u16 rtl8180_rate2rate(short rate)
6643 -{
6644 - if (rate >11) return 0;
6645 - return rtl_rate[rate];
6646 -}
6647 -
6648 -
6649 -void rtl8187_rx_isr(struct urb *rx_urb, struct pt_regs *regs)
6650 -{
6651 - struct net_device *dev = (struct net_device*)rx_urb->context;
6652 - struct r8180_priv *priv = ieee80211_priv(dev);
6653 -
6654 - priv->rxurb_task = rx_urb;
6655 -// DMESGW("David: Rx tasklet start!");
6656 - tasklet_schedule(&priv->irq_rx_tasklet);
6657 -// DMESGW("=David: Rx tasklet finish!");
6658 -}
6659 -
6660 -#if 0
6661 -void rtl8180_tx_queues_stop(struct net_device *dev)
6662 -{
6663 - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6664 - u8 dma_poll_mask = (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
6665 - dma_poll_mask |= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT);
6666 - dma_poll_mask |= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT);
6667 - dma_poll_mask |= (1<<TX_DMA_STOP_BEACON_SHIFT);
6668 -
6669 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6670 - write_nic_byte(dev,TX_DMA_POLLING,dma_poll_mask);
6671 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
6672 -}
6673 -#endif
6674 -
6675 -void rtl8180_data_hard_stop(struct net_device *dev)
6676 -{
6677 - //FIXME !!
6678 - #if 0
6679 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6680 - priv->dma_poll_mask |= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
6681 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6682 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
6683 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
6684 - #endif
6685 -}
6686 -
6687 -
6688 -void rtl8180_data_hard_resume(struct net_device *dev)
6689 -{
6690 - // FIXME !!
6691 - #if 0
6692 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6693 - priv->dma_poll_mask &= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT);
6694 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6695 - write_nic_byte(dev,TX_DMA_POLLING,priv->dma_poll_mask);
6696 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
6697 - #endif
6698 -}
6699 -
6700 -
6701 -/* this function TX data frames when the ieee80211 stack requires this.
6702 - * It checks also if we need to stop the ieee tx queue, eventually do it
6703 - */
6704 -void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate)
6705 -{
6706 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6707 -
6708 - short morefrag = 0;
6709 - unsigned long flags;
6710 - struct ieee80211_hdr *h = (struct ieee80211_hdr *) skb->data;
6711 -
6712 - if (le16_to_cpu(h->frame_ctl) & IEEE80211_FCTL_MOREFRAGS)
6713 - morefrag = 1;
6714 -// DMESG("%x %x", h->frame_ctl, h->seq_ctl);
6715 - /*
6716 - * This function doesn't require lock because we make
6717 - * sure it's called with the tx_lock already acquired.
6718 - * this come from the kernel's hard_xmit callback (trought
6719 - * the ieee stack, or from the try_wake_queue (again trought
6720 - * the ieee stack.
6721 - */
6722 - spin_lock_irqsave(&priv->tx_lock,flags);
6723 -
6724 - //DMESG("TX");
6725 - if (!check_nic_enought_desc(dev, LOW_PRIORITY)){
6726 - DMESG("Error: no TX slot ");
6727 - ieee80211_stop_queue(priv->ieee80211);
6728 - }
6729 -
6730 - rtl8180_tx(dev, (u32*)skb->data, skb->len, LOW_PRIORITY, morefrag,
6731 - ieeerate2rtlrate(rate));
6732 -
6733 - priv->stats.txdatapkt++;
6734 -
6735 - if (!check_nic_enought_desc(dev, LOW_PRIORITY))
6736 - ieee80211_stop_queue(priv->ieee80211);
6737 -
6738 - spin_unlock_irqrestore(&priv->tx_lock,flags);
6739 -
6740 -}
6741 -#if 0
6742 -/* This is a rough attempt to TX a frame
6743 - * This is called by the ieee 80211 stack to TX management frames.
6744 - * If the ring is full packet are dropped (for data frame the queue
6745 - * is stopped before this can happen).
6746 - */
6747 -int rtl8180_hard_start_xmit(struct sk_buff *skb,struct net_device *dev)
6748 -{
6749 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
6750 - int ret;
6751 - unsigned long flags;
6752 -
6753 - spin_lock_irqsave(&priv->tx_lock,flags);
6754 -
6755 - ret = rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY, 0,DEFAULT_BASICRATE);
6756 -/*
6757 - int i;
6758 - for(i=0;i<skb->len;i++)
6759 - printk("%x ", skb->data[i]);
6760 - printk("--------------------\n");
6761 -*/
6762 - priv->ieee80211->stats.tx_bytes+=skb->len;
6763 - priv->ieee80211->stats.tx_packets++;
6764 -
6765 - spin_unlock_irqrestore(&priv->tx_lock,flags);
6766 -
6767 - dev_kfree_skb_any(skb);
6768 - return ret;
6769 -}
6770 -#endif
6771 -
6772 -#if 0
6773 -// longpre 144+48 shortpre 72+24
6774 -u16 rtl8180_len2duration(u32 len, short rate,short* ext)
6775 -{
6776 - u16 duration;
6777 - u16 drift;
6778 - *ext=0;
6779 -
6780 - switch(rate){
6781 - case 0://1mbps
6782 - *ext=0;
6783 - duration = ((len+4)<<4) /0x2;
6784 - drift = ((len+4)<<4) % 0x2;
6785 - if(drift ==0 ) break;
6786 - duration++;
6787 - break;
6788 -
6789 - case 1://2mbps
6790 - *ext=0;
6791 - duration = ((len+4)<<4) /0x4;
6792 - drift = ((len+4)<<4) % 0x4;
6793 - if(drift ==0 ) break;
6794 - duration++;
6795 - break;
6796 -
6797 - case 2: //5.5mbps
6798 - *ext=0;
6799 - duration = ((len+4)<<4) /0xb;
6800 - drift = ((len+4)<<4) % 0xb;
6801 - if(drift ==0 )
6802 - break;
6803 - duration++;
6804 - break;
6805 -
6806 - default:
6807 - case 3://11mbps
6808 - *ext=0;
6809 - duration = ((len+4)<<4) /0x16;
6810 - drift = ((len+4)<<4) % 0x16;
6811 - if(drift ==0 )
6812 - break;
6813 - duration++;
6814 - if(drift > 6)
6815 - break;
6816 - *ext=1;
6817 - break;
6818 - }
6819 -
6820 - return duration;
6821 -}
6822 -#endif
6823 -
6824 -void rtl8180_try_wake_queue(struct net_device *dev, int pri);
6825 -
6826 -void rtl8187_lptx_isr(struct urb *tx_urb, struct pt_regs *regs)
6827 -{
6828 - struct net_device *dev = (struct net_device*)tx_urb->context;
6829 - struct r8180_priv *priv = ieee80211_priv(dev);
6830 - if(tx_urb->status == 0)
6831 - priv->stats.txlpokint++;
6832 - else
6833 - priv->stats.txlperr++;
6834 - kfree(tx_urb->transfer_buffer);
6835 - usb_free_urb(tx_urb);
6836 - atomic_dec(&priv->tx_lp_pending);
6837 - rtl8180_try_wake_queue(dev,LOW_PRIORITY);
6838 -}
6839 -
6840 -
6841 -void rtl8187_beacon_stop(struct net_device *dev)
6842 -{
6843 - u8 msr, msrm, msr2;
6844 - msr = read_nic_byte(dev, MSR);
6845 - msrm = msr & MSR_LINK_MASK;
6846 - msr2 = msr & ~MSR_LINK_MASK;
6847 - if ((msrm == (MSR_LINK_ADHOC<<MSR_LINK_SHIFT) ||
6848 - (msrm == (MSR_LINK_MASTER<<MSR_LINK_SHIFT)))){
6849 - write_nic_byte(dev, MSR, msr2 | MSR_LINK_NONE);
6850 - write_nic_byte(dev, MSR, msr);
6851 - }
6852 -
6853 -
6854 -}
6855 -
6856 -
6857 -void rtl8187_net_update(struct net_device *dev)
6858 -{
6859 -
6860 - struct r8180_priv *priv = ieee80211_priv(dev);
6861 - struct ieee80211_network *net;
6862 - net = & priv->ieee80211->current_network;
6863 -
6864 -
6865 - write_nic_dword(dev,BSSID,((u32*)net->bssid)[0]);
6866 - write_nic_word(dev,BSSID+4,((u16*)net->bssid)[2]);
6867 - //for(i=0;i<ETH_ALEN;i++)
6868 - // write_nic_byte(dev,BSSID+i,net->bssid[i]);
6869 -
6870 - rtl8180_update_msr(dev);
6871 -
6872 -// rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
6873 - write_nic_word(dev, AtimWnd, 2);
6874 - write_nic_word(dev, AtimtrItv, 100);
6875 - write_nic_word(dev, BEACON_INTERVAL, net->beacon_interval);
6876 - write_nic_word(dev, BcnIntTime, 100);
6877 -
6878 -
6879 -}
6880 -
6881 -void rtl8187_beacon_tx(struct net_device *dev)
6882 -{
6883 -
6884 - struct r8180_priv *priv = ieee80211_priv(dev);
6885 - struct sk_buff *skb;
6886 - int i = 0;
6887 -
6888 - rtl8187_net_update(dev);
6889 -
6890 - skb = ieee80211_get_beacon(priv->ieee80211);
6891 -
6892 -
6893 - if(!skb){
6894 - DMESG("not enought memory for allocating beacon");
6895 - return;
6896 - }
6897 -
6898 -#if 0
6899 - while(MAX_TX_URB!=atomic_read(&priv->tx_np_pending)){
6900 - msleep_interruptible_rtl(HZ/2);
6901 - if(i++ > 20){
6902 - DMESG("get stuck to wait EP3 become ready");
6903 - return ;
6904 - }
6905 - }
6906 -#endif
6907 - write_nic_byte(dev, BQREQ, read_nic_byte(dev, BQREQ) | (1<<7));
6908 -
6909 - i=0;
6910 - //while(!read_nic_byte(dev,BQREQ & (1<<7)))
6911 - while( (read_nic_byte(dev, BQREQ) & (1<<7)) == 0 )
6912 - {
6913 - msleep_interruptible_rtl(HZ/2);
6914 - if(i++ > 10){
6915 - DMESG("get stuck to wait HW beacon to be ready");
6916 - return ;
6917 - }
6918 - }
6919 -
6920 - rtl8180_tx(dev, (u32*)skb->data, skb->len, NORM_PRIORITY,
6921 - 0, priv->ieee80211->basic_rate);
6922 -
6923 -}
6924 -
6925 -void rtl8187_nptx_isr(struct urb *tx_urb, struct pt_regs *regs)
6926 -{
6927 - struct net_device *dev = (struct net_device*)tx_urb->context;
6928 - struct r8180_priv *priv = ieee80211_priv(dev);
6929 - if(tx_urb->status == 0)
6930 - priv->stats.txnpokint++;
6931 - else
6932 - priv->stats.txnperr++;
6933 - kfree(tx_urb->transfer_buffer);
6934 - usb_free_urb(tx_urb);
6935 - atomic_dec(&priv->tx_np_pending);
6936 - //rtl8180_try_wake_queue(dev,NORM_PRIORITY);
6937 -}
6938 -
6939 -
6940 -/* This function do the real dirty work: it sends a TX command
6941 - * descriptor plus data URB
6942 - */
6943 -
6944 -short rtl8180_tx(struct net_device *dev, u32* txbuf, int len, priority_t priority,
6945 - short morefrag, short rate)
6946 -{
6947 - u32 *tx;
6948 -// u16 duration;
6949 -// short ext;
6950 - int pend ;
6951 - int status;
6952 - struct urb *tx_urb;
6953 - int urb_len;
6954 - struct r8180_priv *priv = ieee80211_priv(dev);
6955 -// int rate = ieeerate2rtlrate(priv->ieee80211->rate);
6956 -
6957 - pend = atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
6958 - /* we are locked here so the two atomic_read and inc are executed without interleaves */
6959 - if( pend > MAX_TX_URB){
6960 - if(priority == NORM_PRIORITY)
6961 - priv->stats.txnpdrop++;
6962 - else
6963 - priv->stats.txlpdrop++;
6964 - return -1;
6965 - }
6966 -
6967 -
6968 - //tx = kmalloc((len + 4*3), GFP_ATOMIC);
6969 - urb_len = len + 4*3;
6970 - if((0 == urb_len%64)||(0 == urb_len%512)) {
6971 - urb_len += 1;
6972 - }
6973 - tx = kmalloc(urb_len, GFP_ATOMIC);
6974 - if(!tx) return -ENOMEM;
6975 -printk(KERN_WARNING "urb_len = %d\n", urb_len);
6976 - tx_urb = usb_alloc_urb(0,GFP_ATOMIC);
6977 -
6978 - if(!tx_urb){
6979 -
6980 - kfree(tx);
6981 - return -ENOMEM;
6982 - }
6983 -
6984 - memcpy(tx+3,txbuf,len);
6985 - tx[0] = 0;
6986 - tx[0] |= len & 0xfff;
6987 - tx[0] |= (1<<15);
6988 -
6989 -// if(priv->shortpre)
6990 -// tx[0] |= (1<<16);
6991 -
6992 - //if(len > priv->rts_threshold){
6993 -// tx[0] |= (1<<23); //ENABLE RTS
6994 -// tx[0] |= (1<<18); //ENABLE CTS
6995 - //}
6996 - if(morefrag) tx[0] |= (1<<17);
6997 - tx[0] |= (ieeerate2rtlrate(priv->ieee80211->basic_rate) << 19); /* RTS RATE - should be basic rate */
6998 - tx[0] |= (rate << 24);
6999 - tx[1] = 0;
7000 -
7001 -// duration = rtl8180_len2duration(len,
7002 -// rate,&ext);
7003 -// tx[1] |= (duration & 0x7fff) <<16;
7004 -// if(ext) tx[1] |= (1<<31);
7005 -
7006 -
7007 -// tx[2] = 0x303020;
7008 - tx[2] = 3; // CW min
7009 - tx[2] |= (7<<4); //CW max
7010 - tx[2] |= (11<<8);//(priv->retry_data<<8); //retry lim
7011 -
7012 -// printk("%x\n%x\n",tx[0],tx[1]);
7013 -
7014 - #ifdef DUMP_TX
7015 - int i;
7016 - printk("<Tx pkt>--rate %x---",rate);
7017 - for (i = 0; i < (len + 3); i++)
7018 - printk("%2x", ((u8*)tx)[i]);
7019 - printk("---------------\n");
7020 - #endif
7021 -
7022 -
7023 - /* FIXME check what EP is for low/norm PRI */
7024 - usb_fill_bulk_urb(tx_urb,priv->udev,
7025 - usb_sndbulkpipe(priv->udev,(priority == LOW_PRIORITY) ? 2:3), tx,
7026 - urb_len, (priority == LOW_PRIORITY)?rtl8187_lptx_isr:rtl8187_nptx_isr, dev);
7027 - status = usb_submit_urb(tx_urb, GFP_ATOMIC);
7028 - if (!status){
7029 - atomic_inc((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending);
7030 - return 0;
7031 - }else{
7032 - DMESGE("Error TX URB %d, error %d",
7033 - atomic_read((priority == NORM_PRIORITY)? &priv->tx_np_pending : &priv->tx_lp_pending),
7034 - status);
7035 - return -1;
7036 - }
7037 -}
7038 -
7039 -
7040 -
7041 -void rtl8180_irq_rx_tasklet(struct r8180_priv * priv);
7042 -
7043 -
7044 -short rtl8187_usb_initendpoints(struct net_device *dev)
7045 -{
7046 - struct r8180_priv *priv = ieee80211_priv(dev);
7047 - int i;
7048 -
7049 - priv->rx_urb = (struct urb**) kmalloc (sizeof(struct urb*) * MAX_RX_URB, GFP_KERNEL);
7050 -
7051 - for(i=0;i<MAX_RX_URB;i++){
7052 - priv->rx_urb[i] = usb_alloc_urb(0,GFP_KERNEL);
7053 - if(!priv->rx_urb[i])
7054 - goto destroy;
7055 -
7056 - priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL);
7057 - if(!priv->rx_urb[i]->transfer_buffer)
7058 - goto destroy1;
7059 -
7060 - priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE;
7061 - }
7062 -
7063 - return 0;
7064 -
7065 -destroy1:
7066 - usb_free_urb(priv->rx_urb[i]);
7067 -
7068 -destroy:
7069 - while (--i >= 0){
7070 - kfree(priv->rx_urb[i]->transfer_buffer);
7071 - usb_free_urb(priv->rx_urb[i]);
7072 - }
7073 -
7074 - kfree(priv->rx_urb);
7075 -
7076 - priv->rx_urb = NULL;
7077 - DMESGE("Endpoint Alloc Failure");
7078 - return -ENOMEM;
7079 -
7080 -}
7081 -
7082 -void rtl8187_usb_deleteendpoints(struct net_device *dev)
7083 -{
7084 - struct r8180_priv *priv = ieee80211_priv(dev);
7085 - int i;
7086 -
7087 - if(priv->rx_urb){
7088 - for(i=0;i<MAX_RX_URB;i++){
7089 - usb_kill_urb(priv->rx_urb[i]);
7090 - kfree(priv->rx_urb[i]->transfer_buffer);
7091 - usb_free_urb(priv->rx_urb[i]);
7092 - }
7093 - kfree(priv->rx_urb);
7094 - priv->rx_urb = NULL;
7095 -
7096 - }
7097 -
7098 -}
7099 -
7100 -
7101 -void rtl8187_set_rate(struct net_device *dev)
7102 -{
7103 - int i;
7104 - u16 word;
7105 - int basic_rate,min_rr_rate,max_rr_rate;
7106 -
7107 -// struct r8180_priv *priv = ieee80211_priv(dev);
7108 -
7109 - //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
7110 -// priv->ieee80211->state == IEEE80211_LINKED){
7111 - basic_rate = ieeerate2rtlrate(240);
7112 - min_rr_rate = ieeerate2rtlrate(60);
7113 - max_rr_rate = ieeerate2rtlrate(240);
7114 -
7115 -//
7116 -// }else{
7117 -// basic_rate = ieeerate2rtlrate(20);
7118 -// min_rr_rate = ieeerate2rtlrate(10);
7119 -// max_rr_rate = ieeerate2rtlrate(110);
7120 -// }
7121 -
7122 - write_nic_byte(dev, RESP_RATE,
7123 - max_rr_rate<<MAX_RESP_RATE_SHIFT| min_rr_rate<<MIN_RESP_RATE_SHIFT);
7124 -
7125 - word = read_nic_word(dev, BRSR);
7126 - word &= ~BRSR_MBR_8185;
7127 -
7128 -
7129 - for(i=0;i<=basic_rate;i++)
7130 - word |= (1<<i);
7131 -
7132 - write_nic_word(dev, BRSR, word);
7133 - //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
7134 -}
7135 -
7136 -
7137 -void rtl8187_link_change(struct net_device *dev)
7138 -{
7139 -// int i;
7140 -
7141 - struct r8180_priv *priv = ieee80211_priv(dev);
7142 - //write_nic_word(dev, BintrItv, net->beacon_interval);
7143 - rtl8187_net_update(dev);
7144 - /*update timing params*/
7145 - rtl8180_set_chan(dev, priv->chan);
7146 -
7147 - rtl8187_set_rxconf(dev);
7148 -}
7149 -
7150 -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv);
7151 -
7152 -short rtl8180_init(struct net_device *dev)
7153 -{
7154 -
7155 - struct r8180_priv *priv = ieee80211_priv(dev);
7156 - int i, j;
7157 - u16 word;
7158 - int ch;
7159 - //u16 version;
7160 - //u8 hw_version;
7161 - //u8 config3;
7162 -
7163 - //FIXME: these constants are placed in a bad pleace.
7164 -
7165 -// priv->txbuffsize = 1024;
7166 -// priv->txringcount = 32;
7167 -// priv->rxbuffersize = 1024;
7168 -// priv->rxringcount = 32;
7169 -// priv->txbeaconcount = 3;
7170 -// priv->rx_skb_complete = 1;
7171 - //priv->txnp_pending.ispending=0;
7172 - /* ^^ the SKB does not containt a partial RXed
7173 - * packet (is empty)
7174 - */
7175 -
7176 - if(!channels){
7177 - DMESG("No channels, aborting");
7178 - return -1;
7179 - }
7180 - ch=channels;
7181 - // set channels 1..14 allowed in given locale
7182 - for (i=1; i<=14; i++) {
7183 - (priv->ieee80211->channel_map)[i] = (u8)(ch & 0x01);
7184 - ch >>= 1;
7185 - }
7186 - //memcpy(priv->stats,0,sizeof(struct Stats));
7187 -
7188 - //priv->irq_enabled=0;
7189 -
7190 -// priv->stats.rxdmafail=0;
7191 - priv->stats.txrdu=0;
7192 -// priv->stats.rxrdu=0;
7193 -// priv->stats.rxnolast=0;
7194 -// priv->stats.rxnodata=0;
7195 - //priv->stats.rxreset=0;
7196 - //priv->stats.rxwrkaround=0;
7197 -// priv->stats.rxnopointer=0;
7198 - priv->stats.txnperr=0;
7199 - priv->stats.txresumed=0;
7200 -// priv->stats.rxerr=0;
7201 -// priv->stats.rxoverflow=0;
7202 -// priv->stats.rxint=0;
7203 - priv->stats.txnpokint=0;
7204 - /*priv->stats.txhpokint=0;
7205 - priv->stats.txhperr=0;*/
7206 - priv->stats.rxurberr=0;
7207 - priv->stats.rxstaterr=0;
7208 - priv->stats.txoverflow=0;
7209 - priv->stats.rxok=0;
7210 -// priv->stats.txbeaconerr=0;
7211 - priv->stats.txlperr=0;
7212 - priv->stats.txlpokint=0;
7213 -
7214 - priv->ieee80211->iw_mode = IW_MODE_INFRA;
7215 -
7216 - priv->retry_rts = DEFAULT_RETRY_RTS;
7217 - priv->retry_data = DEFAULT_RETRY_DATA;
7218 - priv->ieee80211->rate = 110; //11 mbps
7219 - priv->ieee80211->short_slot = 1;
7220 - priv->ieee80211->mode = IEEE_G;
7221 - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0;
7222 - spin_lock_init(&priv->tx_lock);
7223 - INIT_WORK(&priv->reset_wq,(void(*)(void*)) rtl8180_restart,dev);
7224 - sema_init(&priv->wx_sem,1);
7225 - tasklet_init(&priv->irq_rx_tasklet,
7226 - (void(*)(unsigned long))rtl8180_irq_rx_tasklet,
7227 - (unsigned long)priv);
7228 -
7229 - //priv->ieee80211->func =
7230 - // kmalloc(sizeof(struct ieee80211_helper_functions),GFP_KERNEL);
7231 - //memset(priv->ieee80211->func, 0,
7232 - // sizeof(struct ieee80211_helper_functions));
7233 - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL;
7234 - priv->ieee80211->iw_mode = IW_MODE_INFRA;
7235 - priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN |
7236 - IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ |
7237 - IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE |
7238 - /*IEEE_SOFTMAC_BEACONS | */IEEE_SOFTMAC_SINGLE_QUEUE;
7239 -
7240 - priv->ieee80211->active_scan = 1;
7241 - priv->ieee80211->rate = 110; //11 mbps
7242 - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION;
7243 - priv->ieee80211->host_encrypt = 1;
7244 - priv->ieee80211->host_decrypt = 1;
7245 - priv->ieee80211->start_send_beacons = rtl8187_beacon_tx;
7246 - priv->ieee80211->stop_send_beacons = rtl8187_beacon_stop;
7247 - //priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit;
7248 - priv->ieee80211->softmac_hard_start_xmit = NULL;
7249 - priv->ieee80211->set_chan = rtl8180_set_chan;
7250 - priv->ieee80211->link_change = rtl8187_link_change;
7251 - priv->ieee80211->softmac_data_hard_start_xmit = rtl8180_hard_data_xmit;
7252 - priv->ieee80211->data_hard_stop = rtl8180_data_hard_stop;
7253 - priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume;
7254 - //priv->ieee80211->start_send_beacons = NULL;
7255 - //priv->ieee80211->stop_send_beacons = NULL;
7256 -
7257 - priv->ieee80211->fts = DEFAULT_FRAG_THRESHOLD;
7258 -
7259 - priv->card_8185 = 2;
7260 - priv->phy_ver = 2;
7261 - priv->card_type = USB;
7262 -
7263 - #if 0
7264 - hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT;
7265 -
7266 - switch (hw_version){
7267 - case HW_VERID_R8185_ABC:
7268 - DMESG("MAC controller is a RTL8185 b/g");
7269 - priv->card_8185 = 1;
7270 - /* you should not find a card with 8225 PHY ver < C*/
7271 - priv->phy_ver = 2;
7272 - break;
7273 -
7274 - case HW_VERID_R8185_D:
7275 - DMESG("MAC controller is a RTL8185 b/g (V. D)");
7276 - priv->card_8185 = 2;
7277 - /* you should not find a card with 8225 PHY ver < C*/
7278 - priv->phy_ver = 2;
7279 - break;
7280 -
7281 - case HW_VERID_R8180_ABCD:
7282 - DMESG("MAC controller is a RTL8180");
7283 - priv->card_8185 = 0;
7284 - break;
7285 -
7286 - case HW_VERID_R8180_F:
7287 - DMESG("MAC controller is a RTL8180 (v. F)");
7288 - priv->card_8185 = 0;
7289 - break;
7290 -
7291 - default:
7292 - DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
7293 - priv->card_8185 = 0;
7294 - break;
7295 - }
7296 -
7297 -
7298 - /* you should not found any 8185 Ver B Card */
7299 - priv->card_8185_Bversion = 0;
7300 -
7301 - config3 = read_nic_byte(dev, CONFIG3);
7302 - if(config3 & 0x8){
7303 - priv->card_type = CARDBUS;
7304 - DMESG("This is a CARDBUS NIC");
7305 - }
7306 - else if( config3 & 0x4){
7307 - priv->card_type = MINIPCI;
7308 - DMESG("This is a MINI-PCI NIC");
7309 - }else{
7310 - priv->card_type = PCI;
7311 - DMESG("This is a PCI NIC");
7312 - }
7313 - #endif
7314 - priv->enable_gpio0 = 0;
7315 -
7316 -
7317 - /* commented out just because we already do
7318 - this when resetting the card
7319 - andrea 20050924
7320 - */
7321 - #if 0
7322 -
7323 - u8 txcr, txreg50;
7324 - u32 txreg54, txreg60;
7325 -
7326 - /* enable A/D D/A register */
7327 - txcr = read_nic_byte(dev, 0x59);
7328 -// DMESG("<txcr:%x>", txcr);
7329 - //write_nic_word(dev, 0x59, 0x44);
7330 - write_nic_byte(dev, 0x59, 0x44);
7331 - //write_nic_byte(dev, 0x59, 0xea);
7332 - txcr = read_nic_byte(dev, 0x59);
7333 -// DMESG("<<txcr:%x>>", txcr);
7334 -
7335 - txreg50 = read_nic_byte(dev, 0x50);
7336 - // DMESG("<txreg50:%x>", txreg50);
7337 - write_nic_byte(dev, 0x50, 0xc0);
7338 - txreg50 = read_nic_byte(dev, 0x50);
7339 - // DMESG("<<txreg50:%x>>", txreg50);
7340 -
7341 -
7342 - txreg54 = read_nic_dword(dev, 0x54);
7343 - // DMESG("<txreg54:%x>", txreg54);
7344 - txreg54 = 0xa0000a59;
7345 - // DMESG("<<txreg54:%x>>", txreg54);
7346 - write_nic_dword(dev, 0x54, txreg54);
7347 - txreg54 = read_nic_dword(dev, 0x54);
7348 - // DMESG("<<<txreg54:%x>>>", txreg54);
7349 -
7350 - txreg60 = read_nic_dword(dev, 0x60);
7351 - // DMESG("<txreg60:%x>", txreg60);
7352 -
7353 - write_nic_byte(dev, 0x50, 0x0);
7354 - txcr = read_nic_byte(dev, 0x50);
7355 - // DMESG("<<txcr:%x>>", txcr);
7356 -
7357 -#endif
7358 -
7359 - /*the eeprom type is stored in RCR register bit #6 */
7360 - if (RCR_9356SEL & read_nic_dword(dev, RCR)){
7361 - priv->epromtype=EPROM_93c56;
7362 - DMESG("Reported EEPROM chip is a 93c56 (2Kbit)");
7363 - }else{
7364 - priv->epromtype=EPROM_93c46;
7365 - DMESG("Reported EEPROM chip is a 93c46 (1Kbit)");
7366 - }
7367 -
7368 - dev->get_stats = rtl8180_stats;
7369 -
7370 - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff;
7371 - dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8;
7372 - dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff;
7373 - dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8;
7374 - dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff;
7375 - dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8;
7376 -
7377 - DMESG("Card MAC address is "MAC_FMT, MAC_ARG(dev->dev_addr));
7378 -
7379 - for(i=1,j=0; i<6; i+=2,j++){
7380 -
7381 - word = eprom_read(dev,EPROM_TXPW0 + j);
7382 - priv->chtxpwr[i]=word & 0xf;
7383 - priv->chtxpwr_ofdm[i]=(word & 0xf0)>>4;
7384 - priv->chtxpwr[i+1]=(word & 0xf00)>>8;
7385 - priv->chtxpwr_ofdm[i+1]=(word & 0xf000)>>12;
7386 - }
7387 -
7388 - for(i=1,j=0; i<4; i+=2,j++){
7389 -
7390 - word = eprom_read(dev,EPROM_TXPW1 + j);
7391 - priv->chtxpwr[i+6]=word & 0xf;
7392 - priv->chtxpwr_ofdm[i+6]=(word & 0xf0)>>4;
7393 - priv->chtxpwr[i+6+1]=(word & 0xf00)>>8;
7394 - priv->chtxpwr_ofdm[i+6+1]=(word & 0xf000)>>12;
7395 - }
7396 -
7397 - for(i=1,j=0; i<4; i+=2,j++){
7398 -
7399 - word = eprom_read(dev,EPROM_TXPW2 + j);
7400 - priv->chtxpwr[i+6+4]=word & 0xf;
7401 - priv->chtxpwr_ofdm[i+6+4]=(word & 0xf0)>>4;
7402 - priv->chtxpwr[i+6+4+1]=(word & 0xf00)>>8;
7403 - priv->chtxpwr_ofdm[i+6+4+1]=(word & 0xf000)>>12;
7404 - }
7405 -
7406 -
7407 - priv->rf_chip = 0xff & eprom_read(dev,EPROM_RFCHIPID);
7408 -
7409 - word = eprom_read(dev,EPROM_TXPW_BASE);
7410 - priv->cck_txpwr_base = word & 0xf;
7411 - priv->ofdm_txpwr_base = (word>>4) & 0xf;
7412 -
7413 - /* check RF frontend chipset */
7414 -
7415 - switch (priv->rf_chip) {
7416 -
7417 - case EPROM_RFCHIPID_RTL8225U:
7418 -
7419 - DMESG("Card reports RF frontend Realtek 8225");
7420 - DMESGW("This driver has EXPERIMENTAL support for this chipset.");
7421 - DMESGW("use it with care and at your own risk and");
7422 - DMESGW("**PLEASE** REPORT SUCCESS/INSUCCESS TO andreamrl@tiscali.it");
7423 - if(rtl8225_is_V_z2(dev)){
7424 - priv->rf_init = rtl8225z2_rf_init;
7425 - priv->rf_set_chan = rtl8225z2_rf_set_chan;
7426 - priv->rf_set_sens = NULL;
7427 - DMESG("This seems a new V2 radio");
7428 - }else{
7429 - priv->rf_init = rtl8225_rf_init;
7430 - priv->rf_set_chan = rtl8225_rf_set_chan;
7431 - priv->rf_set_sens = rtl8225_rf_set_sens;
7432 - DMESG("This seems a legacy 1st version radio");
7433 - }
7434 - priv->rf_close = rtl8225_rf_close;
7435 -
7436 - priv->max_sens = RTL8225_RF_MAX_SENS;
7437 - priv->sens = RTL8225_RF_DEF_SENS;
7438 - break;
7439 -
7440 - default:
7441 - DMESGW("Unknown RF module %x",priv->rf_chip);
7442 - DMESGW("Exiting...");
7443 - return -1;
7444 -
7445 - }
7446 -
7447 -// DMESG("Energy threshold: %x",priv->cs_treshold);
7448 - DMESG("PAPE from CONFIG2: %x",read_nic_byte(dev,CONFIG2)&0x7);
7449 - //DMESG("CONFIG2: %x ECONFIG2: %x",read_nic_byte(dev,CONFIG2),eprom_read(dev,EPROM_CONFIG2));
7450 -
7451 - if(rtl8187_usb_initendpoints(dev)!=0){
7452 - DMESG("Endopoints initialization failed");
7453 - return -ENOMEM;
7454 - }
7455 -#if 0
7456 - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
7457 - return -ENOMEM;
7458 -
7459 - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
7460 - TX_NORMPRIORITY_RING_ADDR))
7461 - return -ENOMEM;
7462 -
7463 - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
7464 - TX_HIGHPRIORITY_RING_ADDR))
7465 - return -ENOMEM;
7466 -
7467 - if (0!=alloc_tx_desc_ring(dev, priv->txbuffsize, priv->txringcount,
7468 - TX_LOWPRIORITY_RING_ADDR))
7469 - return -ENOMEM;
7470 -
7471 -
7472 - if (0!=alloc_tx_beacon_desc_ring(dev, priv->txbeaconcount))
7473 - return -ENOMEM;
7474 -#endif
7475 -
7476 -
7477 -#ifdef DEBUG_EPROM
7478 - dump_eprom(dev);
7479 -#endif
7480 - return 0;
7481 -
7482 -}
7483 -
7484 -void rtl8185_rf_pins_enable(struct net_device *dev)
7485 -{
7486 -/* u16 tmp;
7487 - tmp = read_nic_word(dev, RFPinsEnable);*/
7488 - write_nic_word(dev, RFPinsEnable, 0x1ff7);// | tmp);
7489 -}
7490 -
7491 -
7492 -void rtl8185_set_anaparam2(struct net_device *dev, u32 a)
7493 -{
7494 - u8 conf3;
7495 -
7496 - rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
7497 -
7498 - conf3 = read_nic_byte(dev, CONFIG3);
7499 - write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
7500 -
7501 - write_nic_dword(dev, ANAPARAM2, a);
7502 -
7503 - conf3 = read_nic_byte(dev, CONFIG3);
7504 - write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
7505 -
7506 - rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
7507 -
7508 -}
7509 -
7510 -
7511 -void rtl8180_set_anaparam(struct net_device *dev, u32 a)
7512 -{
7513 - u8 conf3;
7514 -
7515 - rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
7516 -
7517 - conf3 = read_nic_byte(dev, CONFIG3);
7518 - write_nic_byte(dev, CONFIG3, conf3 | (1<<CONFIG3_ANAPARAM_W_SHIFT));
7519 -
7520 - write_nic_dword(dev, ANAPARAM, a);
7521 -
7522 - conf3 = read_nic_byte(dev, CONFIG3);
7523 - write_nic_byte(dev, CONFIG3, conf3 &~(1<<CONFIG3_ANAPARAM_W_SHIFT));
7524 -
7525 - rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
7526 -
7527 -}
7528 -
7529 -
7530 -void rtl8185_tx_antenna(struct net_device *dev, u8 ant)
7531 -{
7532 - write_nic_byte(dev, TX_ANTENNA, ant);
7533 - force_pci_posting(dev);
7534 - mdelay(1);
7535 -}
7536 -
7537 -
7538 -void rtl8187_write_phy(struct net_device *dev, u8 adr, u32 data)
7539 -{
7540 - //u8 phyr;
7541 - u32 phyw;
7542 -// int i;
7543 -
7544 - adr |= 0x80;
7545 -
7546 - phyw= ((data<<8) | adr);
7547 -
7548 -
7549 -
7550 - // Note that, we must write 0xff7c after 0x7d-0x7f to write BB register.
7551 - write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24));
7552 - write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16));
7553 - write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8));
7554 - write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff) ));
7555 -
7556 - //read_nic_dword(dev, PHY_ADR);
7557 -#if 0
7558 - for(i=0;i<10;i++){
7559 - write_nic_dword(dev, PHY_ADR, 0xffffff7f & phyw);
7560 - phyr = read_nic_byte(dev, PHY_READ);
7561 - if(phyr == (data&0xff)) break;
7562 -
7563 - }
7564 -#endif
7565 - /* this is ok to fail when we write AGC table. check for AGC table might be
7566 - * done by masking with 0x7f instead of 0xff
7567 - */
7568 - //if(phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data, adr);
7569 - mdelay(1);
7570 -}
7571 -
7572 -
7573 -inline void write_phy_ofdm (struct net_device *dev, u8 adr, u32 data)
7574 -{
7575 - data = data & 0xff;
7576 - rtl8187_write_phy(dev, adr, data);
7577 -}
7578 -
7579 -
7580 -void write_phy_cck (struct net_device *dev, u8 adr, u32 data)
7581 -{
7582 - data = data & 0xff;
7583 - rtl8187_write_phy(dev, adr, data | 0x10000);
7584 -}
7585 -
7586 -
7587 -void rtl8180_adapter_start(struct net_device *dev)
7588 -{
7589 - struct r8180_priv *priv = ieee80211_priv(dev);
7590 - //u32 anaparam;
7591 - //u8 config3;
7592 -
7593 - //rtl8180_rtx_disable(dev);
7594 - rtl8180_reset(dev);
7595 -
7596 - write_nic_byte(dev,0x85,0);
7597 - write_nic_byte(dev,0x91,0);
7598 -
7599 - /* light blink! */
7600 - write_nic_byte(dev,0x85,4);
7601 - write_nic_byte(dev,0x91,1);
7602 - write_nic_byte(dev,0x90,0);
7603 -
7604 - priv->irq_mask = 0xffff;
7605 -/*
7606 - priv->dma_poll_mask = 0;
7607 - priv->dma_poll_mask|= (1<<TX_DMA_STOP_BEACON_SHIFT);
7608 -*/
7609 -// rtl8180_beacon_tx_disable(dev);
7610 -
7611 - rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
7612 - write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]);
7613 - write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff );
7614 -
7615 - rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
7616 - rtl8180_update_msr(dev);
7617 -
7618 - rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
7619 -
7620 - write_nic_word(dev,0xf4,0xffff);
7621 - write_nic_byte(dev,
7622 - CONFIG1, (read_nic_byte(dev,CONFIG1) & 0x3f) | 0x80);
7623 -
7624 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
7625 -
7626 - write_nic_dword(dev,INT_TIMEOUT,0);
7627 -
7628 -#ifdef DEBUG_REGISTERS
7629 - rtl8180_dump_reg(dev);
7630 -#endif
7631 -
7632 -
7633 - write_nic_byte(dev, WPA_CONFIG, 0);
7634 -
7635 - write_nic_byte(dev, RATE_FALLBACK, 0x81);
7636 - rtl8187_set_rate(dev);
7637 -
7638 - priv->rf_init(dev);
7639 -
7640 - if(priv->rf_set_sens != NULL)
7641 - priv->rf_set_sens(dev,priv->sens);
7642 -
7643 - write_nic_word(dev,0x5e,1);
7644 -
7645 - #if 1
7646 - //mdelay(1);
7647 - write_nic_word(dev,0xfe,0x10);
7648 -// mdelay(1);
7649 - #endif
7650 - write_nic_byte(dev, TALLY_SEL, 0x80);//Set NQ retry count
7651 -
7652 - write_nic_byte(dev, 0xff, 0x60);
7653 -
7654 - write_nic_word(dev,0x5e,0);
7655 -
7656 -
7657 - rtl8180_irq_enable(dev);
7658 - /*DMESG ("lfree %d",get_curr_tx_free_desc(dev,LOW_PRIORITY));
7659 -
7660 - DMESG ("nfree %d",get_curr_tx_free_desc(dev,NORM_PRIORITY));
7661 -
7662 - DMESG ("hfree %d",get_curr_tx_free_desc(dev,HI_PRIORITY));
7663 - if(check_nic_enought_desc(dev,NORM_PRIORITY)) DMESG("NORM OK");
7664 - if(check_nic_enought_desc(dev,HI_PRIORITY)) DMESG("HI OK");
7665 - if(check_nic_enought_desc(dev,LOW_PRIORITY)) DMESG("LOW OK");*/
7666 -}
7667 -
7668 -
7669 -
7670 -/* this configures registers for beacon tx and enables it via
7671 - * rtl8180_beacon_tx_enable(). rtl8180_beacon_tx_disable() might
7672 - * be used to stop beacon transmission
7673 - */
7674 -#if 0
7675 -void rtl8180_start_tx_beacon(struct net_device *dev)
7676 -{
7677 - int i;
7678 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
7679 - u16 word;
7680 - DMESG("Enabling beacon TX");
7681 - //write_nic_byte(dev, 0x42,0xe6);// TCR
7682 - //rtl8180_init_beacon(dev);
7683 - //set_nic_txring(dev);
7684 -// rtl8180_prepare_beacon(dev);
7685 - rtl8180_irq_disable(dev);
7686 -// rtl8180_beacon_tx_enable(dev);
7687 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
7688 - //write_nic_byte(dev,0x9d,0x20); //DMA Poll
7689 - //write_nic_word(dev,0x7a,0);
7690 - //write_nic_word(dev,0x7a,0x8000);
7691 -
7692 -
7693 - word = read_nic_word(dev, BcnItv);
7694 - word &= ~BcnItv_BcnItv; // clear Bcn_Itv
7695 - write_nic_word(dev, BcnItv, word);
7696 -
7697 - write_nic_word(dev, AtimWnd,
7698 - read_nic_word(dev, AtimWnd) &~ AtimWnd_AtimWnd);
7699 -
7700 - word = read_nic_word(dev, BintrItv);
7701 - word &= ~BintrItv_BintrItv;
7702 -
7703 - //word |= priv->ieee80211->beacon_interval *
7704 - // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
7705 - // FIXME:FIXME check if correct ^^ worked with 0x3e8;
7706 -
7707 - write_nic_word(dev, BintrItv, word);
7708 -
7709 - //write_nic_word(dev,0x2e,0xe002);
7710 - //write_nic_dword(dev,0x30,0xb8c7832e);
7711 - for(i=0; i<ETH_ALEN; i++)
7712 - write_nic_byte(dev, BSSID+i, priv->ieee80211->beacon_cell_ssid[i]);
7713 -
7714 -// rtl8180_update_msr(dev);
7715 -
7716 -
7717 - //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
7718 -
7719 - rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
7720 -
7721 - rtl8180_irq_enable(dev);
7722 -
7723 - /* VV !!!!!!!!!! VV*/
7724 - /*
7725 - rtl8180_set_mode(dev,EPROM_CMD_CONFIG);
7726 - write_nic_byte(dev,0x9d,0x00);
7727 - rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
7728 -*/
7729 -}
7730 -#endif
7731 -/***************************************************************************
7732 - -------------------------------NET STUFF---------------------------
7733 -***************************************************************************/
7734 -static struct net_device_stats *rtl8180_stats(struct net_device *dev)
7735 -{
7736 - struct r8180_priv *priv = ieee80211_priv(dev);
7737 -
7738 - return &priv->ieee80211->stats;
7739 -}
7740 -
7741 -
7742 -int _rtl8180_up(struct net_device *dev)
7743 -{
7744 - struct r8180_priv *priv = ieee80211_priv(dev);
7745 -
7746 - priv->up=1;
7747 -
7748 - //DMESG("Bringing up iface");
7749 -
7750 - rtl8180_adapter_start(dev);
7751 -
7752 - rtl8180_rx_enable(dev);
7753 -
7754 - rtl8180_tx_enable(dev);
7755 -
7756 - ieee80211_softmac_start_protocol(priv->ieee80211);
7757 -
7758 - ieee80211_reset_queue(priv->ieee80211);
7759 - if(!netif_queue_stopped(dev))
7760 - netif_start_queue(dev);
7761 - else
7762 - netif_wake_queue(dev);
7763 -
7764 - return 0;
7765 -}
7766 -
7767 -
7768 -int rtl8180_open(struct net_device *dev)
7769 -{
7770 - struct r8180_priv *priv = ieee80211_priv(dev);
7771 - int ret;
7772 -
7773 - down(&priv->wx_sem);
7774 - ret = rtl8180_up(dev);
7775 - up(&priv->wx_sem);
7776 - return ret;
7777 -
7778 -}
7779 -
7780 -
7781 -int rtl8180_up(struct net_device *dev)
7782 -{
7783 - struct r8180_priv *priv = ieee80211_priv(dev);
7784 -
7785 - if (priv->up == 1) return -1;
7786 -
7787 - return _rtl8180_up(dev);
7788 -}
7789 -
7790 -
7791 -int rtl8180_close(struct net_device *dev)
7792 -{
7793 - struct r8180_priv *priv = ieee80211_priv(dev);
7794 - int ret;
7795 -
7796 - down(&priv->wx_sem);
7797 -
7798 - ret = rtl8180_down(dev);
7799 -
7800 - up(&priv->wx_sem);
7801 -
7802 - return ret;
7803 -
7804 -}
7805 -
7806 -int rtl8180_down(struct net_device *dev)
7807 -{
7808 - struct r8180_priv *priv = ieee80211_priv(dev);
7809 -
7810 - if (priv->up == 0) return -1;
7811 -
7812 - priv->up=0;
7813 -
7814 -/* FIXME */
7815 - if (!netif_queue_stopped(dev))
7816 - netif_stop_queue(dev);
7817 -
7818 - rtl8180_rtx_disable(dev);
7819 - rtl8180_irq_disable(dev);
7820 -
7821 - ieee80211_softmac_stop_protocol(priv->ieee80211);
7822 -
7823 - return 0;
7824 -}
7825 -
7826 -
7827 -void rtl8180_commit(struct net_device *dev)
7828 -{
7829 - struct r8180_priv *priv = ieee80211_priv(dev);
7830 -
7831 - if (priv->up == 0) return ;
7832 -
7833 - ieee80211_softmac_stop_protocol(priv->ieee80211);
7834 -
7835 - rtl8180_irq_disable(dev);
7836 - rtl8180_rtx_disable(dev);
7837 - _rtl8180_up(dev);
7838 -}
7839 -
7840 -void rtl8180_restart(struct net_device *dev)
7841 -{
7842 - struct r8180_priv *priv = ieee80211_priv(dev);
7843 -
7844 - down(&priv->wx_sem);
7845 -
7846 - rtl8180_commit(dev);
7847 -
7848 - up(&priv->wx_sem);
7849 -}
7850 -
7851 -static void r8180_set_multicast(struct net_device *dev)
7852 -{
7853 - struct r8180_priv *priv = ieee80211_priv(dev);
7854 - short promisc;
7855 -
7856 - //down(&priv->wx_sem);
7857 -
7858 - /* FIXME FIXME */
7859 -
7860 - promisc = (dev->flags & IFF_PROMISC) ? 1:0;
7861 -
7862 - if (promisc != priv->promisc)
7863 - // rtl8180_commit(dev);
7864 -
7865 - priv->promisc = promisc;
7866 -
7867 - //schedule_work(&priv->reset_wq);
7868 - //up(&priv->wx_sem);
7869 -}
7870 -
7871 -
7872 -int r8180_set_mac_adr(struct net_device *dev, void *mac)
7873 -{
7874 - struct r8180_priv *priv = ieee80211_priv(dev);
7875 - struct sockaddr *addr = mac;
7876 -
7877 - down(&priv->wx_sem);
7878 -
7879 - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
7880 -
7881 - schedule_work(&priv->reset_wq);
7882 -
7883 - up(&priv->wx_sem);
7884 -
7885 - return 0;
7886 -}
7887 -
7888 -
7889 -/* based on ipw2200 driver */
7890 -int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
7891 -{
7892 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
7893 -
7894 - down(&priv->wx_sem);
7895 -
7896 - struct iwreq *wrq = (struct iwreq *)rq;
7897 -
7898 - int ret=-1;
7899 - switch (cmd) {
7900 - case RTL_IOCTL_WPA_SUPPLICANT:
7901 - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data);
7902 - break;
7903 -
7904 - default:
7905 - ret = -EOPNOTSUPP;
7906 - break;
7907 - }
7908 -
7909 - up(&priv->wx_sem);
7910 -
7911 - return ret;
7912 -}
7913 -
7914 -
7915 -void rtl8180_irq_rx_tasklet(struct r8180_priv *priv)
7916 -{
7917 - struct urb *rx_urb = priv->rxurb_task;
7918 - struct net_device *dev = (struct net_device*)rx_urb->context;
7919 - int status,len,flen;
7920 - struct sk_buff *skb;
7921 - u32 *desc;
7922 -
7923 - //DMESG("rtl8187_rx_isr");
7924 -
7925 - struct ieee80211_rx_stats stats = {
7926 - .signal = 0,
7927 - .noise = -98,
7928 - .rate = 0,
7929 - // .mac_time = jiffies,
7930 - .freq = IEEE80211_24GHZ_BAND,
7931 - };
7932 -
7933 - //DMESG("RX %d ",rx_urb->status);
7934 - status = rx_urb->status;
7935 - if(status == 0){
7936 -
7937 - len = rx_urb->actual_length;
7938 - // len = len - 4 - 15 - 1; /* CRC, DESC, SEPARATOR*/
7939 - len -= 4*4;/* 4 dword and 4 byte CRC */
7940 -
7941 - desc = (u32*)(rx_urb->transfer_buffer + len);
7942 -
7943 - flen = desc[0] & 0xfff;
7944 -
7945 - if( flen <= rx_urb->actual_length){
7946 -
7947 - stats.signal = (desc[1] & 0x7f00)>>8;
7948 - stats.noise = desc[1] &0xff;
7949 - stats.rate = desc[0] >> 20 & 0xf;
7950 - stats.mac_time[0] = desc[2];
7951 - stats.mac_time[1] = desc[3];
7952 - skb = dev_alloc_skb(flen-4);
7953 - //skb_reserve(skb,2);
7954 - if(skb){
7955 - memcpy(skb_put(skb,flen-4),
7956 - rx_urb->transfer_buffer,flen -4);
7957 -
7958 - #ifdef DUMP_RX
7959 - int i;
7960 - for(i=0;i<flen-4;i++)
7961 - printk("%2x ",((u8*)(rx_urb->transfer_buffer))[i]);
7962 - printk("------RATE %x:w---------------\n",stats.rate);
7963 -
7964 - #endif
7965 - priv->stats.rxok++;
7966 - // priv->rxskb = skb;
7967 - // priv->tempstats = &stats;
7968 -
7969 - if(!ieee80211_rx(priv->ieee80211,
7970 - skb, &stats))
7971 - dev_kfree_skb_any(skb);
7972 - }
7973 - }else priv->stats.rxurberr++;
7974 - }else{
7975 - priv->stats.rxstaterr++;
7976 - priv->ieee80211->stats.rx_errors++;
7977 -
7978 - }
7979 -
7980 - if(status != -ENOENT)rtl8187_rx_urbsubmit(dev,rx_urb);
7981 - else DMESG("RX process aborted due to explicit shutdown");
7982 -}
7983 -
7984 -/****************************************************************************
7985 - ---------------------------- USB_STUFF---------------------------
7986 -*****************************************************************************/
7987 -
7988 -
7989 -static int __devinit rtl8187_usb_probe(struct usb_interface *intf,
7990 - const struct usb_device_id *id)
7991 -{
7992 -// unsigned long ioaddr = 0;
7993 - struct net_device *dev = NULL;
7994 - struct r8180_priv *priv= NULL;
7995 - struct usb_device *udev = interface_to_usbdev(intf);
7996 -
7997 -//printk("===> rtl8187_usb_probe()\n");
7998 -
7999 - dev = alloc_ieee80211(sizeof(struct r8180_priv));
8000 -
8001 - SET_MODULE_OWNER(dev);
8002 - usb_set_intfdata(intf, dev);
8003 -
8004 - SET_NETDEV_DEV(dev, &intf->dev);
8005 -
8006 - priv = ieee80211_priv(dev);
8007 - priv->ieee80211 = netdev_priv(dev);
8008 -
8009 - priv->udev=udev;
8010 -
8011 - dev->open = rtl8180_open;
8012 - dev->stop = rtl8180_close;
8013 - //dev->hard_start_xmit = rtl8180_8023_hard_start_xmit;
8014 - dev->tx_timeout = tx_timeout;
8015 - dev->wireless_handlers = &r8180_wx_handlers_def;
8016 - dev->do_ioctl = rtl8180_ioctl;
8017 - dev->set_multicast_list = r8180_set_multicast;
8018 - dev->set_mac_address = r8180_set_mac_adr;
8019 - dev->get_wireless_stats = r8180_get_wireless_stats;
8020 - dev->type=ARPHRD_ETHER;
8021 -
8022 - if (dev_alloc_name(dev, ifname) < 0){
8023 - DMESG("Oops: devname already taken! Trying wlan%%d...\n");
8024 - ifname = "wlan%d";
8025 - dev_alloc_name(dev, ifname);
8026 - }
8027 -
8028 -// dev->open=rtl8180_init;
8029 -
8030 - if(rtl8180_init(dev)!=0){
8031 - DMESG("Initialization failed");
8032 - goto fail;
8033 - }
8034 -
8035 - netif_carrier_off(dev);
8036 - netif_stop_queue(dev);
8037 -
8038 - register_netdev(dev);
8039 -
8040 - rtl8180_proc_init_one(dev);
8041 -
8042 -
8043 - DMESG("Driver probe completed\n");
8044 - return 0;
8045 -
8046 -
8047 -fail:
8048 - free_ieee80211(dev);
8049 -
8050 - DMESG("wlan driver load failed\n");
8051 -
8052 - return -ENODEV;
8053 -
8054 -}
8055 -
8056 -
8057 -static void __devexit rtl8187_usb_disconnect(struct usb_interface *intf)
8058 -{
8059 - struct r8180_priv *priv;
8060 - struct net_device *dev = usb_get_intfdata(intf);
8061 - if(dev){
8062 -
8063 - unregister_netdev(dev);
8064 -
8065 - priv=ieee80211_priv(dev);
8066 -
8067 - rtl8180_proc_remove_one(dev);
8068 -
8069 - rtl8180_down(dev);
8070 - priv->rf_close(dev);
8071 - //rtl8180_rtx_disable(dev);
8072 - rtl8187_usb_deleteendpoints(dev);
8073 - rtl8180_irq_disable(dev);
8074 - rtl8180_reset(dev);
8075 - mdelay(10);
8076 -
8077 - }
8078 -// pci_disable_device(pdev);
8079 - free_ieee80211(dev);
8080 - DMESG("wlan driver removed\n");
8081 -}
8082 -
8083 -
8084 -static int __init rtl8187_usb_module_init(void)
8085 -{
8086 - printk(KERN_INFO "\nLinux kernel driver for RTL8187 \
8087 -based WLAN cards\n");
8088 - printk(KERN_INFO "Copyright (c) 2004-2005, Andrea Merello\n");
8089 - DMESG("Initializing module");
8090 - DMESG("Wireless extensions version %d", WIRELESS_EXT);
8091 - rtl8180_proc_module_init();
8092 - return usb_register(&rtl8187_usb_driver);
8093 -}
8094 -
8095 -
8096 -static void __exit rtl8187_usb_module_exit(void)
8097 -{
8098 - usb_deregister(&rtl8187_usb_driver);
8099 -
8100 - rtl8180_proc_module_remove();
8101 - DMESG("Exiting");
8102 -}
8103 -
8104 -
8105 -void rtl8180_try_wake_queue(struct net_device *dev, int pri)
8106 -{
8107 - unsigned long flags;
8108 - short enough_desc;
8109 - struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
8110 -
8111 - spin_lock_irqsave(&priv->tx_lock,flags);
8112 - enough_desc = check_nic_enought_desc(dev,pri);
8113 - spin_unlock_irqrestore(&priv->tx_lock,flags);
8114 -
8115 - if(enough_desc)
8116 - ieee80211_wake_queue(priv->ieee80211);
8117 -}
8118 -
8119 -
8120 -
8121 -/***************************************************************************
8122 - ------------------- module init / exit stubs ----------------
8123 -****************************************************************************/
8124 -module_init(rtl8187_usb_module_init);
8125 -module_exit(rtl8187_usb_module_exit);
8126 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h
8127 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h 2006-06-06 02:48:10.000000000 -0400
8128 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h 2008-08-12 13:11:32.000000000 -0400
8129 @@ -1,17 +1,17 @@
8130 -/*
8131 +/*
8132 This is part of rtl8187 OpenSource driver.
8133 - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
8134 + Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
8135 Released under the terms of GPL (General Public Licence)
8136 -
8137 - Parts of this driver are based on the GPL part of the
8138 +
8139 + Parts of this driver are based on the GPL part of the
8140 official realtek driver
8141 -
8142 - Parts of this driver are based on the rtl8180 driver skeleton
8143 +
8144 + Parts of this driver are based on the rtl8180 driver skeleton
8145 from Patric Schenke & Andres Salomon
8146 -
8147 +
8148 Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
8149 -
8150 - We want to tanks the Authors of those projects and the Ndiswrapper
8151 +
8152 + We want to tanks the Authors of those projects and the Ndiswrapper
8153 project Authors.
8154 */
8155  
8156 @@ -26,7 +26,6 @@
8157  
8158 #include <linux/module.h>
8159 #include <linux/kernel.h>
8160 -#include <linux/config.h>
8161 #include <linux/init.h>
8162 #include <linux/ioport.h>
8163 #include <linux/sched.h>
8164 @@ -47,6 +46,12 @@
8165 #include <asm/io.h>
8166 #include <asm/semaphore.h>
8167  
8168 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8169 +#include <linux/config.h>
8170 +#else
8171 +#include <linux/autoconf.h>
8172 +#endif
8173 +
8174 #include "ieee80211.h"
8175  
8176 #define EPROM_93c46 0
8177 @@ -68,7 +73,7 @@
8178 {
8179 struct buffer *next;
8180 u32 *buf;
8181 -
8182 +
8183 } buffer;
8184  
8185 #if 0
8186 @@ -123,18 +128,18 @@
8187 short epromtype;
8188 int irq;
8189 struct ieee80211_device *ieee80211;
8190 -
8191 +
8192 short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */
8193 short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */
8194 short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
8195 short enable_gpio0;
8196 enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type;
8197 short hw_plcp_len;
8198 -
8199 +
8200 // spinlock_t irq_lock;
8201 // spinlock_t irq_th_lock;
8202 spinlock_t tx_lock;
8203 -
8204 +
8205 u16 irq_mask;
8206 // short irq_enabled;
8207 struct net_device *dev;
8208 @@ -143,13 +148,18 @@
8209 short max_sens;
8210 u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
8211 u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
8212 + u8 chtxpwr_orig[15]; //channels from 1 to 14, 0 not used
8213 + u8 chtxpwr_ofdm_orig[15]; //channels from 1 to 14, 0 not used
8214 u8 cck_txpwr_base;
8215 u8 ofdm_txpwr_base;
8216 + u8 txpwr_max;
8217 u8 challow[15]; //channels from 1 to 14, 0 not used
8218 short up;
8219 short crcmon; //if 1 allow bad crc frame reception in monitor mode
8220 -// short prism_hdr;
8221 -
8222 + short prism_hdr;
8223 + short fasttx;
8224 + short highpower;
8225 +
8226 // struct timer_list scan_timer;
8227 /*short scanpending;
8228 short stopscan;*/
8229 @@ -158,7 +168,7 @@
8230 //u8 active_scan_num;
8231 struct semaphore wx_sem;
8232 // short hw_wep;
8233 -
8234 +
8235 // short digphy;
8236 // short antb;
8237 // short diversity;
8238 @@ -171,31 +181,31 @@
8239 void (*rf_close)(struct net_device *dev);
8240 void (*rf_init)(struct net_device *dev);
8241 //short rate;
8242 - short promisc;
8243 + short promisc;
8244 /*stats*/
8245 struct Stats stats;
8246 struct iw_statistics wstats;
8247 struct proc_dir_entry *dir_dev;
8248 -
8249 +
8250 /*RX stuff*/
8251 // u32 *rxring;
8252 // u32 *rxringtail;
8253 // dma_addr_t rxringdma;
8254 struct urb **rx_urb;
8255 -
8256 +
8257 //struct buffer *rxbuffer;
8258 //struct buffer *rxbufferhead;
8259 //int rxringcount;
8260 //u16 rxbuffersize;
8261 -
8262 - //struct sk_buff *rx_skb;
8263 +
8264 + //struct sk_buff *rx_skb;
8265  
8266 //short rx_skb_complete;
8267  
8268 //u32 rx_prevlen;
8269 atomic_t tx_lp_pending;
8270 atomic_t tx_np_pending;
8271 -#if 0
8272 +#if 0
8273 /*TX stuff*/
8274 u32 *txlpring;
8275 u32 *txhpring;
8276 @@ -225,7 +235,7 @@
8277 struct urb *rxurb_task;
8278 // u8 dma_poll_mask;
8279 //short tx_suspend;
8280 -
8281 +
8282 /* adhoc/master mode stuff */
8283 #if 0
8284 u32 *txbeacontail;
8285 @@ -239,22 +249,23 @@
8286 //u16 master_beaconinterval;
8287 // u32 master_beaconsize;
8288 //u16 beacon_interval;
8289 -
8290 +
8291 u8 retry_data;
8292 u8 retry_rts;
8293 -
8294 +
8295 struct work_struct reset_wq;
8296 -
8297 +
8298 }r8180_priv;
8299  
8300  
8301 -typedef enum{
8302 +typedef enum{
8303 LOW_PRIORITY ,
8304 - NORM_PRIORITY
8305 + NORM_PRIORITY
8306 } priority_t;
8307  
8308  
8309 short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate);
8310 +short rtl8180_tx_fast(struct net_device *dev,u32* skbuf, int len, short rate);
8311  
8312 u8 read_nic_byte(struct net_device *dev, int x);
8313 u8 read_nic_byte_E(struct net_device *dev, int x);
8314 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h~ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~
8315 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/r8187.h~ 2006-06-05 22:58:02.000000000 -0400
8316 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.h~ 1969-12-31 19:00:00.000000000 -0500
8317 @@ -1,288 +0,0 @@
8318 -/*
8319 - This is part of rtl8187 OpenSource driver.
8320 - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it>
8321 - Released under the terms of GPL (General Public Licence)
8322 -
8323 - Parts of this driver are based on the GPL part of the
8324 - official realtek driver
8325 -
8326 - Parts of this driver are based on the rtl8180 driver skeleton
8327 - from Patric Schenke & Andres Salomon
8328 -
8329 - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
8330 -
8331 - We want to tanks the Authors of those projects and the Ndiswrapper
8332 - project Authors.
8333 -*/
8334 -
8335 -#ifndef R8180H
8336 -#define R8180H
8337 -
8338 -
8339 -#define RTL8187_MODULE_NAME "rtl8187"
8340 -#define DMESG(x,a...) printk(KERN_INFO RTL8187_MODULE_NAME ": " x "\n", ## a)
8341 -#define DMESGW(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": WW:" x "\n", ## a)
8342 -#define DMESGE(x,a...) printk(KERN_WARNING RTL8187_MODULE_NAME ": EE:" x "\n", ## a)
8343 -
8344 -#include <linux/module.h>
8345 -#include <linux/kernel.h>
8346 -#include <linux/config.h>
8347 -#include <linux/init.h>
8348 -#include <linux/ioport.h>
8349 -#include <linux/sched.h>
8350 -#include <linux/types.h>
8351 -#include <linux/slab.h>
8352 -#include <linux/netdevice.h>
8353 -//#include <linux/pci.h>
8354 -#include <linux/usb.h>
8355 -#include <linux/etherdevice.h>
8356 -#include <linux/delay.h>
8357 -#include <linux/rtnetlink.h> //for rtnl_lock()
8358 -#include <linux/wireless.h>
8359 -#include <linux/timer.h>
8360 -#include <linux/proc_fs.h> // Necessary because we use the proc fs
8361 -#include <linux/if_arp.h>
8362 -#include <linux/random.h>
8363 -#include <linux/version.h>
8364 -#include <asm/io.h>
8365 -#include <asm/semaphore.h>
8366 -
8367 -#include "ieee80211.h"
8368 -
8369 -#define EPROM_93c46 0
8370 -#define EPROM_93c56 1
8371 -
8372 -#define DEFAULT_FRAG_THRESHOLD 2342U
8373 -#define MIN_FRAG_THRESHOLD 256U
8374 -#define DEFAULT_BEACONINTERVAL 0x64U
8375 -#define DEFAULT_BEACON_ESSID "Rtl8187"
8376 -
8377 -#define DEFAULT_SSID ""
8378 -#define DEFAULT_RETRY_RTS 7
8379 -#define DEFAULT_RETRY_DATA 7
8380 -#define PRISM_HDR_SIZE 64
8381 -
8382 -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30
8383 -
8384 -typedef struct buffer
8385 -{
8386 - struct buffer *next;
8387 - u32 *buf;
8388 -
8389 -} buffer;
8390 -
8391 -#if 0
8392 -
8393 -typedef struct tx_pendingbuf
8394 -{
8395 - struct ieee80211_txb *txb;
8396 - short ispending;
8397 - short descfrag;
8398 -} tx_pendigbuf;
8399 -
8400 -#endif
8401 -
8402 -typedef struct Stats
8403 -{
8404 - unsigned long txrdu;
8405 -// unsigned long rxrdu;
8406 - //unsigned long rxnolast;
8407 - //unsigned long rxnodata;
8408 -// unsigned long rxreset;
8409 -// unsigned long rxwrkaround;
8410 -// unsigned long rxnopointer;
8411 - unsigned long rxok;
8412 - unsigned long rxurberr;
8413 - unsigned long rxstaterr;
8414 - unsigned long txnperr;
8415 - unsigned long txnpdrop;
8416 - unsigned long txresumed;
8417 -// unsigned long rxerr;
8418 -// unsigned long rxoverflow;
8419 -// unsigned long rxint;
8420 - unsigned long txnpokint;
8421 -// unsigned long txhpokint;
8422 -// unsigned long txhperr;
8423 -// unsigned long ints;
8424 -// unsigned long shints;
8425 - unsigned long txoverflow;
8426 -// unsigned long rxdmafail;
8427 -// unsigned long txbeacon;
8428 -// unsigned long txbeaconerr;
8429 - unsigned long txlpokint;
8430 - unsigned long txlpdrop;
8431 - unsigned long txlperr;
8432 - unsigned long txdatapkt;
8433 -} Stats;
8434 -
8435 -
8436 -
8437 -typedef struct r8180_priv
8438 -{
8439 - struct usb_device *udev;
8440 - short epromtype;
8441 - int irq;
8442 - struct ieee80211_device *ieee80211;
8443 -
8444 - short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D */
8445 - short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */
8446 - short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
8447 - short enable_gpio0;
8448 - enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type;
8449 - short hw_plcp_len;
8450 -
8451 -// spinlock_t irq_lock;
8452 -// spinlock_t irq_th_lock;
8453 - spinlock_t tx_lock;
8454 -
8455 - u16 irq_mask;
8456 -// short irq_enabled;
8457 - struct net_device *dev;
8458 - short chan;
8459 - short sens;
8460 - short max_sens;
8461 - u8 chtxpwr[15]; //channels from 1 to 14, 0 not used
8462 - u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used
8463 - u8 cck_txpwr_base;
8464 - u8 ofdm_txpwr_base;
8465 - u8 challow[15]; //channels from 1 to 14, 0 not used
8466 - short up;
8467 - short crcmon; //if 1 allow bad crc frame reception in monitor mode
8468 -// short prism_hdr;
8469 -
8470 -// struct timer_list scan_timer;
8471 - /*short scanpending;
8472 - short stopscan;*/
8473 -// spinlock_t scan_lock;
8474 -// u8 active_probe;
8475 - //u8 active_scan_num;
8476 - struct semaphore wx_sem;
8477 -// short hw_wep;
8478 -
8479 -// short digphy;
8480 -// short antb;
8481 -// short diversity;
8482 -// u8 cs_treshold;
8483 -// short rcr_csense;
8484 - short rf_chip;
8485 -// u32 key0[4];
8486 - short (*rf_set_sens)(struct net_device *dev,short sens);
8487 - void (*rf_set_chan)(struct net_device *dev,short ch);
8488 - void (*rf_close)(struct net_device *dev);
8489 - void (*rf_init)(struct net_device *dev);
8490 - //short rate;
8491 - short promisc;
8492 - /*stats*/
8493 - struct Stats stats;
8494 - struct iw_statistics wstats;
8495 - struct proc_dir_entry *dir_dev;
8496 -
8497 - /*RX stuff*/
8498 -// u32 *rxring;
8499 -// u32 *rxringtail;
8500 -// dma_addr_t rxringdma;
8501 - struct urb **rx_urb;
8502 -
8503 - //struct buffer *rxbuffer;
8504 - //struct buffer *rxbufferhead;
8505 - //int rxringcount;
8506 - //u16 rxbuffersize;
8507 -
8508 - //struct sk_buff *rx_skb;
8509 -
8510 - //short rx_skb_complete;
8511 -
8512 - //u32 rx_prevlen;
8513 - atomic_t tx_lp_pending;
8514 - atomic_t tx_np_pending;
8515 -#if 0
8516 - /*TX stuff*/
8517 - u32 *txlpring;
8518 - u32 *txhpring;
8519 - u32 *txnpring;
8520 - dma_addr_t txlpringdma;
8521 - dma_addr_t txhpringdma;
8522 - dma_addr_t txnpringdma;
8523 - u32 *txlpringtail;
8524 - u32 *txhpringtail;
8525 - u32 *txnpringtail;
8526 - u32 *txlpringhead;
8527 - u32 *txhpringhead;
8528 - u32 *txnpringhead;
8529 - struct buffer *txlpbufs;
8530 - struct buffer *txhpbufs;
8531 - struct buffer *txnpbufs;
8532 - struct buffer *txlpbufstail;
8533 - struct buffer *txhpbufstail;
8534 - struct buffer *txnpbufstail;
8535 - int txringcount;
8536 - int txbuffsize;
8537 -
8538 - //struct tx_pendingbuf txnp_pending;
8539 - struct tasklet_struct irq_tx_tasklet;
8540 -#endif
8541 -// struct tasklet_struct irq_rx_tasklet;
8542 -// u8 dma_poll_mask;
8543 - //short tx_suspend;
8544 -
8545 - /* adhoc/master mode stuff */
8546 -#if 0
8547 - u32 *txbeacontail;
8548 - dma_addr_t txbeaconringdma;
8549 - u32 *txbeaconring;
8550 - int txbeaconcount;
8551 -#endif
8552 -// struct ieee_tx_beacon *beacon_buf;
8553 - //char *master_essid;
8554 -// dma_addr_t beacondmabuf;
8555 - //u16 master_beaconinterval;
8556 -// u32 master_beaconsize;
8557 - //u16 beacon_interval;
8558 -
8559 - u8 retry_data;
8560 - u8 retry_rts;
8561 -
8562 - struct work_struct reset_wq;
8563 -
8564 -}r8180_priv;
8565 -
8566 -
8567 -typedef enum{
8568 - LOW_PRIORITY ,
8569 - NORM_PRIORITY
8570 - } priority_t;
8571 -
8572 -
8573 -short rtl8180_tx(struct net_device *dev,u32* skbuf, int len,priority_t priority,short morefrag,short rate);
8574 -
8575 -u8 read_nic_byte(struct net_device *dev, int x);
8576 -u8 read_nic_byte_E(struct net_device *dev, int x);
8577 -u32 read_nic_dword(struct net_device *dev, int x);
8578 -u16 read_nic_word(struct net_device *dev, int x) ;
8579 -void write_nic_byte(struct net_device *dev, int x,u8 y);
8580 -void write_nic_byte_E(struct net_device *dev, int x,u8 y);
8581 -void write_nic_word(struct net_device *dev, int x,u16 y);
8582 -void write_nic_dword(struct net_device *dev, int x,u32 y);
8583 -void force_pci_posting(struct net_device *dev);
8584 -
8585 -void rtl8180_rtx_disable(struct net_device *);
8586 -void rtl8180_rx_enable(struct net_device *);
8587 -void rtl8180_tx_enable(struct net_device *);
8588 -
8589 -void rtl8180_disassociate(struct net_device *dev);
8590 -//void fix_rx_fifo(struct net_device *dev);
8591 -void rtl8185_set_rf_pins_enable(struct net_device *dev,u32 a);
8592 -
8593 -void rtl8180_set_anaparam(struct net_device *dev,u32 a);
8594 -void rtl8185_set_anaparam2(struct net_device *dev,u32 a);
8595 -void rtl8180_update_msr(struct net_device *dev);
8596 -int rtl8180_down(struct net_device *dev);
8597 -int rtl8180_up(struct net_device *dev);
8598 -void rtl8180_commit(struct net_device *dev);
8599 -void rtl8180_set_chan(struct net_device *dev,short ch);
8600 -void write_phy(struct net_device *dev, u8 adr, u8 data);
8601 -void write_phy_cck(struct net_device *dev, u8 adr, u32 data);
8602 -void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data);
8603 -void rtl8185_tx_antenna(struct net_device *dev, u8 ant);
8604 -void rtl8187_set_rxconf(struct net_device *dev);
8605 -#endif
8606 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/beta-8187/.tmp_versions/r8187.mod rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod
8607 --- rtl8187_linux_26.1010.0622.2006_orig/beta-8187/.tmp_versions/r8187.mod 2006-06-22 01:40:15.000000000 -0400
8608 +++ rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/.tmp_versions/r8187.mod 2008-08-12 13:11:32.000000000 -0400
8609 @@ -1,2 +1,2 @@
8610 -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187.ko
8611 -/usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8187_core.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_93cx6.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_wx.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225.o /usr/rtl8187_linux_26.1010.0619.2006/beta-8187/r8180_rtl8225z2.o
8612 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187.ko
8613 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8187_core.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_93cx6.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/beta-8187/r8180_rtl8225z2.o
8614 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c
8615 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.c 2006-06-05 22:57:56.000000000 -0400
8616 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.c 2008-08-12 13:11:32.000000000 -0400
8617 @@ -11,7 +11,6 @@
8618 *
8619 */
8620  
8621 -#include <linux/config.h>
8622 #include <linux/version.h>
8623 #include <linux/module.h>
8624 #include <linux/init.h>
8625 @@ -19,6 +18,12 @@
8626 #include <asm/string.h>
8627 #include <asm/errno.h>
8628  
8629 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8630 +#include <linux/config.h>
8631 +#else
8632 +#include <linux/autoconf.h>
8633 +#endif
8634 +
8635 #include "ieee80211.h"
8636  
8637 MODULE_AUTHOR("Jouni Malinen");
8638 @@ -38,7 +43,7 @@
8639  
8640 static struct ieee80211_crypto *hcrypt;
8641  
8642 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
8643 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *ieee,
8644 int force)
8645 {
8646 struct list_head *ptr, *n;
8647 @@ -61,13 +66,13 @@
8648 }
8649 }
8650  
8651 -void ieee80211_crypt_deinit_handler(unsigned long data)
8652 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long data)
8653 {
8654 struct ieee80211_device *ieee = (struct ieee80211_device *)data;
8655 unsigned long flags;
8656  
8657 spin_lock_irqsave(&ieee->lock, flags);
8658 - ieee80211_crypt_deinit_entries(ieee, 0);
8659 + ieee80211_crypt_deinit_entries_rtl7(ieee, 0);
8660 if (!list_empty(&ieee->crypt_deinit_list)) {
8661 printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
8662 "deletion list\n", ieee->dev->name);
8663 @@ -78,7 +83,7 @@
8664  
8665 }
8666  
8667 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
8668 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
8669 struct ieee80211_crypt_data **crypt)
8670 {
8671 struct ieee80211_crypt_data *tmp;
8672 @@ -103,7 +108,7 @@
8673 spin_unlock_irqrestore(&ieee->lock, flags);
8674 }
8675  
8676 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
8677 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
8678 {
8679 unsigned long flags;
8680 struct ieee80211_crypto_alg *alg;
8681 @@ -128,7 +133,7 @@
8682 return 0;
8683 }
8684  
8685 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
8686 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops)
8687 {
8688 unsigned long flags;
8689 struct list_head *ptr;
8690 @@ -159,7 +164,7 @@
8691 }
8692  
8693  
8694 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
8695 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name)
8696 {
8697 unsigned long flags;
8698 struct list_head *ptr;
8699 @@ -186,13 +191,13 @@
8700 }
8701  
8702  
8703 -static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
8704 -static void ieee80211_crypt_null_deinit(void *priv) {}
8705 +static void * ieee80211_crypt_null_init_rtl7(int keyidx) { return (void *) 1; }
8706 +static void ieee80211_crypt_null_deinit_rtl7(void *priv) {}
8707  
8708 static struct ieee80211_crypto_ops ieee80211_crypt_null = {
8709 .name = "NULL",
8710 - .init = ieee80211_crypt_null_init,
8711 - .deinit = ieee80211_crypt_null_deinit,
8712 + .init = ieee80211_crypt_null_init_rtl7,
8713 + .deinit = ieee80211_crypt_null_deinit_rtl7,
8714 .encrypt_mpdu = NULL,
8715 .decrypt_mpdu = NULL,
8716 .encrypt_msdu = NULL,
8717 @@ -205,7 +210,7 @@
8718 };
8719  
8720  
8721 -static int __init ieee80211_crypto_init(void)
8722 +static int __init ieee80211_crypto_init_rtl7(void)
8723 {
8724 int ret = -ENOMEM;
8725  
8726 @@ -217,7 +222,7 @@
8727 INIT_LIST_HEAD(&hcrypt->algs);
8728 spin_lock_init(&hcrypt->lock);
8729  
8730 - ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
8731 + ret = ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_null);
8732 if (ret < 0) {
8733 kfree(hcrypt);
8734 hcrypt = NULL;
8735 @@ -227,7 +232,7 @@
8736 }
8737  
8738  
8739 -static void __exit ieee80211_crypto_deinit(void)
8740 +static void __exit ieee80211_crypto_deinit_rtl7(void)
8741 {
8742 struct list_head *ptr, *n;
8743  
8744 @@ -247,13 +252,13 @@
8745 kfree(hcrypt);
8746 }
8747  
8748 -EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
8749 -EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
8750 -EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
8751 -
8752 -EXPORT_SYMBOL(ieee80211_register_crypto_ops);
8753 -EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
8754 -EXPORT_SYMBOL(ieee80211_get_crypto_ops);
8755 +EXPORT_SYMBOL(ieee80211_crypt_deinit_entries_rtl7);
8756 +EXPORT_SYMBOL(ieee80211_crypt_deinit_handler_rtl7);
8757 +EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit_rtl7);
8758 +
8759 +EXPORT_SYMBOL(ieee80211_register_crypto_ops_rtl7);
8760 +EXPORT_SYMBOL(ieee80211_unregister_crypto_ops_rtl7);
8761 +EXPORT_SYMBOL(ieee80211_get_crypto_ops_rtl7);
8762  
8763 -module_init(ieee80211_crypto_init);
8764 -module_exit(ieee80211_crypto_deinit);
8765 +module_init(ieee80211_crypto_init_rtl7);
8766 +module_exit(ieee80211_crypto_deinit_rtl7);
8767 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_ccmp.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c
8768 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_ccmp.c 2006-06-05 22:58:00.000000000 -0400
8769 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.c 2008-08-12 13:11:32.000000000 -0400
8770 @@ -9,7 +9,6 @@
8771 * more details.
8772 */
8773  
8774 -#include <linux/config.h>
8775 #include <linux/version.h>
8776 #include <linux/module.h>
8777 #include <linux/init.h>
8778 @@ -22,11 +21,22 @@
8779 #include <asm/string.h>
8780 #include <linux/wireless.h>
8781  
8782 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8783 +#include <linux/config.h>
8784 +#else
8785 +#include <linux/autoconf.h>
8786 +#endif
8787 +
8788 #include "ieee80211.h"
8789  
8790  
8791 #include <linux/crypto.h>
8792 -#include <asm/scatterlist.h>
8793 +
8794 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
8795 + #include <asm/scatterlist.h>
8796 +#else
8797 + #include <linux/scatterlist.h>
8798 +#endif
8799  
8800 MODULE_AUTHOR("Jouni Malinen");
8801 MODULE_DESCRIPTION("Host AP crypt: CCMP");
8802 @@ -51,7 +61,11 @@
8803  
8804 int key_idx;
8805  
8806 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8807 struct crypto_tfm *tfm;
8808 +#else
8809 + struct crypto_cipher *tfm;
8810 +#endif
8811  
8812 /* scratch buffers for virt_to_page() (crypto API) */
8813 u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
8814 @@ -59,7 +73,8 @@
8815 u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
8816 };
8817  
8818 -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
8819 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8820 +void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_tfm *tfm,
8821 const u8 pt[16], u8 ct[16])
8822 {
8823 struct scatterlist src, dst;
8824 @@ -74,8 +89,15 @@
8825  
8826 crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
8827 }
8828 +#else
8829 +static inline void ieee80211_ccmp_aes_encrypt_rtl7(struct crypto_cipher *tfm,
8830 + const u8 pt[16], u8 ct[16])
8831 +{
8832 + crypto_cipher_encrypt_one(tfm, ct, pt);
8833 +}
8834 +#endif
8835  
8836 -static void * ieee80211_ccmp_init(int key_idx)
8837 +static void * ieee80211_ccmp_init_rtl7(int key_idx)
8838 {
8839 struct ieee80211_ccmp_data *priv;
8840  
8841 @@ -85,19 +107,33 @@
8842 memset(priv, 0, sizeof(*priv));
8843 priv->key_idx = key_idx;
8844  
8845 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8846 priv->tfm = crypto_alloc_tfm("aes", 0);
8847 if (priv->tfm == NULL) {
8848 printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
8849 "crypto API aes\n");
8850 goto fail;
8851 }
8852 +#else
8853 + priv->tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
8854 + if (IS_ERR(priv->tfm)) {
8855 + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
8856 + "crypto API aes\n");
8857 + priv->tfm = NULL;
8858 + goto fail;
8859 + }
8860 +#endif
8861  
8862 return priv;
8863  
8864 fail:
8865 if (priv) {
8866 if (priv->tfm)
8867 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8868 crypto_free_tfm(priv->tfm);
8869 +#else
8870 + crypto_free_cipher(priv->tfm);
8871 +#endif
8872 kfree(priv);
8873 }
8874  
8875 @@ -105,16 +141,20 @@
8876 }
8877  
8878  
8879 -static void ieee80211_ccmp_deinit(void *priv)
8880 +static void ieee80211_ccmp_deinit_rtl7(void *priv)
8881 {
8882 struct ieee80211_ccmp_data *_priv = priv;
8883 if (_priv && _priv->tfm)
8884 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8885 crypto_free_tfm(_priv->tfm);
8886 +#else
8887 + crypto_free_cipher(_priv->tfm);
8888 +#endif
8889 kfree(priv);
8890 }
8891  
8892  
8893 -static inline void xor_block(u8 *b, u8 *a, size_t len)
8894 +static inline void xor_block_rtl7(u8 *b, u8 *a, size_t len)
8895 {
8896 int i;
8897 for (i = 0; i < len; i++)
8898 @@ -122,7 +162,11 @@
8899 }
8900  
8901  
8902 -static void ccmp_init_blocks(struct crypto_tfm *tfm,
8903 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
8904 +static void ccmp_init_blocks_rtl7(struct crypto_tfm *tfm,
8905 +#else
8906 +static void ccmp_init_blocks_rtl7(struct crypto_cipher *tfm,
8907 +#endif
8908 struct ieee80211_hdr *hdr,
8909 u8 *pn, size_t dlen, u8 *b0, u8 *auth,
8910 u8 *s0)
8911 @@ -186,18 +230,18 @@
8912 }
8913  
8914 /* Start with the first block and AAD */
8915 - ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
8916 - xor_block(auth, aad, AES_BLOCK_LEN);
8917 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
8918 - xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
8919 - ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
8920 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, auth);
8921 + xor_block_rtl7(auth, aad, AES_BLOCK_LEN);
8922 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
8923 + xor_block_rtl7(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
8924 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, auth, auth);
8925 b0[0] &= 0x07;
8926 b0[14] = b0[15] = 0;
8927 - ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
8928 + ieee80211_ccmp_aes_encrypt_rtl7(tfm, b0, s0);
8929 }
8930  
8931  
8932 -static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
8933 +static int ieee80211_ccmp_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
8934 {
8935 struct ieee80211_ccmp_data *key = priv;
8936 int data_len, i, blocks, last, len;
8937 @@ -237,7 +281,7 @@
8938 *pos++ = key->tx_pn[0];
8939  
8940 hdr = (struct ieee80211_hdr *) skb->data;
8941 - ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
8942 + ccmp_init_blocks_rtl7(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
8943  
8944 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
8945 last = data_len % AES_BLOCK_LEN;
8946 @@ -245,13 +289,13 @@
8947 for (i = 1; i <= blocks; i++) {
8948 len = (i == blocks && last) ? last : AES_BLOCK_LEN;
8949 /* Authentication */
8950 - xor_block(b, pos, len);
8951 - ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
8952 + xor_block_rtl7(b, pos, len);
8953 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b, b);
8954 /* Encryption, with counter */
8955 b0[14] = (i >> 8) & 0xff;
8956 b0[15] = i & 0xff;
8957 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
8958 - xor_block(pos, e, len);
8959 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, e);
8960 + xor_block_rtl7(pos, e, len);
8961 pos += len;
8962 }
8963  
8964 @@ -262,7 +306,7 @@
8965 }
8966  
8967  
8968 -static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
8969 +static int ieee80211_ccmp_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
8970 {
8971 struct ieee80211_ccmp_data *key = priv;
8972 u8 keyidx, *pos;
8973 @@ -326,8 +370,8 @@
8974 return -4;
8975 }
8976  
8977 - ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
8978 - xor_block(mic, b, CCMP_MIC_LEN);
8979 + ccmp_init_blocks_rtl7(key->tfm, hdr, pn, data_len, b0, a, b);
8980 + xor_block_rtl7(mic, b, CCMP_MIC_LEN);
8981  
8982 blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
8983 last = data_len % AES_BLOCK_LEN;
8984 @@ -337,11 +381,11 @@
8985 /* Decrypt, with counter */
8986 b0[14] = (i >> 8) & 0xff;
8987 b0[15] = i & 0xff;
8988 - ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
8989 - xor_block(pos, b, len);
8990 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, b0, b);
8991 + xor_block_rtl7(pos, b, len);
8992 /* Authentication */
8993 - xor_block(a, pos, len);
8994 - ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
8995 + xor_block_rtl7(a, pos, len);
8996 + ieee80211_ccmp_aes_encrypt_rtl7(key->tfm, a, a);
8997 pos += len;
8998 }
8999  
9000 @@ -365,11 +409,15 @@
9001 }
9002  
9003  
9004 -static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
9005 +static int ieee80211_ccmp_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
9006 {
9007 struct ieee80211_ccmp_data *data = priv;
9008 int keyidx;
9009 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9010 struct crypto_tfm *tfm = data->tfm;
9011 +#else
9012 + struct crypto_cipher *tfm = data->tfm;
9013 +#endif
9014  
9015 keyidx = data->key_idx;
9016 memset(data, 0, sizeof(*data));
9017 @@ -396,7 +444,7 @@
9018 }
9019  
9020  
9021 -static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
9022 +static int ieee80211_ccmp_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
9023 {
9024 struct ieee80211_ccmp_data *data = priv;
9025  
9026 @@ -420,7 +468,7 @@
9027 }
9028  
9029  
9030 -static char * ieee80211_ccmp_print_stats(char *p, void *priv)
9031 +static char * ieee80211_ccmp_print_stats_rtl7(char *p, void *priv)
9032 {
9033 struct ieee80211_ccmp_data *ccmp = priv;
9034 p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
9035 @@ -437,34 +485,34 @@
9036 }
9037  
9038  
9039 -static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
9040 +static struct ieee80211_crypto_ops ieee80211_crypt_ccmp_rtl7 = {
9041 .name = "CCMP",
9042 - .init = ieee80211_ccmp_init,
9043 - .deinit = ieee80211_ccmp_deinit,
9044 - .encrypt_mpdu = ieee80211_ccmp_encrypt,
9045 - .decrypt_mpdu = ieee80211_ccmp_decrypt,
9046 + .init = ieee80211_ccmp_init_rtl7,
9047 + .deinit = ieee80211_ccmp_deinit_rtl7,
9048 + .encrypt_mpdu = ieee80211_ccmp_encrypt_rtl7,
9049 + .decrypt_mpdu = ieee80211_ccmp_decrypt_rtl7,
9050 .encrypt_msdu = NULL,
9051 .decrypt_msdu = NULL,
9052 - .set_key = ieee80211_ccmp_set_key,
9053 - .get_key = ieee80211_ccmp_get_key,
9054 - .print_stats = ieee80211_ccmp_print_stats,
9055 + .set_key = ieee80211_ccmp_set_key_rtl7,
9056 + .get_key = ieee80211_ccmp_get_key_rtl7,
9057 + .print_stats = ieee80211_ccmp_print_stats_rtl7,
9058 .extra_prefix_len = CCMP_HDR_LEN,
9059 .extra_postfix_len = CCMP_MIC_LEN,
9060 .owner = THIS_MODULE,
9061 };
9062  
9063  
9064 -static int __init ieee80211_crypto_ccmp_init(void)
9065 +static int __init ieee80211_crypto_ccmp_init_rtl7(void)
9066 {
9067 - return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
9068 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
9069 }
9070  
9071  
9072 -static void __exit ieee80211_crypto_ccmp_exit(void)
9073 +static void __exit ieee80211_crypto_ccmp_exit_rtl7(void)
9074 {
9075 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
9076 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_ccmp_rtl7);
9077 }
9078  
9079  
9080 -module_init(ieee80211_crypto_ccmp_init);
9081 -module_exit(ieee80211_crypto_ccmp_exit);
9082 +module_init(ieee80211_crypto_ccmp_init_rtl7);
9083 +module_exit(ieee80211_crypto_ccmp_exit_rtl7);
9084 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h
9085 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt.h 2006-06-05 22:58:00.000000000 -0400
9086 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.h 2008-08-12 13:11:32.000000000 -0400
9087 @@ -75,12 +75,12 @@
9088 atomic_t refcnt;
9089 };
9090  
9091 -int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
9092 -int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
9093 -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
9094 -void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
9095 -void ieee80211_crypt_deinit_handler(unsigned long);
9096 -void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
9097 +int ieee80211_register_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
9098 +int ieee80211_unregister_crypto_ops_rtl7(struct ieee80211_crypto_ops *ops);
9099 +struct ieee80211_crypto_ops * ieee80211_get_crypto_ops_rtl7(const char *name);
9100 +void ieee80211_crypt_deinit_entries_rtl7(struct ieee80211_device *, int);
9101 +void ieee80211_crypt_deinit_handler_rtl7(unsigned long);
9102 +void ieee80211_crypt_delayed_deinit_rtl7(struct ieee80211_device *ieee,
9103 struct ieee80211_crypt_data **crypt);
9104  
9105 #endif
9106 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_tkip.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c
9107 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_tkip.c 2006-06-05 22:57:54.000000000 -0400
9108 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.c 2008-08-12 13:11:32.000000000 -0400
9109 @@ -9,7 +9,6 @@
9110 * more details.
9111 */
9112  
9113 -#include <linux/config.h>
9114 #include <linux/version.h>
9115 #include <linux/module.h>
9116 #include <linux/init.h>
9117 @@ -21,13 +20,24 @@
9118 #include <linux/if_arp.h>
9119 #include <asm/string.h>
9120  
9121 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9122 +#include <linux/config.h>
9123 +#else
9124 +#include <linux/autoconf.h>
9125 +#endif
9126 +
9127 #include "ieee80211.h"
9128  
9129 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
9130 + #include <asm/scatterlist.h>
9131 +#else
9132 + #include <linux/scatterlist.h>
9133 +#endif
9134  
9135 #include <linux/crypto.h>
9136 -#include <asm/scatterlist.h>
9137 #include <linux/crc32.h>
9138  
9139 +
9140 MODULE_AUTHOR("Jouni Malinen");
9141 MODULE_DESCRIPTION("Host AP crypt: TKIP");
9142 MODULE_LICENSE("GPL");
9143 @@ -55,14 +65,21 @@
9144  
9145 int key_idx;
9146  
9147 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9148 struct crypto_tfm *tfm_arc4;
9149 struct crypto_tfm *tfm_michael;
9150 +#else
9151 + struct crypto_blkcipher *rx_tfm_arc4;
9152 + struct crypto_blkcipher *tx_tfm_arc4;
9153 + struct crypto_hash *rx_tfm_michael;
9154 + struct crypto_hash *tx_tfm_michael;
9155 +#endif
9156  
9157 /* scratch buffers for virt_to_page() (crypto API) */
9158 u8 rx_hdr[16], tx_hdr[16];
9159 };
9160  
9161 -static void * ieee80211_tkip_init(int key_idx)
9162 +static void * ieee80211_tkip_init_rtl7(int key_idx)
9163 {
9164 struct ieee80211_tkip_data *priv;
9165  
9166 @@ -72,28 +89,74 @@
9167 memset(priv, 0, sizeof(*priv));
9168 priv->key_idx = key_idx;
9169  
9170 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9171 priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
9172 if (priv->tfm_arc4 == NULL) {
9173 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
9174 "crypto API arc4\n");
9175 goto fail;
9176 }
9177 -
9178 priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
9179 if (priv->tfm_michael == NULL) {
9180 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
9181 "crypto API michael_mic\n");
9182 goto fail;
9183 }
9184 +#else
9185 + priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
9186 + if (IS_ERR(priv->tx_tfm_arc4)) {
9187 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
9188 + "crypto API arc4\n");
9189 + priv->tx_tfm_arc4 = NULL;
9190 + goto fail;
9191 + }
9192 +
9193 + priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
9194 + CRYPTO_ALG_ASYNC);
9195 + if (IS_ERR(priv->tx_tfm_michael)) {
9196 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
9197 + "crypto API michael_mic\n");
9198 + priv->tx_tfm_michael = NULL;
9199 + goto fail;
9200 + }
9201 +
9202 + priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
9203 + if (IS_ERR(priv->rx_tfm_arc4)) {
9204 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
9205 + "crypto API arc4\n");
9206 + priv->rx_tfm_arc4 = NULL;
9207 + goto fail;
9208 + }
9209 +
9210 + priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
9211 + CRYPTO_ALG_ASYNC);
9212 + if (IS_ERR(priv->rx_tfm_michael)) {
9213 + printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
9214 + "crypto API michael_mic\n");
9215 + priv->rx_tfm_michael = NULL;
9216 + goto fail;
9217 + }
9218 +#endif
9219  
9220 return priv;
9221  
9222 fail:
9223 if (priv) {
9224 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9225 if (priv->tfm_michael)
9226 crypto_free_tfm(priv->tfm_michael);
9227 if (priv->tfm_arc4)
9228 crypto_free_tfm(priv->tfm_arc4);
9229 +#else
9230 + if (priv->tx_tfm_michael)
9231 + crypto_free_hash(priv->tx_tfm_michael);
9232 + if (priv->tx_tfm_arc4)
9233 + crypto_free_blkcipher(priv->tx_tfm_arc4);
9234 + if (priv->rx_tfm_michael)
9235 + crypto_free_hash(priv->rx_tfm_michael);
9236 + if (priv->rx_tfm_arc4)
9237 + crypto_free_blkcipher(priv->rx_tfm_arc4);
9238 +#endif
9239 kfree(priv);
9240 }
9241  
9242 @@ -101,13 +164,26 @@
9243 }
9244  
9245  
9246 -static void ieee80211_tkip_deinit(void *priv)
9247 +static void ieee80211_tkip_deinit_rtl7(void *priv)
9248 {
9249 struct ieee80211_tkip_data *_priv = priv;
9250 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9251 if (_priv && _priv->tfm_michael)
9252 crypto_free_tfm(_priv->tfm_michael);
9253 if (_priv && _priv->tfm_arc4)
9254 crypto_free_tfm(_priv->tfm_arc4);
9255 +#else
9256 + if (_priv) {
9257 + if (_priv->tx_tfm_michael)
9258 + crypto_free_hash(_priv->tx_tfm_michael);
9259 + if (_priv->tx_tfm_arc4)
9260 + crypto_free_blkcipher(_priv->tx_tfm_arc4);
9261 + if (_priv->rx_tfm_michael)
9262 + crypto_free_hash(_priv->rx_tfm_michael);
9263 + if (_priv->rx_tfm_arc4)
9264 + crypto_free_blkcipher(_priv->rx_tfm_arc4);
9265 + }
9266 +#endif
9267 kfree(priv);
9268 }
9269  
9270 @@ -200,7 +276,7 @@
9271  
9272 #define PHASE1_LOOP_COUNT 8
9273  
9274 -static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
9275 +static void tkip_mixing_phase1_rtl7(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
9276 {
9277 int i, j;
9278  
9279 @@ -222,7 +298,7 @@
9280 }
9281  
9282  
9283 -static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
9284 +static void tkip_mixing_phase2_rtl7(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
9285 u16 IV16)
9286 {
9287 /* Make temporary area overlap WEP seed so that the final copy can be
9288 @@ -268,7 +344,7 @@
9289 #endif
9290 }
9291  
9292 -static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
9293 +static int ieee80211_tkip_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
9294 {
9295 struct ieee80211_tkip_data *tkey = priv;
9296 int len;
9297 @@ -276,6 +352,9 @@
9298 struct ieee80211_hdr *hdr;
9299 u32 crc;
9300 struct scatterlist sg;
9301 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
9302 + struct blkcipher_desc desc = { .tfm = tkey->tx_tfm_arc4 };
9303 +#endif
9304  
9305 if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
9306 skb->len < hdr_len)
9307 @@ -283,11 +362,11 @@
9308  
9309 hdr = (struct ieee80211_hdr *) skb->data;
9310 if (!tkey->tx_phase1_done) {
9311 - tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
9312 + tkip_mixing_phase1_rtl7(tkey->tx_ttak, tkey->key, hdr->addr2,
9313 tkey->tx_iv32);
9314 tkey->tx_phase1_done = 1;
9315 }
9316 - tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
9317 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
9318  
9319 len = skb->len - hdr_len;
9320 pos = skb_push(skb, 8);
9321 @@ -310,11 +389,23 @@
9322 icv[2] = crc >> 16;
9323 icv[3] = crc >> 24;
9324  
9325 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9326 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
9327 +#else
9328 + crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16);
9329 +#endif
9330 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9331 sg.page = virt_to_page(pos);
9332 sg.offset = offset_in_page(pos);
9333 sg.length = len + 4;
9334 +#else
9335 + sg_set_page(&sg, virt_to_page(pos), len + 2, offset_in_page(pos));
9336 +#endif
9337 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9338 crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4);
9339 +#else
9340 + crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
9341 +#endif
9342  
9343 tkey->tx_iv16++;
9344 if (tkey->tx_iv16 == 0) {
9345 @@ -325,7 +416,7 @@
9346 return 0;
9347 }
9348  
9349 -static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
9350 +static int ieee80211_tkip_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
9351 {
9352 struct ieee80211_tkip_data *tkey = priv;
9353 u8 rc4key[16];
9354 @@ -337,6 +428,9 @@
9355 u32 crc;
9356 struct scatterlist sg;
9357 int plen;
9358 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
9359 + struct blkcipher_desc desc = { .tfm = tkey->rx_tfm_arc4 };
9360 +#endif
9361  
9362 if (skb->len < hdr_len + 8 + 4)
9363 return -1;
9364 @@ -382,18 +476,30 @@
9365 }
9366  
9367 if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
9368 - tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
9369 + tkip_mixing_phase1_rtl7(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
9370 tkey->rx_phase1_done = 1;
9371 }
9372 - tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
9373 + tkip_mixing_phase2_rtl7(rc4key, tkey->key, tkey->rx_ttak, iv16);
9374  
9375 plen = skb->len - hdr_len - 12;
9376  
9377 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9378 crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
9379 +#else
9380 + crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
9381 +#endif
9382 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9383 sg.page = virt_to_page(pos);
9384 sg.offset = offset_in_page(pos);
9385 sg.length = plen + 4;
9386 +#else
9387 + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos));
9388 +#endif
9389 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9390 crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);
9391 +#else
9392 + crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4);
9393 +#endif
9394  
9395 crc = ~crc32_le(~0, pos, plen);
9396 icv[0] = crc;
9397 @@ -427,33 +533,59 @@
9398 return keyidx;
9399 }
9400  
9401 -
9402 -static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
9403 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9404 +static int michael_mic_rtl7(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
9405 u8 *data, size_t data_len, u8 *mic)
9406 {
9407 struct scatterlist sg[2];
9408  
9409 if (tkey->tfm_michael == NULL) {
9410 +#else
9411 +static int michael_mic_rtl7(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr,
9412 + u8 *data, size_t data_len, u8 *mic)
9413 +{
9414 + struct hash_desc desc;
9415 + struct scatterlist sg[2];
9416 +
9417 + if (tfm_michael == NULL) {
9418 +#endif
9419 printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
9420 return -1;
9421 }
9422 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9423 sg[0].page = virt_to_page(hdr);
9424 sg[0].offset = offset_in_page(hdr);
9425 sg[0].length = 16;
9426 +#else
9427 + sg_set_page(&sg[0], virt_to_page(hdr), 16, offset_in_page(hdr));
9428 +#endif
9429  
9430 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9431 sg[1].page = virt_to_page(data);
9432 sg[1].offset = offset_in_page(data);
9433 sg[1].length = data_len;
9434 +#else
9435 + sg_set_page(&sg[1], virt_to_page(data), data_len, offset_in_page(data));
9436 +#endif
9437  
9438 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9439 crypto_digest_init(tkey->tfm_michael);
9440 crypto_digest_setkey(tkey->tfm_michael, key, 8);
9441 crypto_digest_update(tkey->tfm_michael, sg, 2);
9442 crypto_digest_final(tkey->tfm_michael, mic);
9443  
9444 return 0;
9445 +#else
9446 + if (crypto_hash_setkey(tfm_michael, key, 8))
9447 + return -1;
9448 +
9449 + desc.tfm = tfm_michael;
9450 + desc.flags = 0;
9451 + return crypto_hash_digest(&desc, sg, data_len + 16, mic);
9452 +#endif
9453 }
9454  
9455 -static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
9456 +static void michael_mic_hdr_rtl7(struct sk_buff *skb, u8 *hdr)
9457 {
9458 struct ieee80211_hdr *hdr11;
9459  
9460 @@ -483,7 +615,7 @@
9461 }
9462  
9463  
9464 -static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
9465 +static int ieee80211_michael_mic_add_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
9466 {
9467 struct ieee80211_tkip_data *tkey = priv;
9468 u8 *pos;
9469 @@ -495,18 +627,24 @@
9470 return -1;
9471 }
9472  
9473 - michael_mic_hdr(skb, tkey->tx_hdr);
9474 + michael_mic_hdr_rtl7(skb, tkey->tx_hdr);
9475 pos = skb_put(skb, 8);
9476 - if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
9477 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9478 + if (michael_mic_rtl7(tkey, &tkey->key[16], tkey->tx_hdr,
9479 + skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
9480 + return -1;
9481 +#else
9482 + if (michael_mic_rtl7(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr,
9483 skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
9484 return -1;
9485 +#endif
9486  
9487 return 0;
9488 }
9489  
9490  
9491 #if WIRELESS_EXT >= 18
9492 -static void ieee80211_michael_mic_failure(struct net_device *dev,
9493 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
9494 struct ieee80211_hdr *hdr,
9495 int keyidx)
9496 {
9497 @@ -527,7 +665,7 @@
9498 wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
9499 }
9500 #elif WIRELESS_EXT >= 15
9501 -static void ieee80211_michael_mic_failure(struct net_device *dev,
9502 +static void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
9503 struct ieee80211_hdr *hdr,
9504 int keyidx)
9505 {
9506 @@ -543,7 +681,7 @@
9507 wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
9508 }
9509 #else /* WIRELESS_EXT >= 15 */
9510 -static inline void ieee80211_michael_mic_failure(struct net_device *dev,
9511 +static inline void ieee80211_michael_mic_failure_rtl7(struct net_device *dev,
9512 struct ieee80211_hdr *hdr,
9513 int keyidx)
9514 {
9515 @@ -551,7 +689,7 @@
9516 #endif /* WIRELESS_EXT >= 15 */
9517  
9518  
9519 -static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
9520 +static int ieee80211_michael_mic_verify_rtl7(struct sk_buff *skb, int keyidx,
9521 int hdr_len, void *priv)
9522 {
9523 struct ieee80211_tkip_data *tkey = priv;
9524 @@ -560,10 +698,16 @@
9525 if (!tkey->key_set)
9526 return -1;
9527  
9528 - michael_mic_hdr(skb, tkey->rx_hdr);
9529 - if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
9530 + michael_mic_hdr_rtl7(skb, tkey->rx_hdr);
9531 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9532 + if (michael_mic_rtl7(tkey, &tkey->key[24], tkey->rx_hdr,
9533 + skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
9534 + return -1;
9535 +#else
9536 + if (michael_mic_rtl7(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr,
9537 skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
9538 return -1;
9539 +#endif
9540 if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
9541 struct ieee80211_hdr *hdr;
9542 hdr = (struct ieee80211_hdr *) skb->data;
9543 @@ -572,7 +716,7 @@
9544 skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
9545 keyidx);
9546 if (skb->dev)
9547 - ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
9548 + ieee80211_michael_mic_failure_rtl7(skb->dev, hdr, keyidx);
9549 tkey->dot11RSNAStatsTKIPLocalMICFailures++;
9550 return -1;
9551 }
9552 @@ -588,18 +732,33 @@
9553 }
9554  
9555  
9556 -static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
9557 +static int ieee80211_tkip_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
9558 {
9559 struct ieee80211_tkip_data *tkey = priv;
9560 int keyidx;
9561 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9562 struct crypto_tfm *tfm = tkey->tfm_michael;
9563 struct crypto_tfm *tfm2 = tkey->tfm_arc4;
9564 +#else
9565 + struct crypto_hash *tfm = tkey->tx_tfm_michael;
9566 + struct crypto_blkcipher *tfm2 = tkey->tx_tfm_arc4;
9567 + struct crypto_hash *tfm3 = tkey->rx_tfm_michael;
9568 + struct crypto_blkcipher *tfm4 = tkey->rx_tfm_arc4;
9569 +#endif
9570  
9571 keyidx = tkey->key_idx;
9572 memset(tkey, 0, sizeof(*tkey));
9573 tkey->key_idx = keyidx;
9574 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9575 tkey->tfm_michael = tfm;
9576 tkey->tfm_arc4 = tfm2;
9577 +#else
9578 + tkey->tx_tfm_michael = tfm;
9579 + tkey->tx_tfm_arc4 = tfm2;
9580 + tkey->rx_tfm_michael = tfm3;
9581 + tkey->rx_tfm_arc4 = tfm4;
9582 +#endif
9583 +
9584 if (len == TKIP_KEY_LEN) {
9585 memcpy(tkey->key, key, TKIP_KEY_LEN);
9586 tkey->key_set = 1;
9587 @@ -618,7 +777,7 @@
9588 }
9589  
9590  
9591 -static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
9592 +static int ieee80211_tkip_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
9593 {
9594 struct ieee80211_tkip_data *tkey = priv;
9595  
9596 @@ -648,7 +807,7 @@
9597 }
9598  
9599  
9600 -static char * ieee80211_tkip_print_stats(char *p, void *priv)
9601 +static char * ieee80211_tkip_print_stats_rtl7(char *p, void *priv)
9602 {
9603 struct ieee80211_tkip_data *tkip = priv;
9604 p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
9605 @@ -675,34 +834,34 @@
9606 }
9607  
9608  
9609 -static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
9610 +static struct ieee80211_crypto_ops ieee80211_crypt_tkip_rtl7 = {
9611 .name = "TKIP",
9612 - .init = ieee80211_tkip_init,
9613 - .deinit = ieee80211_tkip_deinit,
9614 - .encrypt_mpdu = ieee80211_tkip_encrypt,
9615 - .decrypt_mpdu = ieee80211_tkip_decrypt,
9616 - .encrypt_msdu = ieee80211_michael_mic_add,
9617 - .decrypt_msdu = ieee80211_michael_mic_verify,
9618 - .set_key = ieee80211_tkip_set_key,
9619 - .get_key = ieee80211_tkip_get_key,
9620 - .print_stats = ieee80211_tkip_print_stats,
9621 + .init = ieee80211_tkip_init_rtl7,
9622 + .deinit = ieee80211_tkip_deinit_rtl7,
9623 + .encrypt_mpdu = ieee80211_tkip_encrypt_rtl7,
9624 + .decrypt_mpdu = ieee80211_tkip_decrypt_rtl7,
9625 + .encrypt_msdu = ieee80211_michael_mic_add_rtl7,
9626 + .decrypt_msdu = ieee80211_michael_mic_verify_rtl7,
9627 + .set_key = ieee80211_tkip_set_key_rtl7,
9628 + .get_key = ieee80211_tkip_get_key_rtl7,
9629 + .print_stats = ieee80211_tkip_print_stats_rtl7,
9630 .extra_prefix_len = 4 + 4, /* IV + ExtIV */
9631 .extra_postfix_len = 8 + 4, /* MIC + ICV */
9632 .owner = THIS_MODULE,
9633 };
9634  
9635  
9636 -static int __init ieee80211_crypto_tkip_init(void)
9637 +static int __init ieee80211_crypto_tkip_init_rtl7(void)
9638 {
9639 - return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
9640 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
9641 }
9642  
9643  
9644 -static void __exit ieee80211_crypto_tkip_exit(void)
9645 +static void __exit ieee80211_crypto_tkip_exit_rtl7(void)
9646 {
9647 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
9648 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_tkip_rtl7);
9649 }
9650  
9651  
9652 -module_init(ieee80211_crypto_tkip_init);
9653 -module_exit(ieee80211_crypto_tkip_exit);
9654 +module_init(ieee80211_crypto_tkip_init_rtl7);
9655 +module_exit(ieee80211_crypto_tkip_exit_rtl7);
9656 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_wep.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c
9657 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_crypt_wep.c 2006-06-05 22:57:54.000000000 -0400
9658 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.c 2008-08-12 13:11:32.000000000 -0400
9659 @@ -9,7 +9,6 @@
9660 * more details.
9661 */
9662  
9663 -#include <linux/config.h>
9664 #include <linux/version.h>
9665 #include <linux/module.h>
9666 #include <linux/init.h>
9667 @@ -18,13 +17,24 @@
9668 #include <linux/skbuff.h>
9669 #include <asm/string.h>
9670  
9671 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9672 +#include <linux/config.h>
9673 +#else
9674 +#include <linux/autoconf.h>
9675 +#endif
9676 +
9677 #include "ieee80211.h"
9678  
9679  
9680 #include <linux/crypto.h>
9681 -#include <asm/scatterlist.h>
9682 #include <linux/crc32.h>
9683  
9684 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
9685 + #include <asm/scatterlist.h>
9686 +#else
9687 + #include <linux/scatterlist.h>
9688 +#endif
9689 +
9690 MODULE_AUTHOR("Jouni Malinen");
9691 MODULE_DESCRIPTION("Host AP crypt: WEP");
9692 MODULE_LICENSE("GPL");
9693 @@ -36,11 +46,16 @@
9694 u8 key[WEP_KEY_LEN + 1];
9695 u8 key_len;
9696 u8 key_idx;
9697 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9698 struct crypto_tfm *tfm;
9699 +#else
9700 + struct crypto_blkcipher *rx_tfm;
9701 + struct crypto_blkcipher *tx_tfm;
9702 +#endif
9703 };
9704  
9705  
9706 -static void * prism2_wep_init(int keyidx)
9707 +static void * prism2_wep_init_rtl7(int keyidx)
9708 {
9709 struct prism2_wep_data *priv;
9710  
9711 @@ -50,13 +65,30 @@
9712 memset(priv, 0, sizeof(*priv));
9713 priv->key_idx = keyidx;
9714  
9715 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9716 priv->tfm = crypto_alloc_tfm("arc4", 0);
9717 if (priv->tfm == NULL) {
9718 printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
9719 "crypto API arc4\n");
9720 goto fail;
9721 }
9722 +#else
9723 + priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
9724 + if (IS_ERR(priv->tx_tfm)) {
9725 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
9726 + "crypto API arc4\n");
9727 + priv->tx_tfm = NULL;
9728 + goto fail;
9729 + }
9730  
9731 + priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
9732 + if (IS_ERR(priv->rx_tfm)) {
9733 + printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
9734 + "crypto API arc4\n");
9735 + priv->rx_tfm = NULL;
9736 + goto fail;
9737 + }
9738 +#endif
9739 /* start WEP IV from a random value */
9740 get_random_bytes(&priv->iv, 4);
9741  
9742 @@ -64,19 +96,35 @@
9743  
9744 fail:
9745 if (priv) {
9746 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9747 if (priv->tfm)
9748 crypto_free_tfm(priv->tfm);
9749 +#else
9750 + if (priv->tx_tfm)
9751 + crypto_free_blkcipher(priv->tx_tfm);
9752 + if (priv->rx_tfm)
9753 + crypto_free_blkcipher(priv->rx_tfm);
9754 +#endif
9755 kfree(priv);
9756 }
9757 return NULL;
9758 }
9759  
9760  
9761 -static void prism2_wep_deinit(void *priv)
9762 +static void prism2_wep_deinit_rtl7(void *priv)
9763 {
9764 struct prism2_wep_data *_priv = priv;
9765 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
9766 if (_priv && _priv->tfm)
9767 crypto_free_tfm(_priv->tfm);
9768 +#else
9769 + if (_priv) {
9770 + if (_priv->tx_tfm)
9771 + crypto_free_blkcipher(_priv->tx_tfm);
9772 + if (_priv->rx_tfm)
9773 + crypto_free_blkcipher(_priv->rx_tfm);
9774 + }
9775 +#endif
9776 kfree(priv);
9777 }
9778  
9779 @@ -87,13 +135,16 @@
9780 *
9781 * WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
9782 */
9783 -static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
9784 +static int prism2_wep_encrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
9785 {
9786 struct prism2_wep_data *wep = priv;
9787 u32 crc, klen, len;
9788 u8 key[WEP_KEY_LEN + 3];
9789 u8 *pos, *icv;
9790 struct scatterlist sg;
9791 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
9792 + struct blkcipher_desc desc = { .tfm = wep->tx_tfm };
9793 +#endif
9794  
9795 if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
9796 skb->len < hdr_len)
9797 @@ -134,13 +185,25 @@
9798 icv[2] = crc >> 16;
9799 icv[3] = crc >> 24;
9800  
9801 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9802 crypto_cipher_setkey(wep->tfm, key, klen);
9803 +#else
9804 + crypto_blkcipher_setkey(wep->tx_tfm, key, klen);
9805 +#endif
9806 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9807 sg.page = virt_to_page(pos);
9808 sg.offset = offset_in_page(pos);
9809 sg.length = len + 4;
9810 - crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
9811 +#else
9812 + sg_set_page(&sg, virt_to_page(pos), len + 4, offset_in_page(pos));
9813 +#endif
9814  
9815 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9816 + crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
9817 return 0;
9818 +#else
9819 + return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4);
9820 +#endif
9821 }
9822  
9823  
9824 @@ -151,13 +214,16 @@
9825 * Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
9826 * failure. If frame is OK, IV and ICV will be removed.
9827 */
9828 -static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
9829 +static int prism2_wep_decrypt_rtl7(struct sk_buff *skb, int hdr_len, void *priv)
9830 {
9831 struct prism2_wep_data *wep = priv;
9832 u32 crc, klen, plen;
9833 u8 key[WEP_KEY_LEN + 3];
9834 u8 keyidx, *pos, icv[4];
9835 struct scatterlist sg;
9836 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19))
9837 + struct blkcipher_desc desc = { .tfm = wep->rx_tfm };
9838 +#endif
9839  
9840 if (skb->len < hdr_len + 8)
9841 return -1;
9842 @@ -178,11 +244,26 @@
9843 /* Apply RC4 to data and compute CRC32 over decrypted data */
9844 plen = skb->len - hdr_len - 8;
9845  
9846 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9847 crypto_cipher_setkey(wep->tfm, key, klen);
9848 +#else
9849 + crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
9850 +#endif
9851 +
9852 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9853 sg.page = virt_to_page(pos);
9854 sg.offset = offset_in_page(pos);
9855 sg.length = plen + 4;
9856 +#else
9857 + sg_set_page(&sg, virt_to_page(pos), plen + 4, offset_in_page(pos));
9858 +#endif
9859 +
9860 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
9861 crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
9862 +#else
9863 + if(crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4))
9864 + return -7;
9865 +#endif
9866  
9867 crc = ~crc32_le(~0, pos, plen);
9868 icv[0] = crc;
9869 @@ -203,7 +284,7 @@
9870 }
9871  
9872  
9873 -static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
9874 +static int prism2_wep_set_key_rtl7(void *key, int len, u8 *seq, void *priv)
9875 {
9876 struct prism2_wep_data *wep = priv;
9877  
9878 @@ -217,7 +298,7 @@
9879 }
9880  
9881  
9882 -static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
9883 +static int prism2_wep_get_key_rtl7(void *key, int len, u8 *seq, void *priv)
9884 {
9885 struct prism2_wep_data *wep = priv;
9886  
9887 @@ -230,7 +311,7 @@
9888 }
9889  
9890  
9891 -static char * prism2_wep_print_stats(char *p, void *priv)
9892 +static char * prism2_wep_print_stats_rtl7(char *p, void *priv)
9893 {
9894 struct prism2_wep_data *wep = priv;
9895 p += sprintf(p, "key[%d] alg=WEP len=%d\n",
9896 @@ -239,34 +320,34 @@
9897 }
9898  
9899  
9900 -static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
9901 +static struct ieee80211_crypto_ops ieee80211_crypt_wep_rtl7 = {
9902 .name = "WEP",
9903 - .init = prism2_wep_init,
9904 - .deinit = prism2_wep_deinit,
9905 - .encrypt_mpdu = prism2_wep_encrypt,
9906 - .decrypt_mpdu = prism2_wep_decrypt,
9907 + .init = prism2_wep_init_rtl7,
9908 + .deinit = prism2_wep_deinit_rtl7,
9909 + .encrypt_mpdu = prism2_wep_encrypt_rtl7,
9910 + .decrypt_mpdu = prism2_wep_decrypt_rtl7,
9911 .encrypt_msdu = NULL,
9912 .decrypt_msdu = NULL,
9913 - .set_key = prism2_wep_set_key,
9914 - .get_key = prism2_wep_get_key,
9915 - .print_stats = prism2_wep_print_stats,
9916 + .set_key = prism2_wep_set_key_rtl7,
9917 + .get_key = prism2_wep_get_key_rtl7,
9918 + .print_stats = prism2_wep_print_stats_rtl7,
9919 .extra_prefix_len = 4, /* IV */
9920 .extra_postfix_len = 4, /* ICV */
9921 .owner = THIS_MODULE,
9922 };
9923  
9924  
9925 -static int __init ieee80211_crypto_wep_init(void)
9926 +static int __init ieee80211_crypto_wep_init_rtl7(void)
9927 {
9928 - return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
9929 + return ieee80211_register_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
9930 }
9931  
9932  
9933 -static void __exit ieee80211_crypto_wep_exit(void)
9934 +static void __exit ieee80211_crypto_wep_exit_rtl7(void)
9935 {
9936 - ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
9937 + ieee80211_unregister_crypto_ops_rtl7(&ieee80211_crypt_wep_rtl7);
9938 }
9939  
9940  
9941 -module_init(ieee80211_crypto_wep_init);
9942 -module_exit(ieee80211_crypto_wep_exit);
9943 +module_init(ieee80211_crypto_wep_init_rtl7);
9944 +module_exit(ieee80211_crypto_wep_exit_rtl7);
9945 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211.h rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h
9946 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211.h 2006-06-05 22:57:56.000000000 -0400
9947 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211.h 2008-08-12 14:23:20.000000000 -0400
9948 @@ -120,7 +120,7 @@
9949 static inline unsigned long msleep_interruptible_rtl(unsigned int msecs)
9950 {
9951 unsigned long timeout = MSECS(msecs) + 1;
9952 -
9953 +
9954 while (timeout) {
9955 set_current_state(TASK_UNINTERRUPTIBLE);
9956 timeout = schedule_timeout(timeout);
9957 @@ -156,6 +156,22 @@
9958 struct list_head list;
9959 };
9960  
9961 +#define LWNG_CAP_DID_BASE (4 | (1 << 6)) /* section 4, group 1 */
9962 +/* ARPHRD_IEEE80211_PRISM uses a bloated version of Prism2 RX frame header
9963 + * (from linux-wlan-ng) */
9964 +struct linux_wlan_ng_val {
9965 + u32 did;
9966 + u16 status, len;
9967 + u32 data;
9968 +} __attribute__ ((packed));
9969 +
9970 +struct linux_wlan_ng_prism_hdr {
9971 + u32 msgcode, msglen;
9972 + char devname[16];
9973 + struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
9974 + noise, rate, istx, frmlen;
9975 +} __attribute__ ((packed));
9976 +
9977 struct ieee80211_hdr {
9978 u16 frame_ctl;
9979 u16 duration_id;
9980 @@ -798,7 +814,7 @@
9981  
9982 /* the card is not linked at all */
9983 IEEE80211_NOLINK = 0,
9984 -
9985 +
9986 /* IEEE80211_ASSOCIATING* are for BSS client mode
9987 * the driver shall not perform RX filtering unless
9988 * the state is LINKED.
9989 @@ -806,31 +822,31 @@
9990 * defaults to NOLINK for ALL the other states (including
9991 * LINKED_SCANNING)
9992 */
9993 -
9994 +
9995 /* the association procedure will start (wq scheduling)*/
9996 IEEE80211_ASSOCIATING,
9997 IEEE80211_ASSOCIATING_RETRY,
9998 -
9999 +
10000 /* the association procedure is sending AUTH request*/
10001 IEEE80211_ASSOCIATING_AUTHENTICATING,
10002 -
10003 +
10004 /* the association procedure has successfully authentcated
10005 * and is sending association request
10006 */
10007 IEEE80211_ASSOCIATING_AUTHENTICATED,
10008 -
10009 +
10010 /* the link is ok. the card associated to a BSS or linked
10011 * to a ibss cell or acting as an AP and creating the bss
10012 */
10013 IEEE80211_LINKED,
10014 -
10015 +
10016 /* same as LINKED, but the driver shall apply RX filter
10017 * rules as we are in NO_LINK mode. As the card is still
10018 * logically linked, but it is doing a syncro site survey
10019 * then it will be back to LINKED state.
10020 */
10021 IEEE80211_LINKED_SCANNING,
10022 -
10023 +
10024 };
10025  
10026 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
10027 @@ -840,14 +856,14 @@
10028  
10029  
10030 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11))
10031 -extern inline int is_multicast_ether_addr(const u8 *addr)
10032 +extern inline int is_multicast_ether_addr_rtl7(const u8 *addr)
10033 {
10034 return ((addr[0] != 0xff) && (0x01 & addr[0]));
10035 }
10036 #endif
10037  
10038 #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13))
10039 -extern inline int is_broadcast_ether_addr(const u8 *addr)
10040 +extern inline int is_broadcast_ether_addr_rtl7(const u8 *addr)
10041 {
10042 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
10043 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
10044 @@ -870,7 +886,7 @@
10045 struct net_device_stats stats;
10046 struct ieee80211_stats ieee_stats;
10047 struct ieee80211_softmac_stats softmac_stats;
10048 -
10049 +
10050 /* Probe / Beacon management */
10051 struct list_head network_free_list;
10052 struct list_head network_list;
10053 @@ -881,7 +897,7 @@
10054 int iw_mode; /* operating mode (IW_MODE_*) */
10055  
10056 spinlock_t lock;
10057 -
10058 +
10059 int tx_headroom; /* Set to size of any additional room needed at front
10060 * of allocated Tx SKBs */
10061 u32 config;
10062 @@ -924,11 +940,11 @@
10063 * ad-hoc is a mixture ;-).
10064 * Note that in infrastructure mode, even when not associated,
10065 * fields bssid and essid may be valid (if wpa_set and essid_set
10066 - * are true) as thy carry the value set by the user via iwconfig
10067 + * are true) as thy carry the value set by the user via iwconfig
10068 */
10069 struct ieee80211_network current_network;
10070  
10071 -
10072 +
10073 enum ieee80211_state state;
10074  
10075 int short_slot;
10076 @@ -936,33 +952,33 @@
10077 int modulation; /* CCK, OFDM */
10078 int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
10079 int abg_true; /* ABG flag */
10080 -
10081 - /* used for forcing the ibss workqueue to terminate
10082 +
10083 + /* used for forcing the ibss workqueue to terminate
10084 * without wait for the syncro scan to terminate
10085 */
10086 - short sync_scan_hurryup;
10087 -
10088 + short sync_scan_hurryup;
10089 +
10090 /* map of allowed channels. 0 is dummy */
10091 // FIXME: remeber to default to a basic channel plan depending of the PHY type
10092 int channel_map[MAX_CHANNEL_NUMBER+1];
10093 -
10094 +
10095 int rate; /* current rate */
10096 int basic_rate;
10097 //FIXME: pleace callback, see if redundant with softmac_features
10098 short active_scan;
10099 -
10100 +
10101 /* this contains flags for selectively enable softmac support */
10102 u16 softmac_features;
10103 -
10104 +
10105 /* if the sequence control field is not filled by HW */
10106 u16 seq_ctrl;
10107 -
10108 +
10109 /* association procedure transaction sequence number */
10110 u16 associate_seq;
10111 -
10112 +
10113 /* AID for RTXed association responses */
10114 u16 assoc_id;
10115 -
10116 +
10117 /* power save mode related*/
10118 short ps;
10119 short sta_sleep;
10120 @@ -970,147 +986,153 @@
10121 struct tasklet_struct ps_task;
10122 u32 ps_th;
10123 u32 ps_tl;
10124 -
10125 +
10126 short raw_tx;
10127 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
10128 short queue_stop;
10129 short scanning;
10130 short proto_started;
10131 -
10132 +
10133 struct semaphore wx_sem;
10134 struct semaphore scan_sem;
10135 -
10136 - spinlock_t mgmt_tx_lock;
10137 +
10138 + spinlock_t mgmt_tx_lock;
10139 spinlock_t beacon_lock;
10140  
10141 short beacon_txing;
10142  
10143 short wap_set;
10144 short ssid_set;
10145 -
10146 +
10147 /* for discarding duplicated packets in IBSS */
10148 struct list_head ibss_mac_hash[IEEE_IBSS_MAC_HASH_SIZE];
10149 -
10150 +
10151 /* for discarding duplicated packets in BSS */
10152 u16 last_seq_num;
10153 u16 last_frag_num;
10154 unsigned long last_packet_time;
10155 -
10156 +
10157 /* for PS mode */
10158 unsigned long last_rx_ps_time;
10159 -
10160 +
10161 /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
10162 struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM];
10163 int mgmt_queue_head;
10164 int mgmt_queue_tail;
10165 -
10166 -
10167 +
10168 +
10169 /* used if IEEE_SOFTMAC_TX_QUEUE is set */
10170 struct tx_pending_t tx_pending;
10171 -
10172 +
10173 /* used if IEEE_SOFTMAC_ASSOCIATE is set */
10174 struct timer_list associate_timer;
10175  
10176 /* used if IEEE_SOFTMAC_BEACONS is set */
10177 struct timer_list beacon_timer;
10178 -
10179 +
10180 struct work_struct associate_complete_wq;
10181 +
10182 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
10183 + struct delayed_work associate_retry_wq;
10184 + struct delayed_work softmac_scan_wq;
10185 +#else
10186 struct work_struct associate_retry_wq;
10187 + struct work_struct softmac_scan_wq;
10188 +#endif
10189 struct work_struct start_ibss_wq;
10190 struct work_struct associate_procedure_wq;
10191 - struct work_struct softmac_scan_wq;
10192 struct work_struct wx_sync_scan_wq;
10193 -
10194 +
10195 struct workqueue_struct *wq;
10196 /* Callback functions */
10197 void (*set_security)(struct net_device *dev,
10198 struct ieee80211_security *sec);
10199 -
10200 +
10201 /* Used to TX data frame by using txb structs.
10202 * this is not used if in the softmac_features
10203 * is set the flag IEEE_SOFTMAC_TX_QUEUE
10204 */
10205 int (*hard_start_xmit)(struct ieee80211_txb *txb,
10206 struct net_device *dev);
10207 -
10208 +
10209 int (*reset_port)(struct net_device *dev);
10210  
10211 - /* Softmac-generated frames (mamagement) are TXed via this
10212 - * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
10213 - * not set. As some cards may have different HW queues that
10214 + /* Softmac-generated frames (mamagement) are TXed via this
10215 + * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
10216 + * not set. As some cards may have different HW queues that
10217 * one might want to use for data and management frames
10218 * the option to have two callbacks might be useful.
10219 * This fucntion can't sleep.
10220 */
10221 int (*softmac_hard_start_xmit)(struct sk_buff *skb,
10222 struct net_device *dev);
10223 -
10224 +
10225 /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
10226 * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
10227 * frames. I the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
10228 * then also management frames are sent via this callback.
10229 * This function can't sleep.
10230 - */
10231 + */
10232 void (*softmac_data_hard_start_xmit)(struct sk_buff *skb,
10233 struct net_device *dev,int rate);
10234  
10235 /* stops the HW queue for DATA frames. Useful to avoid
10236 * waste time to TX data frame when we are reassociating
10237 * This function can sleep.
10238 - */
10239 + */
10240 void (*data_hard_stop)(struct net_device *dev);
10241 -
10242 +
10243 /* OK this is complementar to data_poll_hard_stop */
10244 void (*data_hard_resume)(struct net_device *dev);
10245 -
10246 +
10247 /* ask to the driver to retune the radio .
10248 * This function can sleep. the driver should ensure
10249 * the radio has been swithced before return.
10250 */
10251 void (*set_chan)(struct net_device *dev,short ch);
10252 -
10253 +
10254 /* These are not used if the ieee stack takes care of
10255 - * scanning (IEEE_SOFTMAC_SCAN feature set).
10256 + * scanning (IEEE_SOFTMAC_SCAN feature set).
10257 * In this case only the set_chan is used.
10258 *
10259 * The syncro version is similar to the start_scan but
10260 * does not return until all channels has been scanned.
10261 - * this is called in user context and should sleep,
10262 + * this is called in user context and should sleep,
10263 * it is called in a work_queue when swithcing to ad-hoc mode
10264 - * or in behalf of iwlist scan when the card is associated
10265 - * and root user ask for a scan.
10266 + * or in behalf of iwlist scan when the card is associated
10267 + * and root user ask for a scan.
10268 * the fucntion stop_scan should stop both the syncro and
10269 * background scanning and can sleep.
10270 - * The fucntion start_scan should initiate the background
10271 + * The fucntion start_scan should initiate the background
10272 * scanning and can't sleep.
10273 - */
10274 + */
10275 void (*scan_syncro)(struct net_device *dev);
10276 void (*start_scan)(struct net_device *dev);
10277 void (*stop_scan)(struct net_device *dev);
10278 -
10279 +
10280 /* indicate the driver that the link state is changed
10281 * for example it may indicate the card is associated now.
10282 - * Driver might be interested in this to apply RX filter
10283 - * rules or simply light the LINK led
10284 + * Driver might be interested in this to apply RX filter
10285 + * rules or simply light the LINK led
10286 */
10287 void (*link_change)(struct net_device *dev);
10288 -
10289 +
10290 /* these two function indicates to the HW when to start
10291 - * and stop to send beacons. This is used when the
10292 + * and stop to send beacons. This is used when the
10293 * IEEE_SOFTMAC_BEACONS is not set. For now the
10294 * stop_send_bacons is NOT guaranteed to be called only
10295 * after start_send_beacons.
10296 */
10297 void (*start_send_beacons) (struct net_device *dev);
10298 void (*stop_send_beacons) (struct net_device *dev);
10299 -
10300 +
10301 /* power save mode related */
10302 void (*sta_wake_up) (struct net_device *dev);
10303 void (*ps_request_tx_ack) (struct net_device *dev);
10304 void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl);
10305 short (*ps_is_queue_empty) (struct net_device *dev);
10306 -
10307 -
10308 +
10309 +
10310 /* This must be the last item so that it points to the data
10311 * allocated beyond this structure by alloc_ieee80211 */
10312 u8 priv[0];
10313 @@ -1148,18 +1170,21 @@
10314 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
10315  
10316 /* Generate beacons. The stack will enqueue beacons
10317 - * to the card
10318 - */
10319 + * to the card
10320 + */
10321 #define IEEE_SOFTMAC_BEACONS (1<<6)
10322  
10323  
10324 -
10325 -extern inline void *ieee80211_priv(struct net_device *dev)
10326 +#if WIRELESS_EXT >= 22
10327 +static inline void *ieee80211_priv_rtl7(struct net_device *dev)
10328 +#else
10329 +extern inline void *ieee80211_priv_rtl7(struct net_device *dev)
10330 +#endif
10331 {
10332 return ((struct ieee80211_device *)netdev_priv(dev))->priv;
10333 }
10334  
10335 -extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
10336 +extern inline int ieee80211_is_empty_essid_rtl7(const char *essid, int essid_len)
10337 {
10338 /* Single white space is for Linksys APs */
10339 if (essid_len == 1 && essid[0] == ' ')
10340 @@ -1175,7 +1200,7 @@
10341 return 1;
10342 }
10343  
10344 -extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
10345 +extern inline int ieee80211_is_valid_mode_rtl7(struct ieee80211_device *ieee, int mode)
10346 {
10347 /*
10348 * It is possible for both access points and our device to support
10349 @@ -1201,7 +1226,7 @@
10350 return 0;
10351 }
10352  
10353 -extern inline int ieee80211_get_hdrlen(u16 fc)
10354 +extern inline int ieee80211_get_hdrlen_rtl7(u16 fc)
10355 {
10356 int hdrlen = 24;
10357  
10358 @@ -1229,140 +1254,144 @@
10359  
10360  
10361 /* ieee80211.c */
10362 -extern void free_ieee80211(struct net_device *dev);
10363 -extern struct net_device *alloc_ieee80211(int sizeof_priv);
10364 +extern void free_ieee80211_rtl7(struct net_device *dev);
10365 +extern struct net_device *alloc_ieee80211_rtl7(int sizeof_priv);
10366  
10367 -extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
10368 +extern int ieee80211_set_encryption_rtl7(struct ieee80211_device *ieee);
10369  
10370 /* ieee80211_tx.c */
10371  
10372 -extern int ieee80211_encrypt_fragment(
10373 +extern int ieee80211_encrypt_fragment_rtl7(
10374 struct ieee80211_device *ieee,
10375 struct sk_buff *frag,
10376 int hdr_len);
10377 -
10378 -extern int ieee80211_xmit(struct sk_buff *skb,
10379 +
10380 +extern int ieee80211_xmit_rtl7(struct sk_buff *skb,
10381 struct net_device *dev);
10382 -extern void ieee80211_txb_free(struct ieee80211_txb *);
10383 +extern void ieee80211_txb_free_rtl7(struct ieee80211_txb *);
10384  
10385  
10386 /* ieee80211_rx.c */
10387 -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
10388 +extern int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
10389 struct ieee80211_rx_stats *rx_stats);
10390 -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
10391 +extern void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
10392 struct ieee80211_hdr *header,
10393 struct ieee80211_rx_stats *stats);
10394  
10395 /* ieee80211_wx.c */
10396 -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
10397 +extern int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
10398 struct iw_request_info *info,
10399 union iwreq_data *wrqu, char *key);
10400 -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
10401 +extern int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
10402 struct iw_request_info *info,
10403 union iwreq_data *wrqu, char *key);
10404 -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
10405 +extern int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
10406 struct iw_request_info *info,
10407 union iwreq_data *wrqu, char *key);
10408 /* ieee80211_softmac.c */
10409 -extern short ieee80211_is_54g(struct ieee80211_network net);
10410 -extern short ieee80211_is_shortslot(struct ieee80211_network net);
10411 -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
10412 +extern short ieee80211_is_54g_rtl7(struct ieee80211_network net);
10413 +extern short ieee80211_is_shortslot_rtl7(struct ieee80211_network net);
10414 +extern int ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
10415 struct ieee80211_rx_stats *rx_stats, u16 type,
10416 u16 stype);
10417 -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net);
10418 +extern void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net);
10419  
10420 -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
10421 -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee);
10422 -extern void ieee80211_start_bss(struct ieee80211_device *ieee);
10423 -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee);
10424 -extern void ieee80211_start_ibss(struct ieee80211_device *ieee);
10425 -extern void ieee80211_softmac_init(struct ieee80211_device *ieee);
10426 -extern void ieee80211_softmac_free(struct ieee80211_device *ieee);
10427 -extern void ieee80211_associate_abort(struct ieee80211_device *ieee);
10428 -extern void ieee80211_disassociate(struct ieee80211_device *ieee);
10429 -extern void ieee80211_stop_scan(struct ieee80211_device *ieee);
10430 -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee);
10431 -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee);
10432 -extern void ieee80211_start_protocol(struct ieee80211_device *ieee);
10433 -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee);
10434 -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee);
10435 -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee);
10436 -extern void ieee80211_reset_queue(struct ieee80211_device *ieee);
10437 -extern void ieee80211_wake_queue(struct ieee80211_device *ieee);
10438 -extern void ieee80211_stop_queue(struct ieee80211_device *ieee);
10439 -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee);
10440 -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee);
10441 -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee);
10442 -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p);
10443 -extern void notify_wx_assoc_event(struct ieee80211_device *ieee);
10444 -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success);
10445 +extern void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee);
10446 +extern void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee);
10447 +extern void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee);
10448 +extern void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee);
10449 +extern void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee);
10450 +extern void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee);
10451 +extern void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee);
10452 +extern void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee);
10453 +extern void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee);
10454 +extern void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee);
10455 +extern void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee);
10456 +extern void ieee80211_check_all_nets_rtl7(struct ieee80211_device *ieee);
10457 +extern void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee);
10458 +extern void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee);
10459 +extern void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee);
10460 +extern void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee);
10461 +extern void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee);
10462 +extern void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee);
10463 +extern void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee);
10464 +extern struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee);
10465 +extern void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee);
10466 +extern void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee);
10467 +extern int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p);
10468 +extern void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee);
10469 +extern void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success);
10470  
10471 /* ieee80211_softmac_wx.c */
10472  
10473 -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
10474 - struct iw_request_info *info,
10475 +extern int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
10476 + struct iw_request_info *info,
10477 union iwreq_data *wrqu, char *ext);
10478 -
10479 -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
10480 +
10481 +extern int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
10482 struct iw_request_info *info,
10483 union iwreq_data *awrq,
10484 char *extra);
10485 -
10486 -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
10487  
10488 -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
10489 +extern int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b);
10490 +
10491 +extern int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
10492 struct iw_request_info *info,
10493 union iwreq_data *wrqu, char *extra);
10494 -
10495 -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
10496 - struct iw_request_info *info,
10497 +
10498 +extern int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
10499 + struct iw_request_info *info,
10500 union iwreq_data *wrqu, char *extra);
10501 -
10502 -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
10503 +
10504 +extern int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
10505 union iwreq_data *wrqu, char *b);
10506 -
10507 -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
10508 +
10509 +extern int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
10510 union iwreq_data *wrqu, char *b);
10511 -
10512 -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
10513 +
10514 +extern int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
10515 struct iw_request_info *a,
10516 union iwreq_data *wrqu, char *extra);
10517 -
10518 -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
10519 +
10520 +extern int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
10521 union iwreq_data *wrqu, char *b);
10522  
10523 -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
10524 +extern int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
10525 union iwreq_data *wrqu, char *b);
10526  
10527 -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
10528 +extern int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
10529 union iwreq_data *wrqu, char *b);
10530  
10531 -extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee);
10532 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
10533 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work);
10534 +#else
10535 +extern void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee);
10536 +#endif
10537  
10538 -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
10539 - struct iw_request_info *info,
10540 +extern int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
10541 + struct iw_request_info *info,
10542 union iwreq_data *wrqu, char *extra);
10543 -
10544 -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee,
10545 - struct iw_request_info *info,
10546 +
10547 +extern int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
10548 + struct iw_request_info *info,
10549 union iwreq_data *wrqu, char *extra);
10550  
10551 -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee,
10552 +extern int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
10553 struct iw_request_info *info,
10554 union iwreq_data *wrqu, char *extra);
10555  
10556 -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee,
10557 +extern int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
10558 struct iw_request_info *info,
10559 union iwreq_data *wrqu, char *extra);
10560 -
10561 -extern const long ieee80211_wlan_frequencies[];
10562  
10563 -extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
10564 +extern const long ieee80211_wlan_frequencies_rtl7[];
10565 +
10566 +extern inline void ieee80211_increment_scans_rtl7(struct ieee80211_device *ieee)
10567 {
10568 ieee->scans++;
10569 }
10570  
10571 -extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
10572 +extern inline int ieee80211_get_scans_rtl7(struct ieee80211_device *ieee)
10573 {
10574 return ieee->scans;
10575 }
10576 @@ -1372,7 +1401,7 @@
10577 const char *s = essid;
10578 char *d = escaped;
10579  
10580 - if (ieee80211_is_empty_essid(essid, essid_len)) {
10581 + if (ieee80211_is_empty_essid_rtl7(essid, essid_len)) {
10582 memcpy(escaped, "<hidden>", sizeof("<hidden>"));
10583 return escaped;
10584 }
10585 @@ -1390,4 +1419,5 @@
10586 *d = '\0';
10587 return escaped;
10588 }
10589 +
10590 #endif /* IEEE80211_H */
10591 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_module.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c
10592 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_module.c 2006-06-05 22:58:00.000000000 -0400
10593 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.c 2008-08-12 13:11:32.000000000 -0400
10594 @@ -31,7 +31,6 @@
10595 *******************************************************************************/
10596  
10597 #include <linux/compiler.h>
10598 -#include <linux/config.h>
10599 #include <linux/errno.h>
10600 #include <linux/if_arp.h>
10601 #include <linux/in6.h>
10602 @@ -52,6 +51,12 @@
10603 #include <asm/uaccess.h>
10604 #include <net/arp.h>
10605  
10606 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
10607 +#include <linux/config.h>
10608 +#else
10609 +#include <linux/autoconf.h>
10610 +#endif
10611 +
10612 #include "ieee80211.h"
10613  
10614 MODULE_DESCRIPTION("802.11 data/management/control stack");
10615 @@ -60,7 +65,7 @@
10616  
10617 #define DRV_NAME "ieee80211"
10618  
10619 -static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
10620 +static inline int ieee80211_networks_allocate_rtl7(struct ieee80211_device *ieee)
10621 {
10622 if (ieee->networks)
10623 return 0;
10624 @@ -80,7 +85,7 @@
10625 return 0;
10626 }
10627  
10628 -static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
10629 +static inline void ieee80211_networks_free_rtl7(struct ieee80211_device *ieee)
10630 {
10631 if (!ieee->networks)
10632 return;
10633 @@ -88,7 +93,7 @@
10634 ieee->networks = NULL;
10635 }
10636  
10637 -static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
10638 +static inline void ieee80211_networks_initialize_rtl7(struct ieee80211_device *ieee)
10639 {
10640 int i;
10641  
10642 @@ -99,7 +104,7 @@
10643 }
10644  
10645  
10646 -struct net_device *alloc_ieee80211(int sizeof_priv)
10647 +struct net_device *alloc_ieee80211_rtl7(int sizeof_priv)
10648 {
10649 struct ieee80211_device *ieee;
10650 struct net_device *dev;
10651 @@ -113,17 +118,17 @@
10652 goto failed;
10653 }
10654 ieee = netdev_priv(dev);
10655 - dev->hard_start_xmit = ieee80211_xmit;
10656 + dev->hard_start_xmit = ieee80211_xmit_rtl7;
10657  
10658 ieee->dev = dev;
10659  
10660 - err = ieee80211_networks_allocate(ieee);
10661 + err = ieee80211_networks_allocate_rtl7(ieee);
10662 if (err) {
10663 IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
10664 err);
10665 goto failed;
10666 }
10667 - ieee80211_networks_initialize(ieee);
10668 + ieee80211_networks_initialize_rtl7(ieee);
10669  
10670 /* Default fragmentation threshold is maximum payload size */
10671 ieee->fts = DEFAULT_FTS;
10672 @@ -138,7 +143,7 @@
10673 INIT_LIST_HEAD(&ieee->crypt_deinit_list);
10674 init_timer(&ieee->crypt_deinit_timer);
10675 ieee->crypt_deinit_timer.data = (unsigned long)ieee;
10676 - ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
10677 + ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler_rtl7;
10678  
10679 spin_lock_init(&ieee->lock);
10680  
10681 @@ -149,7 +154,7 @@
10682 ieee->ieee802_1x = 1;
10683 ieee->raw_tx = 0;
10684  
10685 - ieee80211_softmac_init(ieee);
10686 + ieee80211_softmac_init_rtl7(ieee);
10687  
10688 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
10689 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
10690 @@ -167,7 +172,7 @@
10691 }
10692  
10693  
10694 -void free_ieee80211(struct net_device *dev)
10695 +void free_ieee80211_rtl7(struct net_device *dev)
10696 {
10697 struct ieee80211_device *ieee = netdev_priv(dev);
10698  
10699 @@ -175,9 +180,9 @@
10700 struct list_head *p, *q;
10701  
10702  
10703 - ieee80211_softmac_free(ieee);
10704 + ieee80211_softmac_free_rtl7(ieee);
10705 del_timer_sync(&ieee->crypt_deinit_timer);
10706 - ieee80211_crypt_deinit_entries(ieee, 1);
10707 + ieee80211_crypt_deinit_entries_rtl7(ieee, 1);
10708  
10709 for (i = 0; i < WEP_KEYS; i++) {
10710 struct ieee80211_crypt_data *crypt = ieee->crypt[i];
10711 @@ -191,7 +196,7 @@
10712 }
10713 }
10714  
10715 - ieee80211_networks_free(ieee);
10716 + ieee80211_networks_free_rtl7(ieee);
10717  
10718 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++) {
10719 list_for_each_safe(p, q, &ieee->ibss_mac_hash[i]) {
10720 @@ -210,13 +215,13 @@
10721 u32 ieee80211_debug_level = 0;
10722 struct proc_dir_entry *ieee80211_proc = NULL;
10723  
10724 -static int show_debug_level(char *page, char **start, off_t offset,
10725 +static int show_debug_level_rtl7(char *page, char **start, off_t offset,
10726 int count, int *eof, void *data)
10727 {
10728 return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
10729 }
10730  
10731 -static int store_debug_level(struct file *file, const char *buffer,
10732 +static int store_debug_level_rtl7(struct file *file, const char *buffer,
10733 unsigned long count, void *data)
10734 {
10735 char buf[] = "0x00000000";
10736 @@ -243,7 +248,7 @@
10737 return strnlen(buf, count);
10738 }
10739  
10740 -static int __init ieee80211_init(void)
10741 +static int __init ieee80211_init_rtl7(void)
10742 {
10743 struct proc_dir_entry *e;
10744  
10745 @@ -268,7 +273,7 @@
10746 return 0;
10747 }
10748  
10749 -static void __exit ieee80211_exit(void)
10750 +static void __exit ieee80211_exit_rtl7(void)
10751 {
10752 if (ieee80211_proc) {
10753 remove_proc_entry("debug_level", ieee80211_proc);
10754 @@ -282,9 +287,9 @@
10755 MODULE_PARM_DESC(debug, "debug output mask");
10756  
10757  
10758 -module_exit(ieee80211_exit);
10759 -module_init(ieee80211_init);
10760 +module_exit(ieee80211_exit_rtl7);
10761 +module_init(ieee80211_init_rtl7);
10762 #endif
10763  
10764 -EXPORT_SYMBOL(alloc_ieee80211);
10765 -EXPORT_SYMBOL(free_ieee80211);
10766 +EXPORT_SYMBOL(alloc_ieee80211_rtl7);
10767 +EXPORT_SYMBOL(free_ieee80211_rtl7);
10768 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_rx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c
10769 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_rx.c 2006-06-05 22:58:00.000000000 -0400
10770 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.c 2008-08-12 13:11:32.000000000 -0400
10771 @@ -13,16 +13,15 @@
10772 * more details.
10773 ******************************************************************************
10774  
10775 - Few modifications for Realtek's Wi-Fi drivers by
10776 + Few modifications for Realtek's Wi-Fi drivers by
10777 Andrea Merello <andreamrl@tiscali.it>
10778 -
10779 - A special thanks goes to Realtek for their support !
10780 +
10781 + A special thanks goes to Realtek for their support !
10782  
10783 ******************************************************************************/
10784 -
10785 +
10786  
10787 #include <linux/compiler.h>
10788 -#include <linux/config.h>
10789 #include <linux/errno.h>
10790 #include <linux/if_arp.h>
10791 #include <linux/in6.h>
10792 @@ -43,18 +42,89 @@
10793 #include <asm/uaccess.h>
10794 #include <linux/ctype.h>
10795  
10796 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
10797 +#include <linux/config.h>
10798 +#else
10799 +#include <linux/autoconf.h>
10800 +#endif
10801 +
10802 +
10803 #include "ieee80211.h"
10804  
10805 -static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
10806 +static inline void ieee80211_monitor_rx_rtl7(struct ieee80211_device *ieee,
10807 struct sk_buff *skb,
10808 struct ieee80211_rx_stats *rx_stats)
10809 {
10810 - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
10811 - u16 fc = le16_to_cpu(hdr->frame_ctl);
10812 + struct ieee80211_hdr *hdr1 = (struct ieee80211_hdr *)skb->data;
10813 + u16 fc = le16_to_cpu(hdr1->frame_ctl);
10814 + int prism_header;
10815 + int hdrlen, phdrlen, head_need, tail_need;
10816 +
10817 + if (ieee->dev->type == ARPHRD_IEEE80211_PRISM) {
10818 + prism_header = 1;
10819 + phdrlen = sizeof(struct linux_wlan_ng_prism_hdr);
10820 + } else {
10821 + prism_header = 0;
10822 + phdrlen = 0;
10823 + }
10824 +
10825 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
10826 +
10827 + /* check if there is enough room for extra data; if not, expand skb
10828 + * buffer to be large enough for the changes */
10829 + head_need = phdrlen;
10830 + tail_need = 0;
10831 +#ifdef PRISM2_ADD_BOGUS_CRC
10832 + tail_need += 4;
10833 +#endif /* PRISM2_ADD_BOGUS_CRC */
10834 +
10835 + head_need -= skb_headroom(skb);
10836 + tail_need -= skb_tailroom(skb);
10837 +
10838 + if (head_need > 0 || tail_need > 0) {
10839 + if (pskb_expand_head(skb, head_need > 0 ? head_need : 0,
10840 + tail_need > 0 ? tail_need : 0,
10841 + GFP_ATOMIC)) {
10842 + printk(KERN_DEBUG "%s: ieee80211_rx failed to "
10843 + "reallocate skb buffer\n", ieee->dev->name);
10844 + dev_kfree_skb_any(skb);
10845 + return;
10846 + }
10847 + }
10848 +
10849 + if (prism_header == 1) {
10850 + struct linux_wlan_ng_prism_hdr *hdr;
10851 + hdr = (struct linux_wlan_ng_prism_hdr *)
10852 + skb_push(skb, phdrlen);
10853 + memset(hdr, 0, phdrlen);
10854 + hdr->msgcode = LWNG_CAP_DID_BASE;
10855 + hdr->msglen = sizeof(*hdr);
10856 + memcpy(hdr->devname, ieee->dev->name, sizeof(hdr->devname));
10857 +#define LWNG_SETVAL(f,i,s,l,d) \
10858 +hdr->f.did = LWNG_CAP_DID_BASE | (i << 12); \
10859 +hdr->f.status = s; hdr->f.len = l; hdr->f.data = d
10860 + LWNG_SETVAL(hosttime, 1, 0, 4, jiffies);
10861 + LWNG_SETVAL(mactime, 2, 0, 4, ((u32)rx_stats->mac_time));
10862 + LWNG_SETVAL(channel, 3, 1 /* no value */, 4, 0);
10863 + LWNG_SETVAL(rssi, 4, 1 /* no value */, 4, 0);
10864 + LWNG_SETVAL(sq, 5, 1 /* no value */, 4, 0);
10865 + LWNG_SETVAL(signal, 6, 0, 4, rx_stats->signal);
10866 + LWNG_SETVAL(noise, 7, 0, 4, rx_stats->noise);
10867 + LWNG_SETVAL(rate, 8, 0, 4, rx_stats->rate / 5);
10868 + LWNG_SETVAL(istx, 9, 0, 4, 0);
10869 + LWNG_SETVAL(frmlen, 10, 0, 4, skb->len - phdrlen);
10870 +#undef LWNG_SETVAL
10871 + }
10872  
10873 skb->dev = ieee->dev;
10874 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
10875 skb->mac.raw = skb->data;
10876 - skb_pull(skb, ieee80211_get_hdrlen(fc));
10877 +#else
10878 + skb_reset_mac_header(skb);
10879 +#endif
10880 + skb_pull(skb, hdrlen);
10881 + if (prism_header)
10882 + skb_pull(skb, phdrlen);
10883 skb->pkt_type = PACKET_OTHERHOST;
10884 skb->protocol = __constant_htons(ETH_P_80211_RAW);
10885 memset(skb->cb, 0, sizeof(skb->cb));
10886 @@ -64,7 +134,7 @@
10887  
10888 /* Called only as a tasklet (software IRQ) */
10889 static struct ieee80211_frag_entry *
10890 -ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
10891 +ieee80211_frag_cache_find_rtl7(struct ieee80211_device *ieee, unsigned int seq,
10892 unsigned int frag, u8 *src, u8 *dst)
10893 {
10894 struct ieee80211_frag_entry *entry;
10895 @@ -94,7 +164,7 @@
10896  
10897 /* Called only as a tasklet (software IRQ) */
10898 static struct sk_buff *
10899 -ieee80211_frag_cache_get(struct ieee80211_device *ieee,
10900 +ieee80211_frag_cache_get_rtl7(struct ieee80211_device *ieee,
10901 struct ieee80211_hdr *hdr)
10902 {
10903 struct sk_buff *skb = NULL;
10904 @@ -133,7 +203,7 @@
10905 } else {
10906 /* received a fragment of a frame for which the head fragment
10907 * should have already been received */
10908 - entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
10909 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, frag, hdr->addr2,
10910 hdr->addr1);
10911 if (entry != NULL) {
10912 entry->last_frag = frag;
10913 @@ -146,7 +216,7 @@
10914  
10915  
10916 /* Called only as a tasklet (software IRQ) */
10917 -static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
10918 +static int ieee80211_frag_cache_invalidate_rtl7(struct ieee80211_device *ieee,
10919 struct ieee80211_hdr *hdr)
10920 {
10921 u16 sc;
10922 @@ -156,7 +226,7 @@
10923 sc = le16_to_cpu(hdr->seq_ctl);
10924 seq = WLAN_GET_SEQ_SEQ(sc);
10925  
10926 - entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
10927 + entry = ieee80211_frag_cache_find_rtl7(ieee, seq, -1, hdr->addr2,
10928 hdr->addr1);
10929  
10930 if (entry == NULL) {
10931 @@ -178,7 +248,7 @@
10932 *
10933 * Called by ieee80211_rx */
10934 static inline int
10935 -ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
10936 +ieee80211_rx_frame_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
10937 struct ieee80211_rx_stats *rx_stats, u16 type,
10938 u16 stype)
10939 {
10940 @@ -187,13 +257,13 @@
10941 * response parser uses it
10942 */
10943 rx_stats->len = skb->len;
10944 - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
10945 - ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
10946 + ieee80211_rx_mgt_rtl7(ieee,(struct ieee80211_hdr *)skb->data,rx_stats);
10947 + ieee80211_rx_frame_softmac_rtl7(ieee, skb, rx_stats, type, stype);
10948  
10949 dev_kfree_skb_any(skb);
10950 -
10951 +
10952 return 0;
10953 -
10954 +
10955 #ifdef NOT_YET
10956 if (ieee->iw_mode == IW_MODE_MASTER) {
10957 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
10958 @@ -253,7 +323,7 @@
10959 /* No encapsulation header if EtherType < 0x600 (=length) */
10960  
10961 /* Called by ieee80211_rx_frame_decrypt */
10962 -static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
10963 +static int ieee80211_is_eapol_frame_rtl7(struct ieee80211_device *ieee,
10964 struct sk_buff *skb)
10965 {
10966 struct net_device *dev = ieee->dev;
10967 @@ -294,7 +364,7 @@
10968  
10969 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
10970 static inline int
10971 -ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
10972 +ieee80211_rx_frame_decrypt_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
10973 struct ieee80211_crypt_data *crypt)
10974 {
10975 struct ieee80211_hdr *hdr;
10976 @@ -304,7 +374,7 @@
10977 return 0;
10978  
10979 hdr = (struct ieee80211_hdr *) skb->data;
10980 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
10981 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
10982  
10983 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
10984 if (ieee->tkip_countermeasures &&
10985 @@ -339,7 +409,7 @@
10986  
10987 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
10988 static inline int
10989 -ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
10990 +ieee80211_rx_frame_decrypt_msdu_rtl7(struct ieee80211_device* ieee, struct sk_buff *skb,
10991 int keyidx, struct ieee80211_crypt_data *crypt)
10992 {
10993 struct ieee80211_hdr *hdr;
10994 @@ -349,7 +419,7 @@
10995 return 0;
10996  
10997 hdr = (struct ieee80211_hdr *) skb->data;
10998 - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
10999 + hdrlen = ieee80211_get_hdrlen_rtl7(le16_to_cpu(hdr->frame_ctl));
11000  
11001 atomic_inc(&crypt->refcnt);
11002 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
11003 @@ -367,7 +437,7 @@
11004  
11005 /* this function is stolen from ipw2200 driver*/
11006 #define IEEE_PACKET_RETRY_TIME (5*HZ)
11007 -static int is_duplicate_packet(struct ieee80211_device *ieee,
11008 +static int is_duplicate_packet_rtl7(struct ieee80211_device *ieee,
11009 struct ieee80211_hdr *header)
11010 {
11011 // u16 fc = le16_to_cpu(header->frame_ctl);
11012 @@ -413,7 +483,7 @@
11013 last_seq = &ieee->last_seq_num;
11014 last_frag = &ieee->last_frag_num;
11015 last_time = &ieee->last_packet_time;
11016 -
11017 +
11018 break;
11019 default:
11020 return 0;
11021 @@ -436,7 +506,7 @@
11022 drop:
11023 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
11024 // printk("DUP\n");
11025 -
11026 +
11027 return 1;
11028 }
11029  
11030 @@ -444,7 +514,7 @@
11031 /* All received frames are sent to this function. @skb contains the frame in
11032 * IEEE 802.11 format, i.e., in the format it was sent over air.
11033 * This function is called only as a tasklet (software IRQ). */
11034 -int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
11035 +int ieee80211_rx_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
11036 struct ieee80211_rx_stats *rx_stats)
11037 {
11038 struct net_device *dev = ieee->dev;
11039 @@ -481,9 +551,9 @@
11040 type = WLAN_FC_GET_TYPE(fc);
11041 stype = WLAN_FC_GET_STYPE(fc);
11042 sc = le16_to_cpu(hdr->seq_ctl);
11043 -
11044 +
11045 frag = WLAN_GET_SEQ_FRAG(sc);
11046 - hdrlen = ieee80211_get_hdrlen(fc);
11047 + hdrlen = ieee80211_get_hdrlen_rtl7(fc);
11048  
11049 #ifdef NOT_YET
11050 #if WIRELESS_EXT > 15
11051 @@ -501,12 +571,12 @@
11052 }
11053 #endif /* IW_WIRELESS_SPY */
11054 #endif /* WIRELESS_EXT > 15 */
11055 - hostap_update_rx_stats(local->ap, hdr, rx_stats);
11056 + hostap_update_rx_stats_rtl7(local->ap, hdr, rx_stats);
11057 #endif
11058  
11059 #if WIRELESS_EXT > 15
11060 if (ieee->iw_mode == IW_MODE_MONITOR) {
11061 - ieee80211_monitor_rx(ieee, skb, rx_stats);
11062 + ieee80211_monitor_rx_rtl7(ieee, skb, rx_stats);
11063 stats->rx_packets++;
11064 stats->rx_bytes += skb->len;
11065 return 1;
11066 @@ -529,7 +599,7 @@
11067 * stations that do not support WEP key mapping). */
11068  
11069 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
11070 - (void) hostap_handle_sta_crypto(local, hdr, &crypt,
11071 + (void) hostap_handle_sta_crypto_rtl7(local, hdr, &crypt,
11072 &sta);
11073 #endif
11074  
11075 @@ -555,7 +625,7 @@
11076 if (skb->len < IEEE80211_DATA_HDR3_LEN)
11077 goto rx_dropped;
11078  
11079 - if (is_duplicate_packet(ieee, hdr))
11080 + if (is_duplicate_packet_rtl7(ieee, hdr))
11081 goto rx_dropped;
11082  
11083  
11084 @@ -573,9 +643,9 @@
11085 goto rx_dropped;
11086 }
11087 #endif
11088 -
11089 -
11090 - if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
11091 +
11092 +
11093 + if (ieee80211_rx_frame_mgmt_rtl7(ieee, skb, rx_stats, type, stype))
11094 goto rx_dropped;
11095 else
11096 goto rx_exit;
11097 @@ -583,7 +653,7 @@
11098  
11099  
11100 /* Data frame - extract src/dst addresses */
11101 -
11102 +
11103 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
11104 case IEEE80211_FCTL_FROMDS:
11105 memcpy(dst, hdr->addr1, ETH_ALEN);
11106 @@ -606,7 +676,7 @@
11107 }
11108  
11109 #ifdef NOT_YET
11110 - if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
11111 + if (hostap_rx_frame_wds_rtl7(ieee, hdr, fc, &wds))
11112 goto rx_dropped;
11113 if (wds) {
11114 skb->dev = dev = wds;
11115 @@ -619,7 +689,7 @@
11116 memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
11117 /* Frame from BSSID of the AP for which we are a client */
11118 skb->dev = dev = ieee->stadev;
11119 - stats = hostap_get_stats(dev);
11120 + stats = hostap_get_stats_rtl7(dev);
11121 from_assoc_ap = 1;
11122 }
11123 #endif
11124 @@ -630,7 +700,7 @@
11125 if ((ieee->iw_mode == IW_MODE_MASTER ||
11126 ieee->iw_mode == IW_MODE_REPEAT) &&
11127 !from_assoc_ap) {
11128 - switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
11129 + switch (hostap_handle_sta_rx_rtl7(ieee, dev, skb, rx_stats,
11130 wds != NULL)) {
11131 case AP_RX_CONTINUE_NOT_AUTHORIZED:
11132 frame_authorized = 0;
11133 @@ -664,7 +734,7 @@
11134 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
11135  
11136 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
11137 - (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
11138 + (keyidx = ieee80211_rx_frame_decrypt_rtl7(ieee, skb, crypt)) < 0)
11139 goto rx_dropped;
11140  
11141 hdr = (struct ieee80211_hdr *) skb->data;
11142 @@ -674,7 +744,7 @@
11143 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
11144 if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
11145 int flen;
11146 - struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
11147 + struct sk_buff *frag_skb = ieee80211_frag_cache_get_rtl7(ieee, hdr);
11148 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
11149  
11150 if (!frag_skb) {
11151 @@ -694,7 +764,7 @@
11152 printk(KERN_WARNING "%s: host decrypted and "
11153 "reassembled frame did not fit skb\n",
11154 dev->name);
11155 - ieee80211_frag_cache_invalidate(ieee, hdr);
11156 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
11157 goto rx_dropped;
11158 }
11159  
11160 @@ -722,19 +792,19 @@
11161 * delivered, so remove skb from fragment cache */
11162 skb = frag_skb;
11163 hdr = (struct ieee80211_hdr *) skb->data;
11164 - ieee80211_frag_cache_invalidate(ieee, hdr);
11165 + ieee80211_frag_cache_invalidate_rtl7(ieee, hdr);
11166 }
11167  
11168 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
11169 * encrypted/authenticated */
11170 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
11171 - ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
11172 + ieee80211_rx_frame_decrypt_msdu_rtl7(ieee, skb, keyidx, crypt))
11173 goto rx_dropped;
11174  
11175 hdr = (struct ieee80211_hdr *) skb->data;
11176 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
11177 if (/*ieee->ieee802_1x &&*/
11178 - ieee80211_is_eapol_frame(ieee, skb)) {
11179 + ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
11180 #ifdef CONFIG_IEEE80211_DEBUG
11181 /* pass unencrypted EAPOL frames even if encryption is
11182 * configured */
11183 @@ -763,7 +833,7 @@
11184 #endif
11185  
11186 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
11187 - !ieee80211_is_eapol_frame(ieee, skb)) {
11188 + !ieee80211_is_eapol_frame_rtl7(ieee, skb)) {
11189 IEEE80211_DEBUG_DROP(
11190 "dropped unencrypted RX data "
11191 "frame from " MAC_FMT
11192 @@ -861,7 +931,12 @@
11193 if (skb2 != NULL) {
11194 /* send to wireless media */
11195 skb2->protocol = __constant_htons(ETH_P_802_3);
11196 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
11197 skb2->mac.raw = skb2->nh.raw = skb2->data;
11198 +#else
11199 + skb_reset_mac_header(skb2);
11200 + skb_reset_network_header(skb2);
11201 +#endif
11202 /* skb2->nh.raw = skb2->data + ETH_HLEN; */
11203 skb2->dev = dev;
11204 dev_queue_xmit(skb2);
11205 @@ -896,7 +971,7 @@
11206  
11207 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
11208  
11209 -static inline int ieee80211_is_ofdm_rate(u8 rate)
11210 +static inline int ieee80211_is_ofdm_rate_rtl7(u8 rate)
11211 {
11212 switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
11213 case IEEE80211_OFDM_RATE_6MB:
11214 @@ -913,7 +988,7 @@
11215 }
11216  
11217  
11218 -static inline int ieee80211_network_init(
11219 +static inline int ieee80211_network_init_rtl7(
11220 struct ieee80211_device *ieee,
11221 struct ieee80211_probe_response *beacon,
11222 struct ieee80211_network *network,
11223 @@ -964,7 +1039,7 @@
11224  
11225 switch (info_element->id) {
11226 case MFIE_TYPE_SSID:
11227 - if (ieee80211_is_empty_essid(info_element->data,
11228 + if (ieee80211_is_empty_essid_rtl7(info_element->data,
11229 info_element->len)) {
11230 network->flags |= NETWORK_EMPTY_ESSID;
11231 break;
11232 @@ -991,7 +1066,7 @@
11233 #ifdef CONFIG_IEEE80211_DEBUG
11234 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
11235 #endif
11236 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
11237 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
11238 network->flags |= NETWORK_HAS_OFDM;
11239 if (info_element->data[i] &
11240 IEEE80211_BASIC_RATE_MASK)
11241 @@ -1014,7 +1089,7 @@
11242 #ifdef CONFIG_IEEE80211_DEBUG
11243 p += snprintf(p, sizeof(rates_str) - (p - rates_str), "%02X ", network->rates[i]);
11244 #endif
11245 - if (ieee80211_is_ofdm_rate(info_element->data[i])) {
11246 + if (ieee80211_is_ofdm_rate_rtl7(info_element->data[i])) {
11247 network->flags |= NETWORK_HAS_OFDM;
11248 if (info_element->data[i] &
11249 IEEE80211_BASIC_RATE_MASK)
11250 @@ -1043,47 +1118,47 @@
11251 break;
11252  
11253 case MFIE_TYPE_TIM:
11254 -
11255 - if(info_element->len < 4)
11256 +
11257 + if(info_element->len < 4)
11258 break;
11259 -
11260 +
11261 network->dtim_period = info_element->data[1];
11262 -
11263 +
11264 if(ieee->state != IEEE80211_LINKED)
11265 break;
11266 -
11267 - network->last_dtim_sta_time[0] = stats->mac_time[0];
11268 +
11269 + network->last_dtim_sta_time[0] = stats->mac_time[0];
11270 network->last_dtim_sta_time[1] = stats->mac_time[1];
11271 -
11272 +
11273 network->dtim_data = IEEE80211_DTIM_VALID;
11274 -
11275 - if(info_element->data[0] != 0)
11276 +
11277 + if(info_element->data[0] != 0)
11278 break;
11279 -
11280 +
11281 if(info_element->data[2] & 1)
11282 network->dtim_data |= IEEE80211_DTIM_MBCAST;
11283 -
11284 +
11285 offset = (info_element->data[2] >> 1)*2;
11286 -
11287 - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
11288 -
11289 - if(ieee->assoc_id < offset ||
11290 +
11291 + //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
11292 +
11293 + if(ieee->assoc_id < offset ||
11294 ieee->assoc_id > 8*(offset + info_element->len -3))
11295 -
11296 +
11297 break;
11298 -
11299 -
11300 +
11301 +
11302 offset = offset + ieee->assoc_id / 8;// + ((aid % 8)? 0 : 1) ;
11303 -
11304 - // printk("offset:%x data:%x, ucast:%d\n", offset,
11305 +
11306 + // printk("offset:%x data:%x, ucast:%d\n", offset,
11307 // info_element->data[3+offset] ,
11308 // info_element->data[3+offset] & (1<<(ieee->assoc_id%8)));
11309 -
11310 +
11311 if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
11312 network->dtim_data |= IEEE80211_DTIM_UCAST;
11313 -
11314 +
11315 break;
11316 -
11317 +
11318 case MFIE_TYPE_IBSS_SET:
11319 IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n");
11320 break;
11321 @@ -1115,7 +1190,7 @@
11322 memcpy(network->rsn_ie, info_element,
11323 network->rsn_ie_len);
11324 break;
11325 -
11326 +
11327 default:
11328 IEEE80211_DEBUG_SCAN("unsupported IE %d\n",
11329 info_element->id);
11330 @@ -1147,7 +1222,7 @@
11331 return 1;
11332 }
11333  
11334 - if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
11335 + if (ieee80211_is_empty_essid_rtl7(network->ssid, network->ssid_len))
11336 network->flags |= NETWORK_EMPTY_ESSID;
11337  
11338 memcpy(&network->stats, stats, sizeof(network->stats));
11339 @@ -1155,24 +1230,24 @@
11340 return 0;
11341 }
11342  
11343 -static inline int is_same_network(struct ieee80211_network *src,
11344 +static inline int is_same_network_rtl7(struct ieee80211_network *src,
11345 struct ieee80211_network *dst)
11346 {
11347 /* A network is only a duplicate if the channel, BSSID, ESSID
11348 - * and the capability field (in particular IBSS and BSS) all match.
11349 + * and the capability field (in particular IBSS and BSS) all match.
11350 * We treat all <hidden> with the same BSSID and channel
11351 * as one network */
11352 return ((src->ssid_len == dst->ssid_len) &&
11353 (src->channel == dst->channel) &&
11354 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
11355 !memcmp(src->ssid, dst->ssid, src->ssid_len) &&
11356 - ((src->capability & WLAN_CAPABILITY_IBSS) ==
11357 + ((src->capability & WLAN_CAPABILITY_IBSS) ==
11358 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
11359 - ((src->capability & WLAN_CAPABILITY_BSS) ==
11360 + ((src->capability & WLAN_CAPABILITY_BSS) ==
11361 (dst->capability & WLAN_CAPABILITY_BSS)));
11362 }
11363  
11364 -static inline void update_network(struct ieee80211_network *dst,
11365 +static inline void update_network_rtl7(struct ieee80211_network *dst,
11366 struct ieee80211_network *src)
11367 {
11368 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
11369 @@ -1194,7 +1269,7 @@
11370 dst->dtim_data = src->dtim_data;
11371 dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
11372 dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
11373 -
11374 +
11375 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
11376 dst->wpa_ie_len = src->wpa_ie_len;
11377 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
11378 @@ -1204,7 +1279,7 @@
11379 /* dst->last_associate is not overwritten */
11380 }
11381  
11382 -static inline void ieee80211_process_probe_response(
11383 +static inline void ieee80211_process_probe_response_rtl7(
11384 struct ieee80211_device *ieee,
11385 struct ieee80211_probe_response *beacon,
11386 struct ieee80211_rx_stats *stats)
11387 @@ -1239,7 +1314,7 @@
11388 (beacon->capability & (1<<0x1)) ? '1' : '0',
11389 (beacon->capability & (1<<0x0)) ? '1' : '0');
11390  
11391 - if (ieee80211_network_init(ieee, beacon, &network, stats)) {
11392 + if (ieee80211_network_init_rtl7(ieee, beacon, &network, stats)) {
11393 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
11394 escape_essid(info_element->data,
11395 info_element->len),
11396 @@ -1261,12 +1336,12 @@
11397 * already there. */
11398  
11399 spin_lock_irqsave(&ieee->lock, flags);
11400 -
11401 - if(is_same_network(&ieee->current_network, &network))
11402 - update_network(&ieee->current_network, &network);
11403 -
11404 +
11405 + if(is_same_network_rtl7(&ieee->current_network, &network))
11406 + update_network_rtl7(&ieee->current_network, &network);
11407 +
11408 list_for_each_entry(target, &ieee->network_list, list) {
11409 - if (is_same_network(target, &network))
11410 + if (is_same_network_rtl7(target, &network))
11411 break;
11412  
11413 if ((oldest == NULL) ||
11414 @@ -1306,7 +1381,7 @@
11415 memcpy(target, &network, sizeof(*target));
11416 list_add_tail(&target->list, &ieee->network_list);
11417 if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
11418 - ieee80211_softmac_new_net(ieee,&network);
11419 + ieee80211_softmac_new_net_rtl7(ieee,&network);
11420 } else {
11421 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
11422 escape_essid(target->ssid,
11423 @@ -1315,39 +1390,39 @@
11424 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
11425 IEEE80211_STYPE_PROBE_RESP ?
11426 "PROBE RESPONSE" : "BEACON");
11427 -
11428 +
11429 /* we have an entry and we are going to update it. But this entry may
11430 - * be already expired. In this case we do the same as we found a new
11431 + * be already expired. In this case we do the same as we found a new
11432 * net and call the new_net handler
11433 */
11434 renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
11435 - update_network(target, &network);
11436 + update_network_rtl7(target, &network);
11437 if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
11438 - ieee80211_softmac_new_net(ieee,&network);
11439 + ieee80211_softmac_new_net_rtl7(ieee,&network);
11440 }
11441  
11442 spin_unlock_irqrestore(&ieee->lock, flags);
11443 }
11444  
11445 -void ieee80211_rx_mgt(struct ieee80211_device *ieee,
11446 +void ieee80211_rx_mgt_rtl7(struct ieee80211_device *ieee,
11447 struct ieee80211_hdr *header,
11448 struct ieee80211_rx_stats *stats)
11449 {
11450 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
11451 -
11452 +
11453 case IEEE80211_STYPE_BEACON:
11454 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
11455 WLAN_FC_GET_STYPE(header->frame_ctl));
11456 IEEE80211_DEBUG_SCAN("Beacon\n");
11457 - ieee80211_process_probe_response(
11458 + ieee80211_process_probe_response_rtl7(
11459 ieee, (struct ieee80211_probe_response *)header, stats);
11460 break;
11461 -
11462 +
11463 case IEEE80211_STYPE_PROBE_RESP:
11464 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
11465 WLAN_FC_GET_STYPE(header->frame_ctl));
11466 IEEE80211_DEBUG_SCAN("Probe response\n");
11467 - ieee80211_process_probe_response(
11468 + ieee80211_process_probe_response_rtl7(
11469 ieee, (struct ieee80211_probe_response *)header, stats);
11470 break;
11471  
11472 @@ -1355,5 +1430,5 @@
11473 }
11474  
11475  
11476 -EXPORT_SYMBOL(ieee80211_rx_mgt);
11477 -EXPORT_SYMBOL(ieee80211_rx);
11478 +EXPORT_SYMBOL(ieee80211_rx_mgt_rtl7);
11479 +EXPORT_SYMBOL(ieee80211_rx_rtl7);
11480 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c
11481 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac.c 2006-06-18 21:27:33.000000000 -0400
11482 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.c 2008-08-12 13:11:32.000000000 -0400
11483 @@ -1,14 +1,14 @@
11484 /* IEEE 802.11 SoftMAC layer
11485 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
11486 *
11487 - * Mostly extracted from the rtl8180-sa2400 driver for the
11488 + * Mostly extracted from the rtl8180-sa2400 driver for the
11489 * in-kernel generic ieee802.11 stack.
11490 *
11491 * Few lines might be stolen from other part of the ieee80211
11492 * stack. Copyright who own it's copyright
11493 *
11494 * WPA code stolen from the ipw2200 driver.
11495 - * Copyright who own it's copyright.
11496 + * Copyright who own it's copyright.
11497 *
11498 * released under the GPL
11499 */
11500 @@ -20,12 +20,12 @@
11501 #include <linux/delay.h>
11502 #include <linux/version.h>
11503  
11504 -short ieee80211_is_54g(struct ieee80211_network net)
11505 +short ieee80211_is_54g_rtl7(struct ieee80211_network net)
11506 {
11507 return ((net.rates_ex_len > 0) || (net.rates_len > 4));
11508 }
11509  
11510 -short ieee80211_is_shortslot(struct ieee80211_network net)
11511 +short ieee80211_is_shortslot_rtl7(struct ieee80211_network net)
11512 {
11513 return (net.capability & WLAN_CAPABILITY_SHORT_SLOT);
11514 }
11515 @@ -34,28 +34,28 @@
11516 * tag and the EXTENDED RATE MFIE tag if needed.
11517 * It encludes two bytes per tag for the tag itself and its len
11518 */
11519 -unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee)
11520 +unsigned int ieee80211_MFIE_rate_len_rtl7(struct ieee80211_device *ieee)
11521 {
11522 unsigned int rate_len = 0;
11523 -
11524 +
11525 if (ieee->modulation & IEEE80211_CCK_MODULATION)
11526 rate_len = IEEE80211_CCK_RATE_LEN + 2;
11527 -
11528 +
11529 if (ieee->modulation & IEEE80211_OFDM_MODULATION)
11530 -
11531 +
11532 rate_len += IEEE80211_OFDM_RATE_LEN + 2;
11533 -
11534 +
11535 return rate_len;
11536 }
11537  
11538 -/* pleace the MFIE rate, tag to the memory (double) poined.
11539 +/* pleace the MFIE rate, tag to the memory (double) poined.
11540 * Then it updates the pointer so that
11541 * it points after the new MFIE tag added.
11542 - */
11543 -void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p)
11544 + */
11545 +void ieee80211_MFIE_Brate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
11546 {
11547 - u8 *tag = *tag_p;
11548 -
11549 + u8 *tag = *tag_p;
11550 +
11551 if (ieee->modulation & IEEE80211_CCK_MODULATION){
11552 *tag++ = MFIE_TYPE_RATES;
11553 *tag++ = 4;
11554 @@ -64,17 +64,17 @@
11555 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
11556 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
11557 }
11558 -
11559 +
11560 /* We may add an option for custom rates that specific HW might support */
11561 *tag_p = tag;
11562 }
11563  
11564 -void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p)
11565 -{
11566 - u8 *tag = *tag_p;
11567 -
11568 +void ieee80211_MFIE_Grate_rtl7(struct ieee80211_device *ieee, u8 **tag_p)
11569 +{
11570 + u8 *tag = *tag_p;
11571 +
11572 if (ieee->modulation & IEEE80211_OFDM_MODULATION){
11573 -
11574 +
11575 *tag++ = MFIE_TYPE_RATES_EX;
11576 *tag++ = 8;
11577 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
11578 @@ -85,73 +85,73 @@
11579 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
11580 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
11581 *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
11582 -
11583 +
11584 }
11585 -
11586 +
11587 /* We may add an option for custom rates that specific HW might support */
11588 *tag_p = tag;
11589 }
11590  
11591 -void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb)
11592 +void enqueue_mgmt_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
11593 {
11594 int nh;
11595 nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM;
11596 -
11597 +
11598 /*
11599 * if the queue is full but we have newer frames then
11600 * just overwrites the oldest.
11601 - *
11602 + *
11603 * if (nh == ieee->mgmt_queue_tail)
11604 * return -1;
11605 - */
11606 + */
11607 ieee->mgmt_queue_head = nh;
11608 ieee->mgmt_queue_ring[nh] = skb;
11609 -
11610 +
11611 //return 0;
11612 }
11613  
11614 -struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee)
11615 +struct sk_buff *dequeue_mgmt_rtl7(struct ieee80211_device *ieee)
11616 {
11617 struct sk_buff *ret;
11618 -
11619 +
11620 if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head)
11621 return NULL;
11622 -
11623 +
11624 ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail];
11625 -
11626 - ieee->mgmt_queue_tail =
11627 +
11628 + ieee->mgmt_queue_tail =
11629 (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM;
11630 -
11631 +
11632 return ret;
11633 }
11634  
11635 -void init_mgmt_queue(struct ieee80211_device *ieee)
11636 +void init_mgmt_queue_rtl7(struct ieee80211_device *ieee)
11637 {
11638 ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0;
11639 }
11640  
11641  
11642 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl);
11643 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl);
11644  
11645 -inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
11646 +inline void softmac_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
11647 {
11648 unsigned long flags;
11649 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
11650 struct ieee80211_hdr_3addr *header=
11651 (struct ieee80211_hdr_3addr *) skb->data;
11652 -
11653 -
11654 +
11655 +
11656 spin_lock_irqsave(&ieee->lock, flags);
11657 -
11658 +
11659 /* called with 2nd param 0, no mgmt lock required */
11660 - ieee80211_sta_wakeup(ieee,0);
11661 -
11662 + ieee80211_sta_wakeup_rtl7(ieee,0);
11663 +
11664 if(single){
11665 -
11666 +
11667 if(ieee->queue_stop){
11668 -
11669 - enqueue_mgmt(ieee,skb);
11670 -
11671 +
11672 + enqueue_mgmt_rtl7(ieee,skb);
11673 +
11674 }else{
11675 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
11676  
11677 @@ -159,119 +159,119 @@
11678 ieee->seq_ctrl = 0;
11679 else
11680 ieee->seq_ctrl++;
11681 -
11682 +
11683 /* avoid watchdog triggers */
11684 ieee->dev->trans_start = jiffies;
11685 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
11686 }
11687 -
11688 +
11689 spin_unlock_irqrestore(&ieee->lock, flags);
11690 }else{
11691 spin_unlock_irqrestore(&ieee->lock, flags);
11692 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags);
11693 -
11694 +
11695 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
11696 -
11697 +
11698 if (ieee->seq_ctrl == 0xFFF)
11699 ieee->seq_ctrl = 0;
11700 else
11701 ieee->seq_ctrl++;
11702 -
11703 +
11704 ieee->softmac_hard_start_xmit(skb,ieee->dev);
11705 -
11706 +
11707 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags);
11708 }
11709 }
11710  
11711  
11712 -inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee)
11713 +inline void softmac_ps_mgmt_xmit_rtl7(struct sk_buff *skb, struct ieee80211_device *ieee)
11714 {
11715 -
11716 +
11717 short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
11718 struct ieee80211_hdr_3addr *header =
11719 (struct ieee80211_hdr_3addr *) skb->data;
11720 -
11721 -
11722 +
11723 +
11724 if(single){
11725 -
11726 +
11727 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
11728  
11729 if (ieee->seq_ctrl == 0xFFF)
11730 ieee->seq_ctrl = 0;
11731 else
11732 ieee->seq_ctrl++;
11733 -
11734 +
11735 /* avoid watchdog triggers */
11736 ieee->dev->trans_start = jiffies;
11737 ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate);
11738 -
11739 +
11740 }else{
11741 -
11742 +
11743 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
11744 -
11745 +
11746 if (ieee->seq_ctrl == 0xFFF)
11747 ieee->seq_ctrl = 0;
11748 else
11749 ieee->seq_ctrl++;
11750  
11751 ieee->softmac_hard_start_xmit(skb,ieee->dev);
11752 -
11753 +
11754 }
11755 }
11756  
11757 -inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee)
11758 +inline struct sk_buff *ieee80211_probe_req_rtl7(struct ieee80211_device *ieee)
11759 {
11760 unsigned int len,rate_len;
11761 u8 *tag;
11762 struct sk_buff *skb;
11763 struct ieee80211_probe_request *req;
11764 -
11765 +
11766 len = ieee->current_network.ssid_len;
11767 -
11768 - rate_len = ieee80211_MFIE_rate_len(ieee);
11769 -
11770 +
11771 + rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
11772 +
11773 skb = dev_alloc_skb(sizeof(struct ieee80211_probe_request) +
11774 2 + len + rate_len);
11775 -
11776 - if (!skb)
11777 +
11778 + if (!skb)
11779 return NULL;
11780 -
11781 +
11782 req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request));
11783 req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
11784 - req->header.duration_id = 0; //FIXME: is this OK ?
11785 -
11786 + req->header.duration_id = 0; //FIXME: is this OK ?
11787 +
11788 memset(req->header.addr1, 0xff, ETH_ALEN);
11789 memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
11790 memset(req->header.addr3, 0xff, ETH_ALEN);
11791 -
11792 +
11793 tag = (u8 *) skb_put(skb,len+2+rate_len);
11794 -
11795 +
11796 *tag++ = MFIE_TYPE_SSID;
11797 *tag++ = len;
11798 memcpy(tag, ieee->current_network.ssid, len);
11799 tag += len;
11800 -
11801 - ieee80211_MFIE_Brate(ieee,&tag);
11802 - ieee80211_MFIE_Grate(ieee,&tag);
11803 +
11804 + ieee80211_MFIE_Brate_rtl7(ieee,&tag);
11805 + ieee80211_MFIE_Grate_rtl7(ieee,&tag);
11806 return skb;
11807 }
11808  
11809 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee);
11810 -void ieee80211_send_beacon(struct ieee80211_device *ieee)
11811 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee);
11812 +void ieee80211_send_beacon_rtl7(struct ieee80211_device *ieee)
11813 {
11814 struct sk_buff *skb;
11815 -
11816 - unsigned long flags;
11817 -
11818 - skb = ieee80211_get_beacon_(ieee);
11819 +
11820 + unsigned long flags;
11821 +
11822 + skb = ieee80211_get_beacon__rtl7(ieee);
11823 if (skb){
11824 - softmac_mgmt_xmit(skb, ieee);
11825 + softmac_mgmt_xmit_rtl7(skb, ieee);
11826 ieee->softmac_stats.tx_beacons++;
11827 }
11828  
11829 - ieee->beacon_timer.expires = jiffies +
11830 + ieee->beacon_timer.expires = jiffies +
11831 (MSECS( ieee->current_network.beacon_interval -5));
11832 -
11833 +
11834 spin_lock_irqsave(&ieee->beacon_lock,flags);
11835 if(ieee->beacon_txing)
11836 add_timer(&ieee->beacon_timer);
11837 @@ -279,57 +279,57 @@
11838 }
11839  
11840  
11841 -void ieee80211_send_beacon_cb(unsigned long _ieee)
11842 +void ieee80211_send_beacon_cb_rtl7(unsigned long _ieee)
11843 {
11844 struct ieee80211_device *ieee =
11845 (struct ieee80211_device *) _ieee;
11846 - ieee80211_send_beacon(ieee);
11847 + ieee80211_send_beacon_rtl7(ieee);
11848 }
11849  
11850  
11851 -void ieee80211_send_probe(struct ieee80211_device *ieee)
11852 +void ieee80211_send_probe_rtl7(struct ieee80211_device *ieee)
11853 {
11854 struct sk_buff *skb;
11855 -
11856 - skb = ieee80211_probe_req(ieee);
11857 +
11858 + skb = ieee80211_probe_req_rtl7(ieee);
11859 if (skb){
11860 - softmac_mgmt_xmit(skb, ieee);
11861 + softmac_mgmt_xmit_rtl7(skb, ieee);
11862 ieee->softmac_stats.tx_probe_rq++;
11863 }
11864 }
11865  
11866 -void ieee80211_send_probe_requests(struct ieee80211_device *ieee)
11867 +void ieee80211_send_probe_requests_rtl7(struct ieee80211_device *ieee)
11868 {
11869 if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){
11870 - ieee80211_send_probe(ieee);
11871 - ieee80211_send_probe(ieee);
11872 + ieee80211_send_probe_rtl7(ieee);
11873 + ieee80211_send_probe_rtl7(ieee);
11874 }
11875 }
11876  
11877 /* this performs syncro scan blocking the caller until all channels
11878 - * in the allowed channel map has been checked.
11879 + * in the allowed channel map has been checked.
11880 */
11881 -void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee)
11882 +void ieee80211_softmac_scan_syncro_rtl7(struct ieee80211_device *ieee)
11883 {
11884 short ch = 0;
11885 -
11886 +
11887 down(&ieee->scan_sem);
11888 -
11889 +
11890 while(1)
11891 {
11892 -
11893 +
11894 do{
11895 ch++;
11896 - if (ch > MAX_CHANNEL_NUMBER)
11897 + if (ch > MAX_CHANNEL_NUMBER)
11898 goto out; /* scan completed */
11899 -
11900 +
11901 }while(!ieee->channel_map[ch]);
11902 -
11903 +
11904 /* this fuction can be called in two situations
11905 * 1- We have switched to ad-hoc mode and we are
11906 * performing a complete syncro scan before conclude
11907 - * there are no interesting cell and to create a
11908 - * new one. In this case the link state is
11909 + * there are no interesting cell and to create a
11910 + * new one. In this case the link state is
11911 * IEEE80211_NOLINK until we found an interesting cell.
11912 * If so the ieee8021_new_net, called by the RX path
11913 * will set the state to IEEE80211_LINKED, so we stop
11914 @@ -342,24 +342,24 @@
11915 * not filter RX frames and the channel is changing.
11916 * So the only situation in witch are interested is to check
11917 * if the state become LINKED because of the #1 situation
11918 - */
11919 -
11920 + */
11921 +
11922 if (ieee->state == IEEE80211_LINKED)
11923 goto out;
11924 -
11925 +
11926 ieee->set_chan(ieee->dev, ch);
11927 -
11928 - ieee80211_send_probe_requests(ieee);
11929 -
11930 +
11931 + ieee80211_send_probe_requests_rtl7(ieee);
11932 +
11933 /* this prevent excessive time wait when we
11934 * need to wait for a syncro scan to end..
11935 - */
11936 + */
11937 if (ieee->sync_scan_hurryup)
11938 goto out;
11939  
11940  
11941 msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME);
11942 -
11943 +
11944 }
11945 out:
11946 ieee->sync_scan_hurryup = 0;
11947 @@ -370,43 +370,49 @@
11948 void ieee80211_softmac_scan(struct ieee80211_device *ieee)
11949 {
11950 short watchdog = 0;
11951 -
11952 +
11953 do{
11954 - ieee->current_network.channel =
11955 + ieee->current_network.channel =
11956 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
11957 - if (watchdog++ > MAX_CHANNEL_NUMBER)
11958 + if (watchdog++ > MAX_CHANNEL_NUMBER)
11959 return; /* no good chans */
11960 -
11961 +
11962 }while(!ieee->channel_map[ieee->current_network.channel]);
11963 -
11964 +
11965  
11966 schedule_work(&ieee->softmac_scan_wq);
11967 }
11968 #endif
11969  
11970 -void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
11971 -{
11972 - down(&ieee->scan_sem);
11973 -
11974 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
11975 +void ieee80211_softmac_scan_wq_rtl7(struct work_struct *work)
11976 +{
11977 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
11978 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
11979 +#else
11980 +void ieee80211_softmac_scan_wq_rtl7(struct ieee80211_device *ieee)
11981 +{
11982 +#endif
11983 short watchdog = 0;
11984 -
11985 + down(&ieee->scan_sem);
11986 +
11987 do{
11988 - ieee->current_network.channel =
11989 + ieee->current_network.channel =
11990 (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER;
11991 - if (watchdog++ > MAX_CHANNEL_NUMBER)
11992 + if (watchdog++ > MAX_CHANNEL_NUMBER)
11993 goto out; /* no good chans */
11994 -
11995 +
11996 }while(!ieee->channel_map[ieee->current_network.channel]);
11997 -
11998 +
11999 if (ieee->scanning == 0 )
12000 goto out;
12001 -
12002 +
12003 ieee->set_chan(ieee->dev, ieee->current_network.channel);
12004 - ieee80211_send_probe_requests(ieee);
12005 + ieee80211_send_probe_requests_rtl7(ieee);
12006  
12007 -#if 0
12008 +#if 0
12009 ieee->.expires = jiffies + (IEEE80211_SOFTMAC_SCAN_TIME);
12010 - if (ieee->scanning == 1)
12011 + if (ieee->scanning == 1)
12012 add_timer(&ieee->scan_timer);
12013 #endif
12014 queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME);
12015 @@ -419,7 +425,7 @@
12016 {
12017 unsigned long flags;
12018 struct ieee80211_device *ieee = (struct ieee80211_device *)_dev;
12019 -
12020 +
12021 spin_lock_irqsave(&ieee->lock, flags);
12022 ieee80211_softmac_scan(ieee);
12023 spin_unlock_irqrestore(&ieee->lock, flags);
12024 @@ -427,19 +433,19 @@
12025 #endif
12026  
12027  
12028 -void ieee80211_beacons_start(struct ieee80211_device *ieee)
12029 +void ieee80211_beacons_start_rtl7(struct ieee80211_device *ieee)
12030 {
12031 - unsigned long flags;
12032 + unsigned long flags;
12033  
12034 spin_lock_irqsave(&ieee->beacon_lock,flags);
12035  
12036 ieee->beacon_txing = 1;
12037 - ieee80211_send_beacon(ieee);
12038 -
12039 + ieee80211_send_beacon_rtl7(ieee);
12040 +
12041 spin_unlock_irqrestore(&ieee->beacon_lock,flags);
12042 }
12043  
12044 -void ieee80211_beacons_stop(struct ieee80211_device *ieee)
12045 +void ieee80211_beacons_stop_rtl7(struct ieee80211_device *ieee)
12046 {
12047 unsigned long flags;
12048  
12049 @@ -453,111 +459,111 @@
12050 }
12051  
12052  
12053 -void ieee80211_stop_send_beacons(struct ieee80211_device *ieee)
12054 +void ieee80211_stop_send_beacons_rtl7(struct ieee80211_device *ieee)
12055 {
12056 if(ieee->stop_send_beacons)
12057 ieee->stop_send_beacons(ieee->dev);
12058 if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
12059 - ieee80211_beacons_stop(ieee);
12060 + ieee80211_beacons_stop_rtl7(ieee);
12061 }
12062  
12063  
12064 -void ieee80211_start_send_beacons(struct ieee80211_device *ieee)
12065 +void ieee80211_start_send_beacons_rtl7(struct ieee80211_device *ieee)
12066 {
12067 if(ieee->start_send_beacons)
12068 ieee->start_send_beacons(ieee->dev);
12069 if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS)
12070 - ieee80211_beacons_start(ieee);
12071 + ieee80211_beacons_start_rtl7(ieee);
12072 }
12073  
12074  
12075 -void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee)
12076 +void ieee80211_softmac_stop_scan_rtl7(struct ieee80211_device *ieee)
12077 {
12078 -// unsigned long flags;
12079 -
12080 +// unsigned long flags;
12081 +
12082 //ieee->sync_scan_hurryup = 1;
12083 -
12084 +
12085 down(&ieee->scan_sem);
12086 // spin_lock_irqsave(&ieee->lock, flags);
12087 -
12088 +
12089 if (ieee->scanning == 1){
12090 ieee->scanning = 0;
12091 //del_timer_sync(&ieee->scan_timer);
12092 cancel_delayed_work(&ieee->softmac_scan_wq);
12093 }
12094 -
12095 +
12096 // spin_unlock_irqrestore(&ieee->lock, flags);
12097 up(&ieee->scan_sem);
12098 }
12099  
12100 -void ieee80211_stop_scan(struct ieee80211_device *ieee)
12101 +void ieee80211_stop_scan_rtl7(struct ieee80211_device *ieee)
12102 {
12103 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
12104 - ieee80211_softmac_stop_scan(ieee);
12105 + ieee80211_softmac_stop_scan_rtl7(ieee);
12106 else
12107 ieee->stop_scan(ieee->dev);
12108 }
12109  
12110 /* called with ieee->lock held */
12111 -void ieee80211_start_scan(struct ieee80211_device *ieee)
12112 +void ieee80211_start_scan_rtl7(struct ieee80211_device *ieee)
12113 {
12114 - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
12115 + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){
12116 if (ieee->scanning == 0){
12117 ieee->scanning = 1;
12118 //ieee80211_softmac_scan(ieee);
12119 - queue_work(ieee->wq, &ieee->softmac_scan_wq);
12120 + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0);
12121 }
12122 }else
12123 ieee->start_scan(ieee->dev);
12124 -
12125 +
12126 }
12127  
12128 /* called with wx_sem held */
12129 -void ieee80211_start_scan_syncro(struct ieee80211_device *ieee)
12130 +void ieee80211_start_scan_syncro_rtl7(struct ieee80211_device *ieee)
12131 {
12132 ieee->sync_scan_hurryup = 0;
12133 -
12134 +
12135 if (ieee->softmac_features & IEEE_SOFTMAC_SCAN)
12136 - ieee80211_softmac_scan_syncro(ieee);
12137 + ieee80211_softmac_scan_syncro_rtl7(ieee);
12138 else
12139 ieee->scan_syncro(ieee->dev);
12140 -
12141 +
12142 }
12143  
12144 -inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *beacon,
12145 +inline struct sk_buff *ieee80211_authentication_req_rtl7(struct ieee80211_network *beacon,
12146 struct ieee80211_device *ieee, int challengelen)
12147 {
12148 - struct sk_buff *skb;
12149 + struct sk_buff *skb;
12150 struct ieee80211_authentication *auth;
12151 -
12152 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
12153 -
12154 +
12155 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen);
12156 +
12157 if (!skb) return NULL;
12158 -
12159 +
12160 auth = (struct ieee80211_authentication *)
12161 skb_put(skb, sizeof(struct ieee80211_authentication));
12162 -
12163 +
12164 auth->header.frame_ctl = IEEE80211_STYPE_AUTH;
12165 if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP;
12166 -
12167 +
12168 auth->header.duration_id = 0x013a; //FIXME
12169 -
12170 +
12171 memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
12172 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
12173 memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
12174 -
12175 +
12176 auth->algorithm = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
12177 -
12178 +
12179 auth->transaction = cpu_to_le16(ieee->associate_seq);
12180 ieee->associate_seq++;
12181 -
12182 +
12183 auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS);
12184 -
12185 +
12186 return skb;
12187 -
12188 +
12189 }
12190  
12191 -static struct sk_buff* ieee80211_probe_resp(struct ieee80211_device *ieee, u8 *dest)
12192 +static struct sk_buff* ieee80211_probe_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
12193 {
12194 u8 *tag;
12195 int beacon_size;
12196 @@ -566,23 +572,23 @@
12197 int encrypt;
12198 int atim_len,erp_len;
12199 struct ieee80211_crypt_data* crypt;
12200 -
12201 +
12202 char *ssid = ieee->current_network.ssid;
12203 int ssid_len = ieee->current_network.ssid_len;
12204 int rate_len = ieee->current_network.rates_len+2;
12205 int rate_ex_len = ieee->current_network.rates_ex_len;
12206 if(rate_ex_len > 0) rate_ex_len+=2;
12207 -
12208 +
12209 if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS)
12210 atim_len = 4;
12211 else
12212 atim_len = 0;
12213 -
12214 - if(ieee80211_is_54g(ieee->current_network))
12215 +
12216 + if(ieee80211_is_54g_rtl7(ieee->current_network))
12217 erp_len = 3;
12218 else
12219 erp_len = 0;
12220 -
12221 +
12222 beacon_size = sizeof(struct ieee80211_probe_response)+
12223 ssid_len
12224 +3 //channel
12225 @@ -590,72 +596,72 @@
12226 +rate_ex_len
12227 +atim_len
12228 +erp_len;
12229 -
12230 +
12231 skb = dev_alloc_skb(beacon_size);
12232 -
12233 - if (!skb)
12234 +
12235 + if (!skb)
12236 return NULL;
12237 -
12238 +
12239 beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size);
12240 -
12241 +
12242 memcpy (beacon_buf->header.addr1, dest,ETH_ALEN);
12243 memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
12244 memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
12245  
12246 beacon_buf->header.duration_id = 0; //FIXME
12247 - beacon_buf->beacon_interval =
12248 + beacon_buf->beacon_interval =
12249 cpu_to_le16(ieee->current_network.beacon_interval);
12250 - beacon_buf->capability =
12251 + beacon_buf->capability =
12252 cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS);
12253 -
12254 +
12255 if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT))
12256 - cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
12257 -
12258 + cpu_to_le16((beacon_buf->capability |= WLAN_CAPABILITY_SHORT_SLOT));
12259 +
12260 crypt = ieee->crypt[ieee->tx_keyidx];
12261  
12262 - encrypt = ieee->host_encrypt && crypt && crypt->ops &&
12263 + encrypt = ieee->host_encrypt && crypt && crypt->ops &&
12264 (0 == strcmp(crypt->ops->name, "WEP"));
12265  
12266 - if (encrypt)
12267 + if (encrypt)
12268 beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
12269 -
12270 -
12271 +
12272 +
12273 beacon_buf->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_RESP);
12274 -
12275 - beacon_buf->info_element.id = MFIE_TYPE_SSID;
12276 +
12277 + beacon_buf->info_element.id = MFIE_TYPE_SSID;
12278 beacon_buf->info_element.len = ssid_len;
12279 -
12280 +
12281 tag = (u8*) beacon_buf->info_element.data;
12282 -
12283 +
12284 memcpy(tag, ssid, ssid_len);
12285 -
12286 +
12287 tag += ssid_len;
12288 -
12289 +
12290 *(tag++) = MFIE_TYPE_RATES;
12291 - *(tag++) = rate_len-2;
12292 + *(tag++) = rate_len-2;
12293 memcpy(tag,ieee->current_network.rates,rate_len-2);
12294 tag+=rate_len-2;
12295 -
12296 +
12297 *(tag++) = MFIE_TYPE_DS_SET;
12298 *(tag++) = 1;
12299 *(tag++) = ieee->current_network.channel;
12300 -
12301 +
12302 if(atim_len){
12303 *(tag++) = MFIE_TYPE_IBSS_SET;
12304 *(tag++) = 2;
12305 *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window);
12306 tag+=2;
12307 }
12308 -
12309 +
12310 if(erp_len){
12311 *(tag++) = MFIE_TYPE_ERP;
12312 *(tag++) = 1;
12313 - *(tag++) = 0;
12314 + *(tag++) = 0;
12315 }
12316 -
12317 +
12318 if(rate_ex_len){
12319 *(tag++) = MFIE_TYPE_RATES_EX;
12320 - *(tag++) = rate_ex_len-2;
12321 + *(tag++) = rate_ex_len-2;
12322 memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2);
12323 tag+=rate_ex_len-2;
12324 }
12325 @@ -664,208 +670,211 @@
12326 }
12327  
12328  
12329 -struct sk_buff* ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest)
12330 +struct sk_buff* ieee80211_assoc_resp_rtl7(struct ieee80211_device *ieee, u8 *dest)
12331 {
12332 struct sk_buff *skb;
12333 u8* tag;
12334 -
12335 +
12336 struct ieee80211_crypt_data* crypt;
12337 struct ieee80211_assoc_response_frame *assoc;
12338 short encrypt;
12339 -
12340 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
12341 +
12342 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
12343 int len = sizeof(struct ieee80211_assoc_response_frame) + rate_len;
12344 -
12345 - skb = dev_alloc_skb(len);
12346 -
12347 - if (!skb)
12348 +
12349 + skb = dev_alloc_skb(len);
12350 +
12351 + if (!skb)
12352 return NULL;
12353 -
12354 +
12355 assoc = (struct ieee80211_assoc_response_frame *)
12356 skb_put(skb,sizeof(struct ieee80211_assoc_response_frame));
12357 -
12358 +
12359 assoc->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP);
12360 memcpy(assoc->header.addr1, dest,ETH_ALEN);
12361 memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
12362 memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
12363 - assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
12364 + assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
12365 WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS);
12366 -
12367 -
12368 +
12369 +
12370 if(ieee->short_slot)
12371 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
12372 -
12373 +
12374 if (ieee->host_encrypt)
12375 crypt = ieee->crypt[ieee->tx_keyidx];
12376 else crypt = NULL;
12377 -
12378 +
12379 encrypt = ( crypt && crypt->ops);
12380 -
12381 +
12382 if (encrypt)
12383 assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
12384 -
12385 +
12386 assoc->status = 0;
12387 assoc->aid = cpu_to_le16(ieee->assoc_id);
12388 if (ieee->assoc_id == 0x2007) ieee->assoc_id=0;
12389 else ieee->assoc_id++;
12390 -
12391 +
12392 tag = (u8*) skb_put(skb, rate_len);
12393 -
12394 - ieee80211_MFIE_Brate(ieee, &tag);
12395 - ieee80211_MFIE_Grate(ieee, &tag);
12396 -
12397 +
12398 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
12399 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
12400 +
12401 return skb;
12402 }
12403  
12404 -struct sk_buff* ieee80211_auth_resp(struct ieee80211_device *ieee,int status, u8 *dest)
12405 +struct sk_buff* ieee80211_auth_resp_rtl7(struct ieee80211_device *ieee,int status, u8 *dest)
12406 {
12407 struct sk_buff *skb;
12408 struct ieee80211_authentication *auth;
12409 -
12410 - skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
12411 -
12412 - if (!skb)
12413 +
12414 + skb = dev_alloc_skb(sizeof(struct ieee80211_authentication)+1);
12415 +
12416 + if (!skb)
12417 return NULL;
12418 -
12419 +
12420 skb->len = sizeof(struct ieee80211_authentication);
12421 -
12422 +
12423 auth = (struct ieee80211_authentication *)skb->data;
12424 -
12425 +
12426 auth->status = cpu_to_le16(status);
12427 auth->transaction = cpu_to_le16(2);
12428 auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
12429 -
12430 +
12431 memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
12432 memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
12433 memcpy(auth->header.addr1, dest, ETH_ALEN);
12434 - auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
12435 + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH);
12436 return skb;
12437 -
12438 -
12439 +
12440 +
12441 }
12442  
12443 -struct sk_buff* ieee80211_null_func(struct ieee80211_device *ieee,short pwr)
12444 +struct sk_buff* ieee80211_null_func_rtl7(struct ieee80211_device *ieee,short pwr)
12445 {
12446 struct sk_buff *skb;
12447 struct ieee80211_hdr_3addr* hdr;
12448 -
12449 - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
12450 -
12451 - if (!skb)
12452 +
12453 + skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
12454 +
12455 + if (!skb)
12456 return NULL;
12457 -
12458 +
12459 hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
12460 -
12461 +
12462 memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
12463 memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
12464 memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
12465 -
12466 - hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
12467 - IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
12468 - (pwr ? IEEE80211_FCTL_PM:0));
12469 -
12470 +
12471 + hdr->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
12472 + IEEE80211_STYPE_NULLFUNC | IEEE80211_FCTL_TODS |
12473 + (pwr ? IEEE80211_FCTL_PM:0));
12474 +
12475 return skb;
12476 -
12477 -
12478 +
12479 +
12480 }
12481  
12482  
12483 -void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8* dest)
12484 +void ieee80211_resp_to_assoc_rq_rtl7(struct ieee80211_device *ieee, u8* dest)
12485 {
12486 - struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest);
12487 -
12488 + struct sk_buff *buf = ieee80211_assoc_resp_rtl7(ieee, dest);
12489 +
12490 if (buf)
12491 - softmac_mgmt_xmit(buf, ieee);
12492 + softmac_mgmt_xmit_rtl7(buf, ieee);
12493 }
12494  
12495  
12496 -void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8* dest)
12497 +void ieee80211_resp_to_auth_rtl7(struct ieee80211_device *ieee, int s, u8* dest)
12498 {
12499 - struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest);
12500 -
12501 + struct sk_buff *buf = ieee80211_auth_resp_rtl7(ieee, s, dest);
12502 +
12503 if (buf)
12504 - softmac_mgmt_xmit(buf, ieee);
12505 + softmac_mgmt_xmit_rtl7(buf, ieee);
12506 }
12507  
12508  
12509 -void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest)
12510 +void ieee80211_resp_to_probe_rtl7(struct ieee80211_device *ieee, u8 *dest)
12511 {
12512 -
12513 - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest);
12514 -
12515 - if (buf)
12516 - softmac_mgmt_xmit(buf, ieee);
12517 +
12518 + struct sk_buff *buf = ieee80211_probe_resp_rtl7(ieee, dest);
12519 +
12520 + if (buf)
12521 + softmac_mgmt_xmit_rtl7(buf, ieee);
12522 }
12523  
12524  
12525 -inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
12526 +inline struct sk_buff *ieee80211_association_req_rtl7(struct ieee80211_network *beacon,struct ieee80211_device *ieee)
12527 {
12528 struct sk_buff *skb;
12529 -
12530 +
12531 struct ieee80211_assoc_request_frame *hdr;
12532 u8 *tag;
12533 -
12534 +
12535 unsigned int wpa_len = beacon->wpa_ie_len;
12536 -
12537 - unsigned int rate_len = ieee80211_MFIE_rate_len(ieee);
12538 -
12539 -
12540 -
12541 +
12542 + unsigned int rate_len = ieee80211_MFIE_rate_len_rtl7(ieee);
12543 +
12544 +
12545 +
12546 int len=sizeof(struct ieee80211_assoc_request_frame)+
12547 + beacon->ssid_len//essid tagged val
12548 + rate_len//rates tagged val
12549 + wpa_len;
12550 -
12551 +
12552 skb = dev_alloc_skb(len);
12553 -
12554 - if (!skb)
12555 +
12556 + if (!skb)
12557 return NULL;
12558 -
12559 +
12560 hdr = (struct ieee80211_assoc_request_frame *)
12561 skb_put(skb, sizeof(struct ieee80211_assoc_request_frame));
12562 -
12563 -
12564 +
12565 +
12566 hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ;
12567 hdr->header.duration_id= 37; //FIXME
12568 memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
12569 memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
12570 memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
12571 -
12572 +
12573 hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS);
12574 - if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
12575 + if (beacon->capability & WLAN_CAPABILITY_PRIVACY )
12576 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
12577 -
12578 +
12579 if(ieee->short_slot)
12580 hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT);
12581 -
12582 +
12583 + if(beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)
12584 + hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);
12585 +
12586 hdr->listen_interval = 0xa; //FIXME
12587 -
12588 +
12589 hdr->info_element.id = MFIE_TYPE_SSID;
12590  
12591 hdr->info_element.len = beacon->ssid_len;
12592 tag = skb_put(skb, beacon->ssid_len);
12593 memcpy(tag, beacon->ssid, beacon->ssid_len);
12594 -
12595 - tag = skb_put(skb, rate_len);
12596 -
12597 - ieee80211_MFIE_Brate(ieee, &tag);
12598 - ieee80211_MFIE_Grate(ieee, &tag);
12599 -
12600 +
12601 + tag = skb_put(skb, rate_len);
12602 +
12603 + ieee80211_MFIE_Brate_rtl7(ieee, &tag);
12604 + ieee80211_MFIE_Grate_rtl7(ieee, &tag);
12605 +
12606 tag = skb_put(skb,wpa_len);
12607 -
12608 +
12609 memcpy(tag,beacon->wpa_ie,wpa_len);
12610 -
12611 +
12612 return skb;
12613 }
12614  
12615 -void ieee80211_associate_abort(struct ieee80211_device *ieee)
12616 +void ieee80211_associate_abort_rtl7(struct ieee80211_device *ieee)
12617 {
12618 -
12619 +
12620 unsigned long flags;
12621 spin_lock_irqsave(&ieee->lock, flags);
12622 -
12623 +
12624 ieee->associate_seq++;
12625 -
12626 +
12627 /* don't scan, and avoid to have the RX path possibily
12628 * try again to associate. Even do not react to AUTH or
12629 * ASSOC response. Just wait for the retry wq to be scheduled.
12630 @@ -873,166 +882,181 @@
12631 * with, so we retry or just get back to NO_LINK and scanning
12632 */
12633 if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){
12634 - IEEE80211_DEBUG_MGMT("Authentication failed\n");
12635 + IEEE80211_DEBUG_MGMT("Authentication failed\n");
12636 ieee->softmac_stats.no_auth_rs++;
12637 }else{
12638 - IEEE80211_DEBUG_MGMT("Association failed\n");
12639 + IEEE80211_DEBUG_MGMT("Association failed\n");
12640 ieee->softmac_stats.no_ass_rs++;
12641 }
12642 -
12643 +
12644 ieee->state = IEEE80211_ASSOCIATING_RETRY;
12645 -
12646 +
12647 queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME);
12648 -
12649 +
12650 spin_unlock_irqrestore(&ieee->lock, flags);
12651 }
12652  
12653 -void ieee80211_associate_abort_cb(unsigned long dev)
12654 +void ieee80211_associate_abort_cb_rtl7(unsigned long dev)
12655 {
12656 - ieee80211_associate_abort((struct ieee80211_device *) dev);
12657 + ieee80211_associate_abort_rtl7((struct ieee80211_device *) dev);
12658 }
12659  
12660  
12661 -void ieee80211_associate_step1(struct ieee80211_device *ieee)
12662 +void ieee80211_associate_step1_rtl7(struct ieee80211_device *ieee)
12663 {
12664 struct ieee80211_network *beacon = &ieee->current_network;
12665 struct sk_buff *skb;
12666 -
12667 +
12668 IEEE80211_DEBUG_MGMT("Stopping scan\n");
12669 -
12670 +
12671 ieee->softmac_stats.tx_auth_rq++;
12672 - skb=ieee80211_authentication_req(beacon, ieee, 0);
12673 -
12674 - if (!skb)
12675 - ieee80211_associate_abort(ieee);
12676 - else{
12677 + skb=ieee80211_authentication_req_rtl7(beacon, ieee, 0);
12678 +
12679 + if (!skb)
12680 + ieee80211_associate_abort_rtl7(ieee);
12681 + else{
12682 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ;
12683 IEEE80211_DEBUG_MGMT("Sending authentication request\n");
12684 - softmac_mgmt_xmit(skb, ieee);
12685 + softmac_mgmt_xmit_rtl7(skb, ieee);
12686 ieee->associate_timer.expires = jiffies + (HZ / 2);
12687 add_timer(&ieee->associate_timer);
12688 - }
12689 + }
12690 }
12691  
12692 -void ieee80211_auth_challenge(struct ieee80211_device *ieee, u8 *challenge, int chlen)
12693 +void ieee80211_auth_challenge_rtl7(struct ieee80211_device *ieee, u8 *challenge, int chlen)
12694 {
12695 - u8 *c;
12696 + u8 *c;
12697 struct sk_buff *skb;
12698 struct ieee80211_network *beacon = &ieee->current_network;
12699 // int hlen = sizeof(struct ieee80211_authentication);
12700 -
12701 +
12702 ieee->associate_seq++;
12703 ieee->softmac_stats.tx_auth_rq++;
12704 -
12705 - skb = ieee80211_authentication_req(beacon, ieee, chlen+2);
12706 - if (!skb)
12707 - ieee80211_associate_abort(ieee);
12708 +
12709 + skb = ieee80211_authentication_req_rtl7(beacon, ieee, chlen+2);
12710 + if (!skb)
12711 + ieee80211_associate_abort_rtl7(ieee);
12712 else{
12713 c = skb_put(skb, chlen+2);
12714 *(c++) = MFIE_TYPE_CHALLENGE;
12715 *(c++) = chlen;
12716 memcpy(c, challenge, chlen);
12717 -
12718 +
12719 IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
12720 -
12721 - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
12722 -
12723 - softmac_mgmt_xmit(skb, ieee);
12724 +
12725 + ieee80211_encrypt_fragment_rtl7(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
12726 +
12727 + softmac_mgmt_xmit_rtl7(skb, ieee);
12728 ieee->associate_timer.expires = jiffies + (HZ / 2);
12729 add_timer(&ieee->associate_timer);
12730 - }
12731 + }
12732 kfree(challenge);
12733 }
12734  
12735 -void ieee80211_associate_step2(struct ieee80211_device *ieee)
12736 +void ieee80211_associate_step2_rtl7(struct ieee80211_device *ieee)
12737 {
12738 struct sk_buff* skb;
12739 struct ieee80211_network *beacon = &ieee->current_network;
12740 -
12741 +
12742 del_timer_sync(&ieee->associate_timer);
12743 -
12744 +
12745 IEEE80211_DEBUG_MGMT("Sending association request\n");
12746 -
12747 +
12748 ieee->softmac_stats.tx_ass_rq++;
12749 - skb=ieee80211_association_req(beacon, ieee);
12750 - if (!skb)
12751 - ieee80211_associate_abort(ieee);
12752 + skb=ieee80211_association_req_rtl7(beacon, ieee);
12753 + if (!skb)
12754 + ieee80211_associate_abort_rtl7(ieee);
12755 else{
12756 - softmac_mgmt_xmit(skb, ieee);
12757 + softmac_mgmt_xmit_rtl7(skb, ieee);
12758 ieee->associate_timer.expires = jiffies + (HZ / 2);
12759 add_timer(&ieee->associate_timer);
12760 - }
12761 + }
12762 }
12763  
12764 -void ieee80211_associate_complete_wq(struct ieee80211_device *ieee)
12765 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
12766 +void ieee80211_associate_complete_wq_rtl7(struct work_struct *work)
12767 +{
12768 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq);
12769 +#else
12770 +void ieee80211_associate_complete_wq_rtl7(struct ieee80211_device *ieee)
12771 {
12772 +#endif
12773 printk(KERN_INFO "Associated successfully\n");
12774 - if(ieee80211_is_54g(ieee->current_network) &&
12775 +#if 0
12776 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
12777 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
12778 -
12779 +
12780 ieee->rate = 540;
12781 printk(KERN_INFO"Using G rates\n");
12782 }else{
12783 ieee->rate = 110;
12784 printk(KERN_INFO"Using B rates\n");
12785 }
12786 +#else
12787 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
12788 +#endif
12789 ieee->link_change(ieee->dev);
12790 - notify_wx_assoc_event(ieee);
12791 + notify_wx_assoc_event_rtl7(ieee);
12792 if (ieee->data_hard_resume)
12793 ieee->data_hard_resume(ieee->dev);
12794 netif_carrier_on(ieee->dev);
12795 }
12796  
12797 -void ieee80211_associate_complete(struct ieee80211_device *ieee)
12798 +void ieee80211_associate_complete_rtl7(struct ieee80211_device *ieee)
12799 {
12800  
12801 del_timer_sync(&ieee->associate_timer);
12802 -
12803 +
12804 ieee->seq_ctrl = 0;
12805 ieee->state = IEEE80211_LINKED;
12806 IEEE80211_DEBUG_MGMT("Successfully associated\n");
12807 -
12808 +
12809 queue_work(ieee->wq, &ieee->associate_complete_wq);
12810 }
12811  
12812 -void ieee80211_associate_procedure_wq(struct ieee80211_device *ieee)
12813 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
12814 +void ieee80211_associate_procedure_wq_rtl7(struct work_struct *work)
12815 {
12816 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_procedure_wq);
12817 +#else
12818 +void ieee80211_associate_procedure_wq_rtl7(struct ieee80211_device *ieee)
12819 +{
12820 +#endif
12821 ieee->sync_scan_hurryup = 1;
12822 down(&ieee->wx_sem);
12823 -
12824 if (ieee->data_hard_stop)
12825 ieee->data_hard_stop(ieee->dev);
12826 -
12827 - ieee80211_stop_scan(ieee);
12828 +
12829 + ieee80211_stop_scan_rtl7(ieee);
12830 ieee->set_chan(ieee->dev, ieee->current_network.channel);
12831 -
12832 +
12833 ieee->associate_seq = 1;
12834 - ieee80211_associate_step1(ieee);
12835 -
12836 + ieee80211_associate_step1_rtl7(ieee);
12837 +
12838 up(&ieee->wx_sem);
12839 }
12840  
12841 -inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net)
12842 +inline void ieee80211_softmac_new_net_rtl7(struct ieee80211_device *ieee, struct ieee80211_network *net)
12843 {
12844 -
12845 +
12846 u8 tmp_ssid[IW_ESSID_MAX_SIZE+1];
12847 int tmp_ssid_len = 0;
12848 -
12849 +
12850 short apset,ssidset,ssidbroad,apmatch,ssidmatch;
12851 -
12852 - /* we are interested in new new only if we are not associated
12853 +
12854 + /* we are interested in new new only if we are not associated
12855 * and we are not associating / authenticating
12856 */
12857 if (ieee->state != IEEE80211_NOLINK)
12858 - return;
12859 -
12860 + return;
12861 +
12862 if ((ieee->iw_mode == IW_MODE_INFRA) && !(net->capability & WLAN_CAPABILITY_BSS))
12863 return;
12864 -
12865 +
12866 if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS))
12867 return;
12868  
12869 -
12870 +
12871 if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){
12872 /* if the user specified the AP MAC, we need also the essid
12873 * This could be obtained by beacons or, if the network does not
12874 @@ -1043,23 +1067,23 @@
12875 ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0');
12876 apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0);
12877 ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len));
12878 -
12879 -
12880 -
12881 +
12882 +
12883 +
12884 if ( /* if the user set the AP check if match.
12885 * if the network does not broadcast essid we check the user supplyed ANY essid
12886 * if the network does broadcast and the user does not set essid it is OK
12887 * if the network does broadcast and the user did set essid chech if essid match
12888 */
12889 - ( apset && apmatch &&
12890 - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
12891 + ( apset && apmatch &&
12892 + ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) ||
12893 /* if the ap is not set, check that the user set the bssid
12894 * and the network does bradcast and that those two bssid matches
12895 - */
12896 - (!apset && ssidset && ssidbroad && ssidmatch)
12897 + */
12898 + (!apset && ssidset && ssidbroad && ssidmatch)
12899 ){
12900 -
12901 -
12902 +
12903 +
12904 /* if the essid is hidden replace it with the
12905 * essid provided by the user.
12906 */
12907 @@ -1068,18 +1092,19 @@
12908 tmp_ssid_len = ieee->current_network.ssid_len;
12909 }
12910 memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network));
12911 -
12912 +
12913 if (!ssidbroad){
12914 strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
12915 ieee->current_network.ssid_len = tmp_ssid_len;
12916 }
12917 - printk(KERN_INFO"Linking with %s\n",ieee->current_network.ssid);
12918 -
12919 + printk(KERN_INFO"Linking with \"%s\" rate: %d MBit\n",ieee->current_network.ssid, (ieee->rate/10));
12920 +
12921 if (ieee->iw_mode == IW_MODE_INFRA){
12922 ieee->state = IEEE80211_ASSOCIATING;
12923 queue_work(ieee->wq, &ieee->associate_procedure_wq);
12924 }else{
12925 - if(ieee80211_is_54g(ieee->current_network) &&
12926 +#if 0
12927 + if(ieee80211_is_54g_rtl7(ieee->current_network) &&
12928 (ieee->modulation & IEEE80211_OFDM_MODULATION)){
12929 ieee->rate = 540;
12930 printk(KERN_INFO"Using G rates\n");
12931 @@ -1087,44 +1112,45 @@
12932 ieee->rate = 110;
12933 printk(KERN_INFO"Using B rates\n");
12934 }
12935 +#else
12936 + printk(KERN_INFO"Using %d MBit\n", (ieee->rate/10) );
12937 +#endif
12938 ieee->state = IEEE80211_LINKED;
12939 }
12940 -
12941 +
12942 }
12943 }
12944 -
12945 }
12946  
12947 -void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee)
12948 +void ieee80211_softmac_check_all_nets_rtl7(struct ieee80211_device *ieee)
12949 {
12950 -
12951 +
12952 unsigned long flags;
12953 struct ieee80211_network *target;
12954 -
12955 +
12956 spin_lock_irqsave(&ieee->lock, flags);
12957 -
12958 list_for_each_entry(target, &ieee->network_list, list) {
12959 -
12960 +
12961 /* if the state become different that NOLINK means
12962 * we had found what we are searching for
12963 */
12964 - if (ieee->state != IEEE80211_NOLINK)
12965 + if (ieee->state != IEEE80211_NOLINK)
12966 break;
12967 -
12968 +
12969 //if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies))
12970 - ieee80211_softmac_new_net(ieee, target);
12971 + ieee80211_softmac_new_net_rtl7(ieee, target);
12972 }
12973 -
12974 +
12975 spin_unlock_irqrestore(&ieee->lock, flags);
12976 -
12977 +
12978 }
12979  
12980  
12981 -static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen)
12982 +static inline u16 auth_parse_rtl7(struct sk_buff *skb, u8** challenge, int *chlen)
12983 {
12984 struct ieee80211_authentication *a;
12985 u8 *t;
12986 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
12987 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
12988 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len);
12989 return 0xcafe;
12990 }
12991 @@ -1132,58 +1158,58 @@
12992 a = (struct ieee80211_authentication*) skb->data;
12993 if(skb->len > (sizeof(struct ieee80211_authentication) +3)){
12994 t = skb->data + sizeof(struct ieee80211_authentication);
12995 -
12996 +
12997 if(*(t++) == MFIE_TYPE_CHALLENGE){
12998 *chlen = *(t++);
12999 *challenge = (u8*)kmalloc(*chlen, GFP_ATOMIC);
13000 memcpy(*challenge, t, *chlen);
13001 }
13002 }
13003 -
13004 +
13005 return cpu_to_le16(a->status);
13006 -
13007 +
13008 }
13009  
13010  
13011 -int auth_rq_parse(struct sk_buff *skb,u8* dest)
13012 +int auth_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
13013 {
13014 struct ieee80211_authentication *a;
13015 -
13016 - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
13017 - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
13018 +
13019 + if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){
13020 + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len);
13021 return -1;
13022 }
13023 a = (struct ieee80211_authentication*) skb->data;
13024 -
13025 +
13026 memcpy(dest,a->header.addr2, ETH_ALEN);
13027 -
13028 - if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
13029 +
13030 + if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
13031 return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
13032 -
13033 +
13034 return WLAN_STATUS_SUCCESS;
13035 }
13036  
13037 -static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
13038 +static short probe_rq_parse_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *src)
13039 {
13040 u8 *tag;
13041 u8 *skbend;
13042 u8 *ssid=NULL;
13043 u8 ssidlen = 0;
13044 -
13045 +
13046 struct ieee80211_hdr_3addr *header =
13047 (struct ieee80211_hdr_3addr *) skb->data;
13048 -
13049 - if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
13050 +
13051 + if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
13052 return -1; /* corrupted */
13053 -
13054 +
13055 memcpy(src,header->addr2, ETH_ALEN);
13056 -
13057 +
13058 skbend = (u8*)skb->data + skb->len;
13059 -
13060 +
13061 tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
13062 -
13063 +
13064 while (tag+1 < skbend){
13065 - if (*tag == 0){
13066 + if (*tag == 0){
13067 ssid = tag+2;
13068 ssidlen = *(tag+1);
13069 break;
13070 @@ -1192,88 +1218,88 @@
13071 tag = tag + *(tag); /* point to the last data byte of the tag */
13072 tag++; /* point to the next tag */
13073 }
13074 -
13075 +
13076 //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src));
13077 if (ssidlen == 0) return 1;
13078 -
13079 +
13080 if (!ssid) return 1; /* ssid not found in tagged param */
13081 return (!strncmp(ssid, ieee->current_network.ssid, ssidlen));
13082 -
13083 +
13084 }
13085  
13086 -int assoc_rq_parse(struct sk_buff *skb,u8* dest)
13087 +int assoc_rq_parse_rtl7(struct sk_buff *skb,u8* dest)
13088 {
13089 struct ieee80211_assoc_request_frame *a;
13090 -
13091 - if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
13092 - sizeof(struct ieee80211_info_element))) {
13093 -
13094 +
13095 + if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) -
13096 + sizeof(struct ieee80211_info_element))) {
13097 +
13098 IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len);
13099 return -1;
13100 }
13101 -
13102 +
13103 a = (struct ieee80211_assoc_request_frame*) skb->data;
13104 -
13105 +
13106 memcpy(dest,a->header.addr2,ETH_ALEN);
13107 -
13108 +
13109 return 0;
13110 }
13111  
13112 -static inline u16 assoc_parse(struct sk_buff *skb, int *aid)
13113 +static inline u16 assoc_parse_rtl7(struct sk_buff *skb, int *aid)
13114 {
13115 struct ieee80211_assoc_response_frame *a;
13116 - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
13117 + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){
13118 IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
13119 return 0xcafe;
13120 }
13121 -
13122 +
13123 a = (struct ieee80211_assoc_response_frame*) skb->data;
13124 *aid = le16_to_cpu(a->aid) & 0x3fff;
13125 return le16_to_cpu(a->status);
13126 }
13127  
13128 static inline void
13129 -ieee80211_rx_probe_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
13130 +ieee80211_rx_probe_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
13131 {
13132 u8 dest[ETH_ALEN];
13133 -
13134 +
13135 //IEEE80211DMESG("Rx probe");
13136 ieee->softmac_stats.rx_probe_rq++;
13137 //DMESG("Dest is "MACSTR, MAC2STR(dest));
13138 - if (probe_rq_parse(ieee, skb, dest)){
13139 + if (probe_rq_parse_rtl7(ieee, skb, dest)){
13140 //IEEE80211DMESG("Was for me!");
13141 ieee->softmac_stats.tx_probe_rs++;
13142 - ieee80211_resp_to_probe(ieee, dest);
13143 + ieee80211_resp_to_probe_rtl7(ieee, dest);
13144 }
13145 }
13146  
13147 static inline void
13148 -ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
13149 +ieee80211_rx_auth_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
13150 {
13151 u8 dest[ETH_ALEN];
13152 int status;
13153 //IEEE80211DMESG("Rx probe");
13154 ieee->softmac_stats.rx_auth_rq++;
13155 -
13156 - if ((status = auth_rq_parse(skb, dest))!= -1){
13157 - ieee80211_resp_to_auth(ieee, status, dest);
13158 +
13159 + if ((status = auth_rq_parse_rtl7(skb, dest))!= -1){
13160 + ieee80211_resp_to_auth_rtl7(ieee, status, dest);
13161 }
13162 //DMESG("Dest is "MACSTR, MAC2STR(dest));
13163 -
13164 +
13165 }
13166  
13167 static inline void
13168 -ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb)
13169 +ieee80211_rx_assoc_rq_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb)
13170 {
13171 -
13172 +
13173 u8 dest[ETH_ALEN];
13174 //unsigned long flags;
13175 -
13176 +
13177 ieee->softmac_stats.rx_ass_rq++;
13178 - if (assoc_rq_parse(skb,dest) != -1){
13179 - ieee80211_resp_to_assoc_rq(ieee, dest);
13180 + if (assoc_rq_parse_rtl7(skb,dest) != -1){
13181 + ieee80211_resp_to_assoc_rq_rtl7(ieee, dest);
13182 }
13183 -
13184 +
13185 printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest));
13186 //FIXME
13187 #if 0
13188 @@ -1285,25 +1311,25 @@
13189  
13190  
13191  
13192 -void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr)
13193 +void ieee80211_sta_ps_send_null_frame_rtl7(struct ieee80211_device *ieee, short pwr)
13194 {
13195 -
13196 - struct sk_buff *buf = ieee80211_null_func(ieee, pwr);
13197 -
13198 +
13199 + struct sk_buff *buf = ieee80211_null_func_rtl7(ieee, pwr);
13200 +
13201 if (buf)
13202 - softmac_ps_mgmt_xmit(buf, ieee);
13203 + softmac_ps_mgmt_xmit_rtl7(buf, ieee);
13204  
13205 -}
13206 +}
13207  
13208  
13209 -short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
13210 -{
13211 +short ieee80211_sta_ps_sleep_rtl7(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l)
13212 +{
13213 int timeout = ieee->ps_timeout;
13214 u8 dtim;
13215 /*if(ieee->ps == IEEE80211_PS_DISABLED ||
13216 - ieee->iw_mode != IW_MODE_INFRA ||
13217 + ieee->iw_mode != IW_MODE_INFRA ||
13218 ieee->state != IEEE80211_LINKED)
13219 -
13220 +
13221 return 0;
13222 */
13223 dtim = ieee->current_network.dtim_data;
13224 @@ -1312,133 +1338,133 @@
13225 return 0;
13226 //printk("VALID\n");
13227 ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID;
13228 -
13229 +
13230 if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps))
13231 return 2;
13232 -
13233 +
13234 if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout)))
13235 return 0;
13236 -
13237 +
13238 if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout)))
13239 return 0;
13240 -
13241 +
13242 if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) &&
13243 (ieee->mgmt_queue_tail != ieee->mgmt_queue_head))
13244 return 0;
13245 -
13246 +
13247 if(time_l){
13248 - *time_l = ieee->current_network.last_dtim_sta_time[0]
13249 - + (ieee->current_network.beacon_interval
13250 + *time_l = ieee->current_network.last_dtim_sta_time[0]
13251 + + (ieee->current_network.beacon_interval
13252 * ieee->current_network.dtim_period) * 1000;
13253 }
13254 -
13255 +
13256 if(time_h){
13257 *time_h = ieee->current_network.last_dtim_sta_time[1];
13258 if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0])
13259 *time_h += 1;
13260 }
13261 -
13262 +
13263 return 1;
13264 -
13265 -
13266 +
13267 +
13268 }
13269  
13270 -inline void ieee80211_sta_ps(struct ieee80211_device *ieee)
13271 +inline void ieee80211_sta_ps_rtl7(struct ieee80211_device *ieee)
13272 {
13273  
13274 u32 th,tl;
13275 short sleep;
13276 -
13277 +
13278 unsigned long flags,flags2;
13279 -
13280 +
13281 spin_lock_irqsave(&ieee->lock, flags);
13282 -
13283 +
13284 if((ieee->ps == IEEE80211_PS_DISABLED ||
13285 - ieee->iw_mode != IW_MODE_INFRA ||
13286 + ieee->iw_mode != IW_MODE_INFRA ||
13287 ieee->state != IEEE80211_LINKED)){
13288 -
13289 - #warning CHECK_LOCK_HERE
13290 +
13291 +// #warning CHECK_LOCK_HERE
13292 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
13293 -
13294 - ieee80211_sta_wakeup(ieee, 1);
13295 -
13296 +
13297 + ieee80211_sta_wakeup_rtl7(ieee, 1);
13298 + printk(KERN_WARNING "wakeup 1!\n" );
13299 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
13300 }
13301 -
13302 - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl);
13303 +
13304 + sleep = ieee80211_sta_ps_sleep_rtl7(ieee,&th, &tl);
13305 /* 2 wake, 1 sleep, 0 do nothing */
13306 if(sleep == 0)
13307 goto out;
13308 -
13309 +
13310 if(sleep == 1){
13311 -
13312 +
13313 if(ieee->sta_sleep == 1)
13314 ieee->enter_sleep_state(ieee->dev,th,tl);
13315 -
13316 +
13317 else if(ieee->sta_sleep == 0){
13318 // printk("send null 1\n");
13319 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
13320 -
13321 +
13322 if(ieee->ps_is_queue_empty(ieee->dev)){
13323 -
13324 -
13325 +
13326 +
13327 ieee->sta_sleep = 2;
13328 -
13329 +
13330 ieee->ps_request_tx_ack(ieee->dev);
13331 -
13332 - ieee80211_sta_ps_send_null_frame(ieee,1);
13333 -
13334 +
13335 + ieee80211_sta_ps_send_null_frame_rtl7(ieee,1);
13336 +
13337 ieee->ps_th = th;
13338 ieee->ps_tl = tl;
13339 - }
13340 + }
13341 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
13342 -
13343 +
13344 }
13345 -
13346 -
13347 +
13348 +
13349 }else if(sleep == 2){
13350 -#warning CHECK_LOCK_HERE
13351 +// #warning CHECK_LOCK_HERE
13352 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
13353 -
13354 - ieee80211_sta_wakeup(ieee,1);
13355 -
13356 +
13357 + ieee80211_sta_wakeup_rtl7(ieee,1);
13358 + printk(KERN_WARNING "wakeup 2!\n" );
13359 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
13360 }
13361  
13362 -out:
13363 +out:
13364 spin_unlock_irqrestore(&ieee->lock, flags);
13365 -
13366 +
13367 }
13368  
13369 -void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl)
13370 +void ieee80211_sta_wakeup_rtl7(struct ieee80211_device *ieee, short nl)
13371 {
13372 if(ieee->sta_sleep == 0){
13373 if(nl){
13374 printk("Warning: driver is probably failing to report TX ps error\n");
13375 ieee->ps_request_tx_ack(ieee->dev);
13376 - ieee80211_sta_ps_send_null_frame(ieee, 0);
13377 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
13378 }
13379 return;
13380 -
13381 +
13382 }
13383 -
13384 - if(ieee->sta_sleep == 1)
13385 +
13386 + if(ieee->sta_sleep == 1)
13387 ieee->sta_wake_up(ieee->dev);
13388 -
13389 +
13390 ieee->sta_sleep = 0;
13391 -
13392 +
13393 if(nl){
13394 ieee->ps_request_tx_ack(ieee->dev);
13395 - ieee80211_sta_ps_send_null_frame(ieee, 0);
13396 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
13397 }
13398 }
13399  
13400 -void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success)
13401 +void ieee80211_ps_tx_ack_rtl7(struct ieee80211_device *ieee, short success)
13402 {
13403 unsigned long flags,flags2;
13404 -
13405 +
13406 spin_lock_irqsave(&ieee->lock, flags);
13407 -
13408 +
13409 if(ieee->sta_sleep == 2){
13410 /* Null frame with PS bit set */
13411 if(success){
13412 @@ -1451,10 +1477,10 @@
13413 }
13414 /* 21112005 - tx again null without PS bit if lost */
13415 else {
13416 -
13417 +
13418 if((ieee->sta_sleep == 0) && !success){
13419 spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2);
13420 - ieee80211_sta_ps_send_null_frame(ieee, 0);
13421 + ieee80211_sta_ps_send_null_frame_rtl7(ieee, 0);
13422 spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2);
13423 }
13424 }
13425 @@ -1462,129 +1488,132 @@
13426 }
13427  
13428 inline int
13429 -ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
13430 +ieee80211_rx_frame_softmac_rtl7(struct ieee80211_device *ieee, struct sk_buff *skb,
13431 struct ieee80211_rx_stats *rx_stats, u16 type,
13432 u16 stype)
13433 {
13434 struct ieee80211_hdr_3addr *header;
13435 - header = (struct ieee80211_hdr_3addr *) skb->data;
13436 u16 errcode;
13437 u8* challenge;
13438 int chlen;
13439 int aid;
13440 -
13441 +
13442 + chlen = 0;
13443 +
13444 + header = (struct ieee80211_hdr_3addr *) skb->data;
13445 +
13446 if(!ieee->proto_started)
13447 return 0;
13448 -
13449 +
13450 if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
13451 - ieee->iw_mode == IW_MODE_INFRA &&
13452 + ieee->iw_mode == IW_MODE_INFRA &&
13453 ieee->state == IEEE80211_LINKED))
13454 -
13455 +
13456 tasklet_schedule(&ieee->ps_task);
13457 -
13458 +
13459 if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
13460 WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
13461 ieee->last_rx_ps_time = jiffies;
13462 -
13463 +
13464 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
13465 -
13466 +
13467 case IEEE80211_STYPE_ASSOC_RESP:
13468 case IEEE80211_STYPE_REASSOC_RESP:
13469 -
13470 +
13471 IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
13472 WLAN_FC_GET_STYPE(header->frame_ctl));
13473 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
13474 - ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
13475 + ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED &&
13476 ieee->iw_mode == IW_MODE_INFRA){
13477 - if (0 == (errcode=assoc_parse(skb, &aid))){
13478 -
13479 + if (0 == (errcode=assoc_parse_rtl7(skb, &aid))){
13480 +
13481 ieee->state=IEEE80211_LINKED;
13482 ieee->assoc_id = aid;
13483 ieee->softmac_stats.rx_ass_ok++;
13484 -
13485 - ieee80211_associate_complete(ieee);
13486 +
13487 + ieee80211_associate_complete_rtl7(ieee);
13488 }else{
13489 ieee->softmac_stats.rx_ass_err++;
13490 IEEE80211_DEBUG_MGMT(
13491 "Association response status code 0x%x\n",
13492 errcode);
13493 - ieee80211_associate_abort(ieee);
13494 + ieee80211_associate_abort_rtl7(ieee);
13495 }
13496 }
13497 break;
13498 -
13499 +
13500 case IEEE80211_STYPE_ASSOC_REQ:
13501 case IEEE80211_STYPE_REASSOC_REQ:
13502 -
13503 +
13504 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
13505 ieee->iw_mode == IW_MODE_MASTER)
13506 -
13507 - ieee80211_rx_assoc_rq(ieee, skb);
13508 +
13509 + ieee80211_rx_assoc_rq_rtl7(ieee, skb);
13510 break;
13511 -
13512 +
13513 case IEEE80211_STYPE_AUTH:
13514 -
13515 +
13516 if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){
13517 - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
13518 + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING &&
13519 ieee->iw_mode == IW_MODE_INFRA){
13520 -
13521 +
13522 IEEE80211_DEBUG_MGMT("Received authentication response");
13523 -
13524 - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){
13525 +
13526 + if (0 == (errcode=auth_parse_rtl7(skb, &challenge, &chlen))){
13527 if(ieee->open_wep || !challenge){
13528 ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED;
13529 ieee->softmac_stats.rx_auth_rs_ok++;
13530 -
13531 - ieee80211_associate_step2(ieee);
13532 +
13533 + ieee80211_associate_step2_rtl7(ieee);
13534 }else{
13535 - ieee80211_auth_challenge(ieee, challenge, chlen);
13536 + ieee80211_auth_challenge_rtl7(ieee, challenge, chlen);
13537 }
13538 }else{
13539 ieee->softmac_stats.rx_auth_rs_err++;
13540 IEEE80211_DEBUG_MGMT("Authentication respose status code 0x%x",errcode);
13541 - ieee80211_associate_abort(ieee);
13542 + ieee80211_associate_abort_rtl7(ieee);
13543 }
13544 -
13545 +
13546 }else if (ieee->iw_mode == IW_MODE_MASTER){
13547 - ieee80211_rx_auth_rq(ieee, skb);
13548 + ieee80211_rx_auth_rq_rtl7(ieee, skb);
13549 }
13550 }
13551 break;
13552 -
13553 +
13554 case IEEE80211_STYPE_PROBE_REQ:
13555 -
13556 - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
13557 - ((ieee->iw_mode == IW_MODE_ADHOC ||
13558 +
13559 + if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
13560 + ((ieee->iw_mode == IW_MODE_ADHOC ||
13561 ieee->iw_mode == IW_MODE_MASTER) &&
13562 ieee->state == IEEE80211_LINKED))
13563 -
13564 - ieee80211_rx_probe_rq(ieee, skb);
13565 +
13566 + ieee80211_rx_probe_rq_rtl7(ieee, skb);
13567 break;
13568 -
13569 +
13570 case IEEE80211_STYPE_DISASSOC:
13571 case IEEE80211_STYPE_DEAUTH:
13572 - /* FIXME for now repeat all the association procedure
13573 + /* FIXME for now repeat all the association procedure
13574 * both for disassociation and deauthentication
13575 */
13576 if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
13577 - ieee->state == IEEE80211_LINKED &&
13578 + ieee->state == IEEE80211_LINKED &&
13579 ieee->iw_mode == IW_MODE_INFRA){
13580 -
13581 +
13582 ieee->state = IEEE80211_ASSOCIATING;
13583 ieee->softmac_stats.reassoc++;
13584 -
13585 - notify_wx_assoc_event(ieee);
13586 -
13587 +
13588 + notify_wx_assoc_event_rtl7(ieee);
13589 +
13590 queue_work(ieee->wq, &ieee->associate_procedure_wq);
13591 }
13592 -
13593 +
13594 break;
13595 -
13596 - default:
13597 +
13598 + default:
13599 return -1;
13600 break;
13601 }
13602 -
13603 +
13604 //dev_kfree_skb_any(skb);
13605 return 0;
13606 }
13607 @@ -1602,21 +1631,21 @@
13608 * This might be useful if each fragment need it's own
13609 * descriptor, thus just keep a total free memory > than
13610 * the max fragmentation treshold is not enought.. If the
13611 - * ieee802.11 stack passed a TXB struct then you needed
13612 - * to keep N free descriptors where
13613 + * ieee802.11 stack passed a TXB struct then you needed
13614 + * to keep N free descriptors where
13615 * N = MAX_PACKET_SIZE / MIN_FRAG_TRESHOLD
13616 * In this way you need just one and the 802.11 stack
13617 - * will take care of buffering fragments and pass them to
13618 + * will take care of buffering fragments and pass them to
13619 * to the driver later, when it wakes the queue.
13620 - */
13621 -
13622 -void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
13623 + */
13624 +
13625 +void ieee80211_softmac_xmit_rtl7(struct ieee80211_txb *txb, struct ieee80211_device *ieee)
13626 {
13627 -
13628 -
13629 +
13630 +
13631 unsigned long flags;
13632 int i;
13633 -
13634 +
13635 spin_lock_irqsave(&ieee->lock,flags);
13636 #if 0
13637 if(ieee->queue_stop){
13638 @@ -1627,13 +1656,13 @@
13639 err = 1;
13640 goto exit;
13641 }
13642 -
13643 +
13644 ieee->stats.tx_bytes+=skb->len;
13645 -
13646 -
13647 +
13648 +
13649 txb=ieee80211_skb_to_txb(ieee,skb);
13650 -
13651 -
13652 +
13653 +
13654 if(txb==NULL){
13655 IEEE80211DMESG("WW: IEEE stack failed to provide txb");
13656 //dev_kfree_skb_any(skb);
13657 @@ -1641,12 +1670,12 @@
13658 goto exit;
13659 }
13660 #endif
13661 -
13662 +
13663 /* called with 2nd parm 0, no tx mgmt lock required */
13664 - ieee80211_sta_wakeup(ieee,0);
13665 + ieee80211_sta_wakeup_rtl7(ieee,0);
13666  
13667 for(i = 0; i < txb->nr_frags; i++) {
13668 -
13669 +
13670 if (ieee->queue_stop){
13671 ieee->tx_pending.txb = txb;
13672 ieee->tx_pending.frag = i;
13673 @@ -1658,29 +1687,29 @@
13674 //(i+1)<txb->nr_frags);
13675 ieee->stats.tx_packets++;
13676 ieee->stats.tx_bytes += txb->fragments[i]->len;
13677 - ieee->dev->trans_start = jiffies;
13678 + ieee->dev->trans_start = jiffies;
13679 }
13680 - }
13681 -
13682 - ieee80211_txb_free(txb);
13683 -
13684 + }
13685 +
13686 + ieee80211_txb_free_rtl7(txb);
13687 +
13688 exit:
13689 spin_unlock_irqrestore(&ieee->lock,flags);
13690 -
13691 +
13692 }
13693  
13694 /* called with ieee->lock acquired */
13695 -void ieee80211_resume_tx(struct ieee80211_device *ieee)
13696 +void ieee80211_resume_tx_rtl7(struct ieee80211_device *ieee)
13697 {
13698 int i;
13699 for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) {
13700 -
13701 +
13702 if (ieee->queue_stop){
13703 ieee->tx_pending.frag = i;
13704 return;
13705 }else{
13706 -
13707 - ieee->softmac_data_hard_start_xmit(
13708 +
13709 + ieee->softmac_data_hard_start_xmit(
13710 ieee->tx_pending.txb->fragments[i],
13711 ieee->dev,ieee->rate);
13712 //(i+1)<ieee->tx_pending.txb->nr_frags);
13713 @@ -1688,21 +1717,21 @@
13714 ieee->dev->trans_start = jiffies;
13715 }
13716 }
13717 -
13718 -
13719 - ieee80211_txb_free(ieee->tx_pending.txb);
13720 +
13721 +
13722 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
13723 ieee->tx_pending.txb = NULL;
13724 }
13725  
13726  
13727 -void ieee80211_reset_queue(struct ieee80211_device *ieee)
13728 +void ieee80211_reset_queue_rtl7(struct ieee80211_device *ieee)
13729 {
13730 unsigned long flags;
13731 -
13732 +
13733 spin_lock_irqsave(&ieee->lock,flags);
13734 - init_mgmt_queue(ieee);
13735 + init_mgmt_queue_rtl7(ieee);
13736 if (ieee->tx_pending.txb){
13737 - ieee80211_txb_free(ieee->tx_pending.txb);
13738 + ieee80211_txb_free_rtl7(ieee->tx_pending.txb);
13739 ieee->tx_pending.txb = NULL;
13740 }
13741 ieee->queue_stop = 0;
13742 @@ -1710,23 +1739,23 @@
13743  
13744 }
13745  
13746 -void ieee80211_wake_queue(struct ieee80211_device *ieee)
13747 +void ieee80211_wake_queue_rtl7(struct ieee80211_device *ieee)
13748 {
13749  
13750 unsigned long flags;
13751 struct sk_buff *skb;
13752 struct ieee80211_hdr_3addr *header;
13753 -
13754 +
13755 spin_lock_irqsave(&ieee->lock,flags);
13756 if (! ieee->queue_stop) goto exit;
13757 -
13758 +
13759 ieee->queue_stop = 0;
13760 -
13761 +
13762 if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){
13763 - while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
13764 -
13765 + while (!ieee->queue_stop && (skb = dequeue_mgmt_rtl7(ieee))){
13766 +
13767 header = (struct ieee80211_hdr_3addr *) skb->data;
13768 -
13769 +
13770 header->seq_ctl = cpu_to_le16(ieee->seq_ctrl << 4);
13771  
13772 if (ieee->seq_ctrl == 0xFFF)
13773 @@ -1738,19 +1767,19 @@
13774 }
13775 }
13776 if (!ieee->queue_stop && ieee->tx_pending.txb)
13777 - ieee80211_resume_tx(ieee);
13778 -
13779 + ieee80211_resume_tx_rtl7(ieee);
13780 +
13781 if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){
13782 ieee->softmac_stats.swtxawake++;
13783 netif_wake_queue(ieee->dev);
13784 }
13785 -
13786 +
13787 exit :
13788 spin_unlock_irqrestore(&ieee->lock,flags);
13789 }
13790  
13791  
13792 -void ieee80211_stop_queue(struct ieee80211_device *ieee)
13793 +void ieee80211_stop_queue_rtl7(struct ieee80211_device *ieee)
13794 {
13795 //unsigned long flags;
13796 //spin_lock_irqsave(&ieee->lock,flags);
13797 @@ -1761,81 +1790,88 @@
13798 }
13799 ieee->queue_stop = 1;
13800 //spin_unlock_irqrestore(&ieee->lock,flags);
13801 -
13802 +
13803 }
13804  
13805  
13806 -inline void ieee80211_randomize_cell(struct ieee80211_device *ieee)
13807 +inline void ieee80211_randomize_cell_rtl7(struct ieee80211_device *ieee)
13808 {
13809 -
13810 +
13811 get_random_bytes(ieee->current_network.bssid, ETH_ALEN);
13812 -
13813 +
13814 /* an IBSS cell address must have the two less significant
13815 - * bits of the first byte = 2
13816 + * bits of the first byte = 2
13817 */
13818 ieee->current_network.bssid[0] &= ~0x01;
13819 ieee->current_network.bssid[0] |= 0x02;
13820 }
13821  
13822 /* called in user context only */
13823 -void ieee80211_start_master_bss(struct ieee80211_device *ieee)
13824 +void ieee80211_start_master_bss_rtl7(struct ieee80211_device *ieee)
13825 {
13826 ieee->assoc_id = 1;
13827 -
13828 +
13829 if (ieee->current_network.ssid_len == 0){
13830 - strncpy(ieee->current_network.ssid,
13831 + strncpy(ieee->current_network.ssid,
13832 IEEE80211_DEFAULT_TX_ESSID,
13833 IW_ESSID_MAX_SIZE);
13834 -
13835 +
13836 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
13837 ieee->ssid_set = 1;
13838 }
13839 -
13840 +
13841 memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
13842 -
13843 +
13844 ieee->set_chan(ieee->dev, ieee->current_network.channel);
13845 ieee->state = IEEE80211_LINKED;
13846 ieee->link_change(ieee->dev);
13847 - notify_wx_assoc_event(ieee);
13848 -
13849 + notify_wx_assoc_event_rtl7(ieee);
13850 +
13851 if (ieee->data_hard_resume)
13852 ieee->data_hard_resume(ieee->dev);
13853 -
13854 +
13855 netif_carrier_on(ieee->dev);
13856 }
13857  
13858 -void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
13859 +void ieee80211_start_monitor_mode_rtl7(struct ieee80211_device *ieee)
13860 {
13861 if(ieee->raw_tx){
13862 -
13863 +
13864 if (ieee->data_hard_resume)
13865 ieee->data_hard_resume(ieee->dev);
13866 -
13867 +
13868 netif_carrier_on(ieee->dev);
13869 }
13870 }
13871 -void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
13872 +
13873 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
13874 +void ieee80211_start_ibss_wq_rtl7(struct work_struct *work)
13875 +{
13876 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, start_ibss_wq);
13877 +#else
13878 +void ieee80211_start_ibss_wq_rtl7(struct ieee80211_device *ieee)
13879 {
13880 -
13881 +#endif
13882 +
13883 /* iwconfig mode ad-hoc will schedule this and return
13884 * on the other hand this will block further iwconfig SET
13885 * operations because of the wx_sem hold.
13886 * Anyway some most set operations set a flag to speed-up
13887 - * (abort) this wq (when syncro scanning) before sleeping
13888 + * (abort) this wq (when syncro scanning) before sleeping
13889 * on the semaphore
13890 */
13891 -
13892 +
13893 down(&ieee->wx_sem);
13894 -
13895 +
13896 if (ieee->current_network.ssid_len == 0){
13897 strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID);
13898 ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID);
13899 ieee->ssid_set = 1;
13900 - }
13901 -
13902 + }
13903 +
13904 /* check if we have this cell in our network list */
13905 - ieee80211_softmac_check_all_nets(ieee);
13906 -
13907 + ieee80211_softmac_check_all_nets_rtl7(ieee);
13908 +
13909 /* if not then the state is not linked. Maybe the user swithced to
13910 * ad-hoc mode just after being in monitor mode, or just after
13911 * being very few time in managed mode (so the card have had no
13912 @@ -1851,29 +1887,29 @@
13913 * associated.
13914 */
13915 if (ieee->state == IEEE80211_NOLINK)
13916 - ieee80211_start_scan_syncro(ieee);
13917 + ieee80211_start_scan_syncro_rtl7(ieee);
13918  
13919 /* the network definitively is not here.. create a new cell */
13920 if (ieee->state == IEEE80211_NOLINK){
13921 - printk("creating new IBSS cell\n");
13922 + printk("creating new IBSS cell\n");
13923 if(!ieee->wap_set)
13924 - ieee80211_randomize_cell(ieee);
13925 -
13926 + ieee80211_randomize_cell_rtl7(ieee);
13927 +
13928 if(ieee->modulation & IEEE80211_CCK_MODULATION){
13929 -
13930 +
13931 ieee->current_network.rates_len = 4;
13932 -
13933 +
13934 ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
13935 ieee->current_network.rates[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
13936 ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
13937 ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
13938 -
13939 +
13940 }else
13941 ieee->current_network.rates_len = 0;
13942 -
13943 +
13944 if(ieee->modulation & IEEE80211_OFDM_MODULATION){
13945 ieee->current_network.rates_ex_len = 8;
13946 -
13947 +
13948 ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB;
13949 ieee->current_network.rates_ex[1] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_9MB;
13950 ieee->current_network.rates_ex[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_12MB;
13951 @@ -1882,44 +1918,44 @@
13952 ieee->current_network.rates_ex[5] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_36MB;
13953 ieee->current_network.rates_ex[6] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_48MB;
13954 ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB;
13955 -
13956 - ieee->rate = 540;
13957 +
13958 +// ieee->rate = 540;
13959 }else{
13960 ieee->current_network.rates_ex_len = 0;
13961 - ieee->rate = 110;
13962 +// ieee->rate = 110;
13963 }
13964 -
13965 +
13966 ieee->current_network.atim_window = 0;
13967 ieee->current_network.capability = WLAN_CAPABILITY_IBSS;
13968 if(ieee->short_slot)
13969 ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT;
13970 -
13971 +
13972 }
13973 -
13974 +
13975 ieee->state = IEEE80211_LINKED;
13976 -
13977 +
13978 ieee->set_chan(ieee->dev, ieee->current_network.channel);
13979 ieee->link_change(ieee->dev);
13980 -
13981 - notify_wx_assoc_event(ieee);
13982 -
13983 - ieee80211_start_send_beacons(ieee);
13984 -
13985 +
13986 + notify_wx_assoc_event_rtl7(ieee);
13987 +
13988 + ieee80211_start_send_beacons_rtl7(ieee);
13989 +
13990 if (ieee->data_hard_resume)
13991 ieee->data_hard_resume(ieee->dev);
13992 -
13993 +
13994 netif_carrier_on(ieee->dev);
13995 -
13996 +
13997 up(&ieee->wx_sem);
13998 }
13999  
14000 -inline void ieee80211_start_ibss(struct ieee80211_device *ieee)
14001 +inline void ieee80211_start_ibss_rtl7(struct ieee80211_device *ieee)
14002 {
14003 queue_work(ieee->wq, &ieee->start_ibss_wq);
14004 }
14005  
14006 /* this is called only in user context, with wx_sem held */
14007 -void ieee80211_start_bss(struct ieee80211_device *ieee)
14008 +void ieee80211_start_bss_rtl7(struct ieee80211_device *ieee)
14009 {
14010 unsigned long flags;
14011 /* check if we have already found the net we
14012 @@ -1927,8 +1963,8 @@
14013 * if not (we are disassociated and we are not
14014 * in associating / authenticating phase) start the background scanning.
14015 */
14016 - ieee80211_softmac_check_all_nets(ieee);
14017 -
14018 + ieee80211_softmac_check_all_nets_rtl7(ieee);
14019 +
14020 /* ensure no-one start an associating process (thus setting
14021 * the ieee->state to ieee80211_ASSOCIATING) while we
14022 * have just cheked it and we are going to enable scan.
14023 @@ -1937,41 +1973,49 @@
14024 * the rx path), so we cannot be in the middle of such function
14025 */
14026 spin_lock_irqsave(&ieee->lock, flags);
14027 -
14028 if (ieee->state == IEEE80211_NOLINK)
14029 - ieee80211_start_scan(ieee);
14030 -
14031 + ieee80211_start_scan_rtl7(ieee);
14032 +
14033 spin_unlock_irqrestore(&ieee->lock, flags);
14034 }
14035  
14036 /* called only in userspace context */
14037 -void ieee80211_disassociate(struct ieee80211_device *ieee)
14038 +void ieee80211_disassociate_rtl7(struct ieee80211_device *ieee)
14039 {
14040 netif_carrier_off(ieee->dev);
14041 -
14042 +
14043 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)
14044 - ieee80211_reset_queue(ieee);
14045 -
14046 + ieee80211_reset_queue_rtl7(ieee);
14047 +
14048 if (ieee->data_hard_stop)
14049 ieee->data_hard_stop(ieee->dev);
14050 -
14051 +
14052 ieee->state = IEEE80211_NOLINK;
14053 ieee->link_change(ieee->dev);
14054 - notify_wx_assoc_event(ieee);
14055 -
14056 + notify_wx_assoc_event_rtl7(ieee);
14057 +
14058 }
14059 -void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
14060 +
14061 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
14062 +void ieee80211_associate_retry_wq_rtl7(struct work_struct *work)
14063 +{
14064 + struct delayed_work *dwork = container_of(work, struct delayed_work, work);
14065 + struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
14066 +#else
14067 +void ieee80211_associate_retry_wq_rtl7(struct ieee80211_device *ieee)
14068 {
14069 +#endif
14070 unsigned long flags;
14071 -
14072 +
14073 down(&ieee->wx_sem);
14074 +
14075 if(!ieee->proto_started)
14076 goto exit;
14077 -
14078 +
14079 if(ieee->state != IEEE80211_ASSOCIATING_RETRY)
14080 goto exit;
14081 -
14082 - /* until we do not set the state to IEEE80211_NOLINK
14083 +
14084 + /* until we do not set the state to IEEE80211_NOLINK
14085 * there are no possibility to have someone else trying
14086 * to start an association procdure (we get here with
14087 * ieee->state = IEEE80211_ASSOCIATING).
14088 @@ -1981,122 +2025,120 @@
14089 * RX path works with ieee->lock held so there are no
14090 * problems. If we are still disassociated then start a scan.
14091 * the lock here is necessary to ensure no one try to start
14092 - * an association procedure when we have just checked the
14093 + * an association procedure when we have just checked the
14094 * state and we are going to start the scan.
14095 */
14096 ieee->state = IEEE80211_NOLINK;
14097  
14098 - ieee80211_softmac_check_all_nets(ieee);
14099 -
14100 + ieee80211_softmac_check_all_nets_rtl7(ieee);
14101 +
14102 spin_lock_irqsave(&ieee->lock, flags);
14103 -
14104 +
14105 if(ieee->state == IEEE80211_NOLINK)
14106 - ieee80211_start_scan(ieee);
14107 -
14108 + ieee80211_start_scan_rtl7(ieee);
14109 +
14110 spin_unlock_irqrestore(&ieee->lock, flags);
14111  
14112 exit:
14113 up(&ieee->wx_sem);
14114 }
14115  
14116 -struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee)
14117 +struct sk_buff *ieee80211_get_beacon__rtl7(struct ieee80211_device *ieee)
14118 {
14119 u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff};
14120 -
14121 +
14122 struct sk_buff *skb;
14123 struct ieee80211_probe_response *b;
14124 -
14125 - skb = ieee80211_probe_resp(ieee, broadcast_addr);
14126 -
14127 - if (!skb)
14128 +
14129 + skb = ieee80211_probe_resp_rtl7(ieee, broadcast_addr);
14130 +
14131 + if (!skb)
14132 return NULL;
14133 -
14134 +
14135 b = (struct ieee80211_probe_response *) skb->data;
14136 b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON);
14137 -
14138 +
14139 return skb;
14140 -
14141 +
14142 }
14143  
14144 -struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee)
14145 +struct sk_buff *ieee80211_get_beacon_rtl7(struct ieee80211_device *ieee)
14146 {
14147 struct sk_buff *skb;
14148 struct ieee80211_probe_response *b;
14149 -
14150 - skb = ieee80211_get_beacon_(ieee);
14151 - if(!skb)
14152 +
14153 + skb = ieee80211_get_beacon__rtl7(ieee);
14154 + if(!skb)
14155 return NULL;
14156 -
14157 - b = (struct ieee80211_probe_response *) skb->data;
14158 +
14159 + b = (struct ieee80211_probe_response *) skb->data;
14160 b->header.seq_ctrl = cpu_to_le16(ieee->seq_ctrl << 4);
14161 -
14162 +
14163 if (ieee->seq_ctrl == 0xFFF)
14164 ieee->seq_ctrl = 0;
14165 else
14166 ieee->seq_ctrl++;
14167 -
14168 +
14169 return skb;
14170 }
14171  
14172 -void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee)
14173 +void ieee80211_softmac_stop_protocol_rtl7(struct ieee80211_device *ieee)
14174 {
14175 ieee->sync_scan_hurryup = 1;
14176 down(&ieee->wx_sem);
14177 - ieee80211_stop_protocol(ieee);
14178 +
14179 + ieee80211_stop_protocol_rtl7(ieee);
14180 up(&ieee->wx_sem);
14181 }
14182  
14183  
14184 -void ieee80211_stop_protocol(struct ieee80211_device *ieee)
14185 +void ieee80211_stop_protocol_rtl7(struct ieee80211_device *ieee)
14186 {
14187 if (!ieee->proto_started)
14188 return;
14189 -
14190 +
14191 ieee->proto_started = 0;
14192 -
14193 - ieee80211_stop_send_beacons(ieee);
14194 -
14195 +
14196 + ieee80211_stop_send_beacons_rtl7(ieee);
14197 +
14198 del_timer_sync(&ieee->associate_timer);
14199 - cancel_delayed_work(&ieee->associate_retry_wq);
14200 -
14201 - ieee80211_stop_scan(ieee);
14202 + cancel_delayed_work(&ieee->associate_retry_wq);
14203 +
14204 + ieee80211_stop_scan_rtl7(ieee);
14205  
14206 - ieee80211_disassociate(ieee);
14207 + ieee80211_disassociate_rtl7(ieee);
14208 }
14209  
14210 -void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee)
14211 +void ieee80211_softmac_start_protocol_rtl7(struct ieee80211_device *ieee)
14212 {
14213 ieee->sync_scan_hurryup = 0;
14214 down(&ieee->wx_sem);
14215 - ieee80211_start_protocol(ieee);
14216 + ieee80211_start_protocol_rtl7(ieee);
14217 up(&ieee->wx_sem);
14218 }
14219  
14220 -void ieee80211_start_protocol(struct ieee80211_device *ieee)
14221 +void ieee80211_start_protocol_rtl7(struct ieee80211_device *ieee)
14222 {
14223 short ch = 0;
14224 -
14225 if (ieee->proto_started)
14226 return;
14227 -
14228 +
14229 ieee->proto_started = 1;
14230 -
14231 +
14232 if (ieee->current_network.channel == 0){
14233 do{
14234 ch++;
14235 - if (ch > MAX_CHANNEL_NUMBER)
14236 + if (ch > MAX_CHANNEL_NUMBER)
14237 return; /* no channel found */
14238 -
14239 +
14240 }while(!ieee->channel_map[ch]);
14241 -
14242 +
14243 ieee->current_network.channel = ch;
14244 }
14245 -
14246 +
14247 if (ieee->current_network.beacon_interval == 0)
14248 ieee->current_network.beacon_interval = 100;
14249 -
14250 ieee->set_chan(ieee->dev,ieee->current_network.channel);
14251 -
14252 ieee->last_seq_num = -1;
14253 ieee->last_frag_num = -1;
14254 ieee->last_packet_time = 0;
14255 @@ -2107,30 +2149,27 @@
14256 * attempts does not fail just because the user provide the essid
14257 * and the nic is still checking for the AP MAC ??
14258 */
14259 -
14260 +
14261 if (ieee->iw_mode == IW_MODE_INFRA)
14262 - ieee80211_start_bss(ieee);
14263 -
14264 + ieee80211_start_bss_rtl7(ieee);
14265 else if (ieee->iw_mode == IW_MODE_ADHOC)
14266 - ieee80211_start_ibss(ieee);
14267 -
14268 + ieee80211_start_ibss_rtl7(ieee);
14269 else if (ieee->iw_mode == IW_MODE_MASTER)
14270 - ieee80211_start_master_bss(ieee);
14271 -
14272 + ieee80211_start_master_bss_rtl7(ieee);
14273 else if(ieee->iw_mode == IW_MODE_MONITOR)
14274 - ieee80211_start_monitor_mode(ieee);
14275 + ieee80211_start_monitor_mode_rtl7(ieee);
14276 }
14277  
14278  
14279 #define DRV_NAME "Ieee80211"
14280 -void ieee80211_softmac_init(struct ieee80211_device *ieee)
14281 +void ieee80211_softmac_init_rtl7(struct ieee80211_device *ieee)
14282 {
14283 memset(&ieee->current_network, 0, sizeof(struct ieee80211_network));
14284 -
14285 +
14286 ieee->state = IEEE80211_NOLINK;
14287 ieee->sync_scan_hurryup = 0;
14288 ieee->seq_ctrl = 0;
14289 -
14290 +
14291 ieee->assoc_id = 0;
14292 ieee->queue_stop = 0;
14293 ieee->scanning = 0;
14294 @@ -2142,66 +2181,75 @@
14295 ieee->rate = 3;
14296 ieee->ps = IEEE80211_PS_DISABLED;
14297 ieee->sta_sleep = 0;
14298 -
14299 - init_mgmt_queue(ieee);
14300 +
14301 + init_mgmt_queue_rtl7(ieee);
14302 #if 0
14303 init_timer(&ieee->scan_timer);
14304 ieee->scan_timer.data = (unsigned long)ieee;
14305 ieee->scan_timer.function = ieee80211_softmac_scan_cb;
14306 #endif
14307 ieee->tx_pending.txb = NULL;
14308 -
14309 +
14310 init_timer(&ieee->associate_timer);
14311 ieee->associate_timer.data = (unsigned long)ieee;
14312 - ieee->associate_timer.function = ieee80211_associate_abort_cb;
14313 + ieee->associate_timer.function = ieee80211_associate_abort_cb_rtl7;
14314  
14315 init_timer(&ieee->beacon_timer);
14316 ieee->beacon_timer.data = (unsigned long) ieee;
14317 - ieee->beacon_timer.function = ieee80211_send_beacon_cb;
14318 -
14319 + ieee->beacon_timer.function = ieee80211_send_beacon_cb_rtl7;
14320 +
14321 #ifdef PF_SYNCTHREAD
14322 ieee->wq = create_workqueue(DRV_NAME,0);
14323 -#else
14324 +#else
14325 ieee->wq = create_workqueue(DRV_NAME);
14326 #endif
14327 -
14328 - INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq,ieee);
14329 - INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq,ieee);
14330 - INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq,ieee);
14331 - INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq,ieee);
14332 - INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq,ieee);
14333 - INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq,ieee);
14334 -
14335 +
14336 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
14337 + INIT_WORK(&ieee->start_ibss_wq,(void(*)(void*)) ieee80211_start_ibss_wq_rtl7,ieee);
14338 + INIT_WORK(&ieee->associate_retry_wq,(void(*)(void*)) ieee80211_associate_retry_wq_rtl7,ieee);
14339 + INIT_WORK(&ieee->associate_complete_wq,(void(*)(void*)) ieee80211_associate_complete_wq_rtl7,ieee);
14340 + INIT_WORK(&ieee->associate_procedure_wq,(void(*)(void*)) ieee80211_associate_procedure_wq_rtl7,ieee);
14341 + INIT_WORK(&ieee->softmac_scan_wq,(void(*)(void*)) ieee80211_softmac_scan_wq_rtl7,ieee);
14342 + INIT_WORK(&ieee->wx_sync_scan_wq,(void(*)(void*)) ieee80211_wx_sync_scan_wq_rtl7,ieee);
14343 +#else
14344 + INIT_WORK(&ieee->start_ibss_wq, ieee80211_start_ibss_wq_rtl7);
14345 + INIT_DELAYED_WORK(&ieee->associate_retry_wq, ieee80211_associate_retry_wq_rtl7);
14346 + INIT_WORK(&ieee->associate_complete_wq, ieee80211_associate_complete_wq_rtl7);
14347 + INIT_WORK(&ieee->associate_procedure_wq, ieee80211_associate_procedure_wq_rtl7);
14348 + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, ieee80211_softmac_scan_wq_rtl7);
14349 + INIT_WORK(&ieee->wx_sync_scan_wq, ieee80211_wx_sync_scan_wq_rtl7);
14350 +#endif
14351 +
14352 sema_init(&ieee->wx_sem, 1);
14353 sema_init(&ieee->scan_sem, 1);
14354 -
14355 +
14356 spin_lock_init(&ieee->mgmt_tx_lock);
14357 spin_lock_init(&ieee->beacon_lock);
14358 -
14359 +
14360 tasklet_init(&ieee->ps_task,
14361 - (void(*)(unsigned long)) ieee80211_sta_ps,
14362 + (void(*)(unsigned long)) ieee80211_sta_ps_rtl7,
14363 (unsigned long)ieee);
14364  
14365 }
14366  
14367 -void ieee80211_softmac_free(struct ieee80211_device *ieee)
14368 +void ieee80211_softmac_free_rtl7(struct ieee80211_device *ieee)
14369 {
14370 down(&ieee->wx_sem);
14371 -
14372 +
14373 del_timer_sync(&ieee->associate_timer);
14374 cancel_delayed_work(&ieee->associate_retry_wq);
14375 destroy_workqueue(ieee->wq);
14376 -
14377 +
14378 up(&ieee->wx_sem);
14379 }
14380  
14381 -/********************************************************
14382 +/********************************************************
14383 * Start of WPA code. *
14384 * this is stolen from the ipw2200 driver *
14385 ********************************************************/
14386  
14387 -
14388 -static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value)
14389 +
14390 +static int ieee80211_wpa_enable_rtl7(struct ieee80211_device *ieee, int value)
14391 {
14392 /* This is called when wpa_supplicant loads and closes the driver
14393 * interface. */
14394 @@ -2210,19 +2258,19 @@
14395 return 0;
14396 }
14397  
14398 -
14399 -void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
14400 +
14401 +void ieee80211_wpa_assoc_frame_rtl7(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len)
14402 {
14403 /* make sure WPA is enabled */
14404 - ieee80211_wpa_enable(ieee, 1);
14405 + ieee80211_wpa_enable_rtl7(ieee, 1);
14406  
14407 - ieee80211_disassociate(ieee);
14408 + ieee80211_disassociate_rtl7(ieee);
14409 }
14410  
14411  
14412 -static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason)
14413 +static int ieee80211_wpa_mlme_rtl7(struct ieee80211_device *ieee, int command, int reason)
14414 {
14415 -
14416 +
14417 int ret = 0;
14418  
14419 switch (command) {
14420 @@ -2231,7 +2279,7 @@
14421 break;
14422  
14423 case IEEE_MLME_STA_DISASSOC:
14424 - ieee80211_disassociate(ieee);
14425 + ieee80211_disassociate_rtl7(ieee);
14426 break;
14427  
14428 default:
14429 @@ -2243,7 +2291,7 @@
14430 }
14431  
14432  
14433 -static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee,
14434 +static int ieee80211_wpa_set_wpa_ie_rtl7(struct ieee80211_device *ieee,
14435 struct ieee_param *param, int plen)
14436 {
14437 u8 *buf;
14438 @@ -2267,16 +2315,16 @@
14439 ieee->wpa_ie_len = 0;
14440 }
14441  
14442 - ieee80211_wpa_assoc_frame(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
14443 + ieee80211_wpa_assoc_frame_rtl7(ieee, ieee->wpa_ie, ieee->wpa_ie_len);
14444 return 0;
14445 }
14446  
14447 #define AUTH_ALG_OPEN_SYSTEM 0x1
14448 #define AUTH_ALG_SHARED_KEY 0x2
14449  
14450 -static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value)
14451 +static int ieee80211_wpa_set_auth_algs_rtl7(struct ieee80211_device *ieee, int value)
14452 {
14453 -
14454 +
14455 struct ieee80211_security sec = {
14456 .flags = SEC_AUTH_MODE,
14457 };
14458 @@ -2300,13 +2348,13 @@
14459  
14460  
14461  
14462 -static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value)
14463 +static int ieee80211_wpa_set_param_rtl7(struct ieee80211_device *ieee, u8 name, u32 value)
14464 {
14465 int ret=0;
14466  
14467 switch (name) {
14468 case IEEE_PARAM_WPA_ENABLED:
14469 - ret = ieee80211_wpa_enable(ieee, value);
14470 + ret = ieee80211_wpa_enable_rtl7(ieee, value);
14471 break;
14472  
14473 case IEEE_PARAM_TKIP_COUNTERMEASURES:
14474 @@ -2351,7 +2399,7 @@
14475 break;
14476  
14477 case IEEE_PARAM_AUTH_ALGS:
14478 - ret = ieee80211_wpa_set_auth_algs(ieee, value);
14479 + ret = ieee80211_wpa_set_auth_algs_rtl7(ieee, value);
14480 break;
14481  
14482 case IEEE_PARAM_IEEE_802_1X:
14483 @@ -2368,11 +2416,11 @@
14484  
14485 /* implementation borrowed from hostap driver */
14486  
14487 -static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
14488 +static int ieee80211_wpa_set_encryption_rtl7(struct ieee80211_device *ieee,
14489 struct ieee_param *param, int param_len)
14490 {
14491 int ret = 0;
14492 -
14493 +
14494 struct ieee80211_crypto_ops *ops;
14495 struct ieee80211_crypt_data **crypt;
14496  
14497 @@ -2407,7 +2455,7 @@
14498 //sec.encrypt = 0;
14499 sec.level = SEC_LEVEL_0;
14500 sec.flags |= SEC_ENABLED | SEC_LEVEL;
14501 - ieee80211_crypt_delayed_deinit(ieee, crypt);
14502 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
14503 }
14504 goto done;
14505 }
14506 @@ -2421,16 +2469,16 @@
14507 strcmp(param->u.crypt.alg, "TKIP"))
14508 goto skip_host_crypt;
14509  
14510 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
14511 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
14512 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
14513 - request_module("ieee80211_crypt_wep");
14514 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
14515 + request_module("ieee80211_crypt_wep_rtl");
14516 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
14517 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
14518 - request_module("ieee80211_crypt_tkip");
14519 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
14520 + request_module("ieee80211_crypt_tkip_rtl");
14521 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
14522 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
14523 - request_module("ieee80211_crypt_ccmp");
14524 - ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
14525 + request_module("ieee80211_crypt_ccmp_rtl");
14526 + ops = ieee80211_get_crypto_ops_rtl7(param->u.crypt.alg);
14527 }
14528 if (ops == NULL) {
14529 printk("unknown crypto alg '%s'\n", param->u.crypt.alg);
14530 @@ -2442,7 +2490,7 @@
14531 if (*crypt == NULL || (*crypt)->ops != ops) {
14532 struct ieee80211_crypt_data *new_crypt;
14533  
14534 - ieee80211_crypt_delayed_deinit(ieee, crypt);
14535 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
14536  
14537 new_crypt = (struct ieee80211_crypt_data *)
14538 kmalloc(sizeof(*new_crypt), GFP_KERNEL);
14539 @@ -2525,7 +2573,7 @@
14540  
14541  
14542  
14543 -int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p)
14544 +int ieee80211_wpa_supplicant_ioctl_rtl7(struct ieee80211_device *ieee, struct iw_point *p)
14545 {
14546 struct ieee_param *param;
14547 int ret=0;
14548 @@ -2537,7 +2585,7 @@
14549 ret = -EINVAL;
14550 goto out;
14551 }
14552 -
14553 +
14554 param = (struct ieee_param *)kmalloc(p->length, GFP_KERNEL);
14555 if (param == NULL){
14556 ret = -ENOMEM;
14557 @@ -2552,20 +2600,20 @@
14558 switch (param->cmd) {
14559  
14560 case IEEE_CMD_SET_WPA_PARAM:
14561 - ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name,
14562 + ret = ieee80211_wpa_set_param_rtl7(ieee, param->u.wpa_param.name,
14563 param->u.wpa_param.value);
14564 break;
14565  
14566 case IEEE_CMD_SET_WPA_IE:
14567 - ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length);
14568 + ret = ieee80211_wpa_set_wpa_ie_rtl7(ieee, param, p->length);
14569 break;
14570  
14571 case IEEE_CMD_SET_ENCRYPTION:
14572 - ret = ieee80211_wpa_set_encryption(ieee, param, p->length);
14573 + ret = ieee80211_wpa_set_encryption_rtl7(ieee, param, p->length);
14574 break;
14575  
14576 case IEEE_CMD_MLME:
14577 - ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command,
14578 + ret = ieee80211_wpa_mlme_rtl7(ieee, param->u.mlme.command,
14579 param->u.mlme.reason_code);
14580 break;
14581  
14582 @@ -2581,11 +2629,11 @@
14583 kfree(param);
14584 out:
14585 up(&ieee->wx_sem);
14586 -
14587 +
14588 return ret;
14589 }
14590  
14591 -void notify_wx_assoc_event(struct ieee80211_device *ieee)
14592 +void notify_wx_assoc_event_rtl7(struct ieee80211_device *ieee)
14593 {
14594 union iwreq_data wrqu;
14595 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
14596 @@ -2597,14 +2645,14 @@
14597 }
14598  
14599  
14600 -EXPORT_SYMBOL(ieee80211_get_beacon);
14601 -EXPORT_SYMBOL(ieee80211_wake_queue);
14602 -EXPORT_SYMBOL(ieee80211_stop_queue);
14603 -EXPORT_SYMBOL(ieee80211_reset_queue);
14604 -EXPORT_SYMBOL(ieee80211_softmac_stop_protocol);
14605 -EXPORT_SYMBOL(ieee80211_softmac_start_protocol);
14606 -EXPORT_SYMBOL(ieee80211_is_shortslot);
14607 -EXPORT_SYMBOL(ieee80211_is_54g);
14608 -EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl);
14609 -EXPORT_SYMBOL(ieee80211_ps_tx_ack);
14610 -//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame);
14611 +EXPORT_SYMBOL(ieee80211_get_beacon_rtl7);
14612 +EXPORT_SYMBOL(ieee80211_wake_queue_rtl7);
14613 +EXPORT_SYMBOL(ieee80211_stop_queue_rtl7);
14614 +EXPORT_SYMBOL(ieee80211_reset_queue_rtl7);
14615 +EXPORT_SYMBOL(ieee80211_softmac_stop_protocol_rtl7);
14616 +EXPORT_SYMBOL(ieee80211_softmac_start_protocol_rtl7);
14617 +EXPORT_SYMBOL(ieee80211_is_shortslot_rtl7);
14618 +EXPORT_SYMBOL(ieee80211_is_54g_rtl7);
14619 +EXPORT_SYMBOL(ieee80211_wpa_supplicant_ioctl_rtl7);
14620 +EXPORT_SYMBOL(ieee80211_ps_tx_ack_rtl7);
14621 +//EXPORT_SYMBOL(ieee80211_sta_ps_send_null_frame_rtl7);
14622 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c
14623 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_softmac_wx.c 2006-06-05 22:57:54.000000000 -0400
14624 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.c 2008-08-12 13:11:33.000000000 -0400
14625 @@ -1,7 +1,7 @@
14626 /* IEEE 802.11 SoftMAC layer
14627 * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it>
14628 *
14629 - * Mostly extracted from the rtl8180-sa2400 driver for the
14630 + * Mostly extracted from the rtl8180-sa2400 driver for the
14631 * in-kernel generic ieee802.11 stack.
14632 *
14633 * Some pieces of code might be stolen from ipw2100 driver
14634 @@ -18,23 +18,23 @@
14635  
14636 /* FIXME: add A freqs */
14637  
14638 -const long ieee80211_wlan_frequencies[] = {
14639 - 2412, 2417, 2422, 2427,
14640 - 2432, 2437, 2442, 2447,
14641 - 2452, 2457, 2462, 2467,
14642 - 2472, 2484
14643 +const long ieee80211_wlan_frequencies_rtl7[] = {
14644 + 2412, 2417, 2422, 2427,
14645 + 2432, 2437, 2442, 2447,
14646 + 2452, 2457, 2462, 2467,
14647 + 2472, 2484
14648 };
14649  
14650  
14651 -int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a,
14652 +int ieee80211_wx_set_freq_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
14653 union iwreq_data *wrqu, char *b)
14654 {
14655 int ret;
14656 struct iw_freq *fwrq = & wrqu->freq;
14657  
14658 down(&ieee->wx_sem);
14659 -
14660 - if(ieee->iw_mode == IW_MODE_INFRA){
14661 +
14662 + if(ieee->iw_mode == IW_MODE_INFRA){
14663 ret = -EOPNOTSUPP;
14664 goto out;
14665 }
14666 @@ -45,31 +45,31 @@
14667 fwrq->m <= (int) 2.487e8)) {
14668 int f = fwrq->m / 100000;
14669 int c = 0;
14670 -
14671 - while ((c < 14) && (f != ieee80211_wlan_frequencies[c]))
14672 +
14673 + while ((c < 14) && (f != ieee80211_wlan_frequencies_rtl7[c]))
14674 c++;
14675 -
14676 +
14677 /* hack to fall through */
14678 fwrq->e = 0;
14679 fwrq->m = c + 1;
14680 }
14681 }
14682 -
14683 - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
14684 +
14685 + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){
14686 ret = -EOPNOTSUPP;
14687 goto out;
14688 -
14689 +
14690 }else { /* Set the channel */
14691 -
14692 -
14693 +
14694 +
14695 ieee->current_network.channel = fwrq->m;
14696 ieee->set_chan(ieee->dev, ieee->current_network.channel);
14697 -
14698 +
14699 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
14700 if(ieee->state == IEEE80211_LINKED){
14701 -
14702 - ieee80211_stop_send_beacons(ieee);
14703 - ieee80211_start_send_beacons(ieee);
14704 +
14705 + ieee80211_stop_send_beacons_rtl7(ieee);
14706 + ieee80211_start_send_beacons_rtl7(ieee);
14707 }
14708 }
14709  
14710 @@ -80,7 +80,7 @@
14711 }
14712  
14713  
14714 -int ieee80211_wx_get_freq(struct ieee80211_device *ieee,
14715 +int ieee80211_wx_get_freq_rtl7(struct ieee80211_device *ieee,
14716 struct iw_request_info *a,
14717 union iwreq_data *wrqu, char *b)
14718 {
14719 @@ -88,110 +88,110 @@
14720  
14721 if (ieee->current_network.channel == 0)
14722 return -1;
14723 -
14724 +
14725 fwrq->m = ieee->current_network.channel;
14726 fwrq->e = 0;
14727 -
14728 +
14729 return 0;
14730 }
14731  
14732 -int ieee80211_wx_get_wap(struct ieee80211_device *ieee,
14733 - struct iw_request_info *info,
14734 +int ieee80211_wx_get_wap_rtl7(struct ieee80211_device *ieee,
14735 + struct iw_request_info *info,
14736 union iwreq_data *wrqu, char *extra)
14737 {
14738 - unsigned long flags;
14739 -
14740 + unsigned long flags;
14741 +
14742 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
14743 -
14744 +
14745 if (ieee->iw_mode == IW_MODE_MONITOR)
14746 return -1;
14747 -
14748 +
14749 /* We want avoid to give to the user inconsistent infos*/
14750 spin_lock_irqsave(&ieee->lock, flags);
14751 -
14752 - if (ieee->state != IEEE80211_LINKED &&
14753 +
14754 + if (ieee->state != IEEE80211_LINKED &&
14755 ieee->state != IEEE80211_LINKED_SCANNING &&
14756 ieee->wap_set == 0)
14757 -
14758 +
14759 memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN);
14760 else
14761 - memcpy(wrqu->ap_addr.sa_data,
14762 + memcpy(wrqu->ap_addr.sa_data,
14763 ieee->current_network.bssid, ETH_ALEN);
14764 -
14765 +
14766 spin_unlock_irqrestore(&ieee->lock, flags);
14767 -
14768 +
14769 return 0;
14770 }
14771  
14772  
14773 -int ieee80211_wx_set_wap(struct ieee80211_device *ieee,
14774 +int ieee80211_wx_set_wap_rtl7(struct ieee80211_device *ieee,
14775 struct iw_request_info *info,
14776 union iwreq_data *awrq,
14777 char *extra)
14778 {
14779 -
14780 +
14781 int ret = 0;
14782 u8 zero[] = {0,0,0,0,0,0};
14783 unsigned long flags;
14784 -
14785 +
14786 + struct sockaddr *temp = NULL;
14787 short ifup = ieee->proto_started;//dev->flags & IFF_UP;
14788 -
14789 +
14790 ieee->sync_scan_hurryup = 1;
14791 -
14792 +
14793 down(&ieee->wx_sem);
14794 -
14795 - struct sockaddr *temp = (struct sockaddr *)awrq;
14796 -
14797 +
14798 + temp = (struct sockaddr *)awrq;
14799 /* use ifconfig hw ether */
14800 if (ieee->iw_mode == IW_MODE_MASTER){
14801 ret = -1;
14802 goto out;
14803 }
14804 -
14805 +
14806 if (temp->sa_family != ARPHRD_ETHER){
14807 ret = -EINVAL;
14808 goto out;
14809 }
14810 -
14811 +
14812 if (ifup)
14813 - ieee80211_stop_protocol(ieee);
14814 -
14815 + ieee80211_stop_protocol_rtl7(ieee);
14816 +
14817 /* just to avoid to give inconsistent infos in the
14818 - * get wx method. not really needed otherwise
14819 + * get wx method. not really needed otherwise
14820 */
14821 spin_lock_irqsave(&ieee->lock, flags);
14822 -
14823 - memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
14824 +
14825 + memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
14826 ieee->wap_set = memcmp(temp->sa_data, zero,ETH_ALEN)!=0;
14827 -
14828 +
14829 spin_unlock_irqrestore(&ieee->lock, flags);
14830 -
14831 +
14832 if (ifup)
14833 - ieee80211_start_protocol(ieee);
14834 -
14835 + ieee80211_start_protocol_rtl7(ieee);
14836 +
14837 out:
14838 up(&ieee->wx_sem);
14839 return ret;
14840 }
14841 -
14842 - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
14843 +
14844 + int ieee80211_wx_get_essid_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b)
14845 {
14846 int len,ret = 0;
14847 unsigned long flags;
14848 -
14849 +
14850 if (ieee->iw_mode == IW_MODE_MONITOR)
14851 return -1;
14852 -
14853 - /* We want avoid to give to the user inconsistent infos*/
14854 +
14855 + /* We want avoid to give to the user inconsistent infos*/
14856 spin_lock_irqsave(&ieee->lock, flags);
14857 -
14858 +
14859 if (ieee->current_network.ssid[0] == '\0' ||
14860 - ieee->current_network.ssid_len == 0){
14861 + ieee->current_network.ssid_len == 0){
14862 ret = -1;
14863 goto out;
14864 }
14865 -
14866 - if (ieee->state != IEEE80211_LINKED &&
14867 +
14868 + if (ieee->state != IEEE80211_LINKED &&
14869 ieee->state != IEEE80211_LINKED_SCANNING &&
14870 ieee->ssid_set == 0){
14871 ret = -1;
14872 @@ -204,59 +204,76 @@
14873  
14874 out:
14875 spin_unlock_irqrestore(&ieee->lock, flags);
14876 -
14877 +
14878 return ret;
14879 -
14880 +
14881 }
14882  
14883 -int ieee80211_wx_set_rate(struct ieee80211_device *ieee,
14884 +int ieee80211_wx_set_rate_rtl7(struct ieee80211_device *ieee,
14885 struct iw_request_info *info,
14886 union iwreq_data *wrqu, char *extra)
14887 {
14888  
14889 u32 target_rate = wrqu->bitrate.value;
14890 -
14891 +
14892 ieee->rate = target_rate/100000;
14893 //FIXME: we might want to limit rate also in management protocols.
14894 - return 0;
14895 + return 0;
14896 }
14897  
14898  
14899  
14900 -int ieee80211_wx_get_rate(struct ieee80211_device *ieee,
14901 - struct iw_request_info *info,
14902 +int ieee80211_wx_get_rate_rtl7(struct ieee80211_device *ieee,
14903 + struct iw_request_info *info,
14904 union iwreq_data *wrqu, char *extra)
14905 {
14906 -
14907 +
14908 wrqu->bitrate.value = ieee->rate * 100000;
14909 -
14910 +
14911 return 0;
14912 }
14913  
14914 -int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
14915 +int ieee80211_wx_set_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
14916 union iwreq_data *wrqu, char *b)
14917 {
14918 -
14919 + short prev = ieee->raw_tx;
14920 +
14921 ieee->sync_scan_hurryup = 1;
14922 -
14923 +
14924 down(&ieee->wx_sem);
14925 -
14926 +
14927 if (wrqu->mode == ieee->iw_mode)
14928 goto out;
14929 -
14930 +
14931 if (wrqu->mode == IW_MODE_MONITOR){
14932 -
14933 - ieee->dev->type = ARPHRD_IEEE80211;
14934 + ieee->dev->type = ARPHRD_IEEE80211_PRISM;
14935 }else{
14936 ieee->dev->type = ARPHRD_ETHER;
14937 }
14938 -
14939 +
14940 if (!ieee->proto_started){
14941 ieee->iw_mode = wrqu->mode;
14942 }else{
14943 - ieee80211_stop_protocol(ieee);
14944 + ieee80211_stop_protocol_rtl7(ieee);
14945 ieee->iw_mode = wrqu->mode;
14946 - ieee80211_start_protocol(ieee);
14947 + ieee80211_start_protocol_rtl7(ieee);
14948 + }
14949 +
14950 + if(ieee->iw_mode == IW_MODE_MONITOR)
14951 + {
14952 + ieee->raw_tx = 1;
14953 + if(prev == 0 && ieee->raw_tx){
14954 + if (ieee->data_hard_resume)
14955 + ieee->data_hard_resume(ieee->dev);
14956 +
14957 + netif_carrier_on(ieee->dev);
14958 + }
14959 +
14960 + netif_carrier_on(ieee->dev);
14961 + }
14962 + else
14963 + {
14964 + ieee->raw_tx = 0;
14965 }
14966  
14967 out:
14968 @@ -264,120 +281,132 @@
14969 return 0;
14970 }
14971  
14972 -void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee)
14973 +# if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
14974 +void ieee80211_wx_sync_scan_wq_rtl7(struct work_struct *work)
14975 {
14976 + struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq);
14977 +#else
14978 +void ieee80211_wx_sync_scan_wq_rtl7(struct ieee80211_device *ieee)
14979 +{
14980 +#endif
14981 short chan;
14982  
14983 chan = ieee->current_network.channel;
14984 -
14985 +
14986 netif_carrier_off(ieee->dev);
14987 -
14988 +
14989 if (ieee->data_hard_stop)
14990 ieee->data_hard_stop(ieee->dev);
14991 -
14992 - ieee80211_stop_send_beacons(ieee);
14993 -
14994 +
14995 + ieee80211_stop_send_beacons_rtl7(ieee);
14996 +
14997 ieee->state = IEEE80211_LINKED_SCANNING;
14998 ieee->link_change(ieee->dev);
14999 -
15000 - ieee80211_start_scan_syncro(ieee);
15001 -
15002 +
15003 + ieee80211_start_scan_syncro_rtl7(ieee);
15004 +
15005 ieee->set_chan(ieee->dev, chan);
15006 -
15007 +
15008 ieee->state = IEEE80211_LINKED;
15009 ieee->link_change(ieee->dev);
15010 -
15011 +
15012 if (ieee->data_hard_resume)
15013 ieee->data_hard_resume(ieee->dev);
15014 -
15015 +
15016 if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER)
15017 - ieee80211_start_send_beacons(ieee);
15018 -
15019 + ieee80211_start_send_beacons_rtl7(ieee);
15020 +
15021 netif_carrier_on(ieee->dev);
15022 -
15023 +
15024 up(&ieee->wx_sem);
15025 -
15026 +
15027 }
15028  
15029 -int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a,
15030 +int ieee80211_wx_set_scan_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
15031 union iwreq_data *wrqu, char *b)
15032 {
15033 int ret = 0;
15034 -
15035 +
15036 down(&ieee->wx_sem);
15037 -
15038 - if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
15039 +
15040 + if (ieee->iw_mode == IW_MODE_MONITOR || !(ieee->proto_started)){
15041 ret = -1;
15042 goto out;
15043 }
15044 -
15045 +
15046 if ( ieee->state == IEEE80211_LINKED){
15047 queue_work(ieee->wq, &ieee->wx_sync_scan_wq);
15048 /* intentionally forget to up sem */
15049 return 0;
15050 }
15051 -
15052 +
15053 out:
15054 up(&ieee->wx_sem);
15055 return ret;
15056 }
15057  
15058 -int ieee80211_wx_set_essid(struct ieee80211_device *ieee,
15059 +int ieee80211_wx_set_essid_rtl7(struct ieee80211_device *ieee,
15060 struct iw_request_info *a,
15061 union iwreq_data *wrqu, char *extra)
15062 {
15063 -
15064 +
15065 int ret=0,len;
15066 short proto_started;
15067 unsigned long flags;
15068 -
15069 +
15070 ieee->sync_scan_hurryup = 1;
15071 -
15072 +
15073 down(&ieee->wx_sem);
15074 -
15075 +
15076 proto_started = ieee->proto_started;
15077 -
15078 +
15079 if (wrqu->essid.length > IW_ESSID_MAX_SIZE){
15080 ret= -E2BIG;
15081 goto out;
15082 }
15083 -
15084 +
15085 if (ieee->iw_mode == IW_MODE_MONITOR){
15086 ret= -1;
15087 goto out;
15088 }
15089 -
15090 +
15091 if(proto_started)
15092 - ieee80211_stop_protocol(ieee);
15093 -
15094 + ieee80211_stop_protocol_rtl7(ieee);
15095 +
15096 /* this is just to be sure that the GET wx callback
15097 * has consisten infos. not needed otherwise
15098 */
15099 spin_lock_irqsave(&ieee->lock, flags);
15100 -
15101 +
15102 if (wrqu->essid.flags && wrqu->essid.length) {
15103 +#if WIRELESS_EXT > 20
15104 + len = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
15105 +#else
15106 len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE;
15107 -
15108 +#endif
15109 +
15110 strncpy(ieee->current_network.ssid, extra, len);
15111 ieee->current_network.ssid_len = len;
15112 ieee->ssid_set = 1;
15113 }
15114 - else{
15115 + else{
15116 ieee->ssid_set = 0;
15117 ieee->current_network.ssid[0] = '\0';
15118 ieee->current_network.ssid_len = 0;
15119 }
15120 -
15121 +
15122 spin_unlock_irqrestore(&ieee->lock, flags);
15123 -
15124 +
15125 if (proto_started)
15126 - ieee80211_start_protocol(ieee);
15127 + ieee80211_start_protocol_rtl7(ieee);
15128 out:
15129 up(&ieee->wx_sem);
15130 +
15131 +
15132 return ret;
15133 }
15134  
15135 - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a,
15136 + int ieee80211_wx_get_mode_rtl7(struct ieee80211_device *ieee, struct iw_request_info *a,
15137 union iwreq_data *wrqu, char *b)
15138 {
15139  
15140 @@ -385,23 +414,23 @@
15141 return 0;
15142 }
15143  
15144 - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee,
15145 - struct iw_request_info *info,
15146 + int ieee80211_wx_set_rawtx_rtl7(struct ieee80211_device *ieee,
15147 + struct iw_request_info *info,
15148 union iwreq_data *wrqu, char *extra)
15149 {
15150 -
15151 +
15152 int *parms = (int *)extra;
15153 int enable = (parms[0] > 0);
15154 short prev = ieee->raw_tx;
15155  
15156 down(&ieee->wx_sem);
15157 -
15158 - if(enable)
15159 +
15160 + if(enable)
15161 ieee->raw_tx = 1;
15162 - else
15163 + else
15164 ieee->raw_tx = 0;
15165  
15166 - printk(KERN_INFO"raw TX is %s\n",
15167 + printk(KERN_INFO"raw TX is %s\n",
15168 ieee->raw_tx ? "enabled" : "disabled");
15169  
15170 if(ieee->iw_mode == IW_MODE_MONITOR)
15171 @@ -409,21 +438,21 @@
15172 if(prev == 0 && ieee->raw_tx){
15173 if (ieee->data_hard_resume)
15174 ieee->data_hard_resume(ieee->dev);
15175 -
15176 - netif_carrier_on(ieee->dev);
15177 +
15178 + netif_carrier_on(ieee->dev);
15179 }
15180 -
15181 +
15182 if(prev && ieee->raw_tx == 1)
15183 - netif_carrier_off(ieee->dev);
15184 + netif_carrier_off(ieee->dev);
15185 }
15186 -
15187 +
15188 up(&ieee->wx_sem);
15189 -
15190 +
15191 return 0;
15192 }
15193 -
15194 -int ieee80211_wx_get_name(struct ieee80211_device *ieee,
15195 - struct iw_request_info *info,
15196 +
15197 +int ieee80211_wx_get_name_rtl7(struct ieee80211_device *ieee,
15198 + struct iw_request_info *info,
15199 union iwreq_data *wrqu, char *extra)
15200 {
15201 strcpy(wrqu->name, "802.11");
15202 @@ -433,20 +462,20 @@
15203 strcat(wrqu->name, "/g");
15204 }else if(ieee->modulation & IEEE80211_OFDM_MODULATION)
15205 strcat(wrqu->name, "g");
15206 -
15207 - if((ieee->state == IEEE80211_LINKED) ||
15208 +
15209 + if((ieee->state == IEEE80211_LINKED) ||
15210 (ieee->state == IEEE80211_LINKED_SCANNING))
15211 strcat(wrqu->name," linked");
15212 else if(ieee->state != IEEE80211_NOLINK)
15213 strcat(wrqu->name," link..");
15214 -
15215 -
15216 +
15217 +
15218 return 0;
15219 }
15220  
15221  
15222 /* this is mostly stolen from hostap */
15223 -int ieee80211_wx_set_power(struct ieee80211_device *ieee,
15224 +int ieee80211_wx_set_power_rtl7(struct ieee80211_device *ieee,
15225 struct iw_request_info *info,
15226 union iwreq_data *wrqu, char *extra)
15227 {
15228 @@ -457,50 +486,50 @@
15229 (!ieee->ps_request_tx_ack) ||
15230 (!ieee->enter_sleep_state) ||
15231 (!ieee->ps_is_queue_empty)){
15232 -
15233 +
15234 printk("ERROR. PS mode is tryied to be use but\
15235 -driver missed a callback\n\n");
15236 -
15237 +driver missed a callback\n\n");
15238 +
15239 return -1;
15240 }
15241 -
15242 +
15243 down(&ieee->wx_sem);
15244 -
15245 +
15246 if (wrqu->power.disabled){
15247 ieee->ps = IEEE80211_PS_DISABLED;
15248 -
15249 +
15250 goto exit;
15251 }
15252 switch (wrqu->power.flags & IW_POWER_MODE) {
15253 case IW_POWER_UNICAST_R:
15254 ieee->ps = IEEE80211_PS_UNICAST;
15255 -
15256 +
15257 break;
15258 case IW_POWER_ALL_R:
15259 - ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
15260 + ieee->ps = IEEE80211_PS_UNICAST | IEEE80211_PS_MBCAST;
15261 break;
15262 -
15263 +
15264 case IW_POWER_ON:
15265 ieee->ps = IEEE80211_PS_DISABLED;
15266 break;
15267 -
15268 +
15269 default:
15270 ret = -EINVAL;
15271 goto exit;
15272 }
15273  
15274 if (wrqu->power.flags & IW_POWER_TIMEOUT) {
15275 -
15276 +
15277 ieee->ps_timeout = wrqu->power.value / 1000;
15278 printk("Timeout %d\n",ieee->ps_timeout);
15279 }
15280 -
15281 +
15282 if (wrqu->power.flags & IW_POWER_PERIOD) {
15283 -
15284 +
15285 ret = -EOPNOTSUPP;
15286 goto exit;
15287 //wrq->value / 1024;
15288 -
15289 +
15290 }
15291 exit:
15292 up(&ieee->wx_sem);
15293 @@ -509,15 +538,15 @@
15294 }
15295  
15296 /* this is stolen from hostap */
15297 -int ieee80211_wx_get_power(struct ieee80211_device *ieee,
15298 +int ieee80211_wx_get_power_rtl7(struct ieee80211_device *ieee,
15299 struct iw_request_info *info,
15300 union iwreq_data *wrqu, char *extra)
15301 {
15302 int ret =0;
15303 -
15304 +
15305 down(&ieee->wx_sem);
15306 -
15307 - if(ieee->ps == IEEE80211_PS_DISABLED){
15308 +
15309 + if(ieee->ps == IEEE80211_PS_DISABLED){
15310 wrqu->power.disabled = 1;
15311 goto exit;
15312 }
15313 @@ -547,19 +576,19 @@
15314  
15315 }
15316  
15317 -EXPORT_SYMBOL(ieee80211_wx_get_essid);
15318 -EXPORT_SYMBOL(ieee80211_wx_set_essid);
15319 -EXPORT_SYMBOL(ieee80211_wx_set_rate);
15320 -EXPORT_SYMBOL(ieee80211_wx_get_rate);
15321 -EXPORT_SYMBOL(ieee80211_wx_set_wap);
15322 -EXPORT_SYMBOL(ieee80211_wx_get_wap);
15323 -EXPORT_SYMBOL(ieee80211_wx_set_mode);
15324 -EXPORT_SYMBOL(ieee80211_wx_get_mode);
15325 -EXPORT_SYMBOL(ieee80211_wx_set_scan);
15326 -EXPORT_SYMBOL(ieee80211_wx_get_freq);
15327 -EXPORT_SYMBOL(ieee80211_wx_set_freq);
15328 -EXPORT_SYMBOL(ieee80211_wx_set_rawtx);
15329 -EXPORT_SYMBOL(ieee80211_wx_get_name);
15330 -EXPORT_SYMBOL(ieee80211_wx_set_power);
15331 -EXPORT_SYMBOL(ieee80211_wx_get_power);
15332 -EXPORT_SYMBOL(ieee80211_wlan_frequencies);
15333 +EXPORT_SYMBOL(ieee80211_wx_get_essid_rtl7);
15334 +EXPORT_SYMBOL(ieee80211_wx_set_essid_rtl7);
15335 +EXPORT_SYMBOL(ieee80211_wx_set_rate_rtl7);
15336 +EXPORT_SYMBOL(ieee80211_wx_get_rate_rtl7);
15337 +EXPORT_SYMBOL(ieee80211_wx_set_wap_rtl7);
15338 +EXPORT_SYMBOL(ieee80211_wx_get_wap_rtl7);
15339 +EXPORT_SYMBOL(ieee80211_wx_set_mode_rtl7);
15340 +EXPORT_SYMBOL(ieee80211_wx_get_mode_rtl7);
15341 +EXPORT_SYMBOL(ieee80211_wx_set_scan_rtl7);
15342 +EXPORT_SYMBOL(ieee80211_wx_get_freq_rtl7);
15343 +EXPORT_SYMBOL(ieee80211_wx_set_freq_rtl7);
15344 +EXPORT_SYMBOL(ieee80211_wx_set_rawtx_rtl7);
15345 +EXPORT_SYMBOL(ieee80211_wx_get_name_rtl7);
15346 +EXPORT_SYMBOL(ieee80211_wx_set_power_rtl7);
15347 +EXPORT_SYMBOL(ieee80211_wx_get_power_rtl7);
15348 +EXPORT_SYMBOL(ieee80211_wlan_frequencies_rtl7);
15349 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_tx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c
15350 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_tx.c 2006-06-05 22:57:54.000000000 -0400
15351 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.c 2008-08-12 13:11:33.000000000 -0400
15352 @@ -24,15 +24,14 @@
15353  
15354 ******************************************************************************
15355  
15356 - Few modifications for Realtek's Wi-Fi drivers by
15357 + Few modifications for Realtek's Wi-Fi drivers by
15358 Andrea Merello <andreamrl@tiscali.it>
15359 -
15360 - A special thanks goes to Realtek for their support !
15361 +
15362 + A special thanks goes to Realtek for their support !
15363  
15364 ******************************************************************************/
15365  
15366 #include <linux/compiler.h>
15367 -#include <linux/config.h>
15368 #include <linux/errno.h>
15369 #include <linux/if_arp.h>
15370 #include <linux/in6.h>
15371 @@ -52,6 +51,12 @@
15372 #include <linux/etherdevice.h>
15373 #include <asm/uaccess.h>
15374  
15375 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
15376 +#include <linux/config.h>
15377 +#else
15378 +#include <linux/autoconf.h>
15379 +#endif
15380 +
15381 #include "ieee80211.h"
15382  
15383  
15384 @@ -155,7 +160,7 @@
15385 static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
15386 static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
15387  
15388 -static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
15389 +static inline int ieee80211_put_snap_rtl7(u8 *data, u16 h_proto)
15390 {
15391 struct ieee80211_snap_hdr *snap;
15392 u8 *oui;
15393 @@ -178,7 +183,7 @@
15394 return SNAP_SIZE + sizeof(u16);
15395 }
15396  
15397 -int ieee80211_encrypt_fragment(
15398 +int ieee80211_encrypt_fragment_rtl7(
15399 struct ieee80211_device *ieee,
15400 struct sk_buff *frag,
15401 int hdr_len)
15402 @@ -225,7 +230,7 @@
15403 }
15404  
15405  
15406 -void ieee80211_txb_free(struct ieee80211_txb *txb) {
15407 +void ieee80211_txb_free_rtl7(struct ieee80211_txb *txb) {
15408 int i;
15409 if (unlikely(!txb))
15410 return;
15411 @@ -235,7 +240,7 @@
15412 kfree(txb);
15413 }
15414  
15415 -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
15416 +struct ieee80211_txb *ieee80211_alloc_txb_rtl7(int nr_frags, int txb_size,
15417 int gfp_mask)
15418 {
15419 struct ieee80211_txb *txb;
15420 @@ -267,7 +272,7 @@
15421 }
15422  
15423 /* SKBs are added to the ieee->tx_queue. */
15424 -int ieee80211_xmit(struct sk_buff *skb,
15425 +int ieee80211_xmit_rtl7(struct sk_buff *skb,
15426 struct net_device *dev)
15427 {
15428 struct ieee80211_device *ieee = netdev_priv(dev);
15429 @@ -299,27 +304,27 @@
15430 }
15431  
15432 if(likely(ieee->raw_tx == 0)){
15433 -
15434 +
15435 if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
15436 printk(KERN_WARNING "%s: skb too small (%d).\n",
15437 ieee->dev->name, skb->len);
15438 goto success;
15439 }
15440 -
15441 -
15442 +
15443 +
15444 ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
15445 -
15446 +
15447 crypt = ieee->crypt[ieee->tx_keyidx];
15448 -
15449 +
15450 encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
15451 ieee->host_encrypt && crypt && crypt->ops;
15452 -
15453 +
15454 if (!encrypt && ieee->ieee802_1x &&
15455 ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
15456 stats->tx_dropped++;
15457 goto success;
15458 }
15459 -
15460 +
15461 #ifdef CONFIG_IEEE80211_DEBUG
15462 if (crypt && !encrypt && ether_type == ETH_P_PAE) {
15463 struct eapol *eap = (struct eapol *)(skb->data +
15464 @@ -328,23 +333,23 @@
15465 eap_get_type(eap->type));
15466 }
15467 #endif
15468 -
15469 +
15470 /* Save source and destination addresses */
15471 memcpy(&dest, skb->data, ETH_ALEN);
15472 memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
15473 -
15474 +
15475 /* Advance the SKB to the start of the payload */
15476 skb_pull(skb, sizeof(struct ethhdr));
15477 -
15478 +
15479 /* Determine total amount of storage required for TXB packets */
15480 bytes = skb->len + SNAP_SIZE + sizeof(u16);
15481 -
15482 +
15483 if (encrypt)
15484 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
15485 IEEE80211_FCTL_WEP;
15486 else
15487 fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
15488 -
15489 +
15490 if (ieee->iw_mode == IW_MODE_INFRA) {
15491 fc |= IEEE80211_FCTL_TODS;
15492 /* To DS: Addr1 = BSSID, Addr2 = SA,
15493 @@ -360,9 +365,9 @@
15494 memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN);
15495 }
15496 header.frame_ctl = cpu_to_le16(fc);
15497 -
15498 +
15499 hdr_len = IEEE80211_3ADDR_LEN;
15500 -
15501 +
15502 /* Determine fragmentation size based on destination (multicast
15503 * and broadcast are not fragmented) */
15504 if (is_multicast_ether_addr(dest) ||
15505 @@ -370,7 +375,7 @@
15506 frag_size = MAX_FRAG_THRESHOLD;
15507 else
15508 frag_size = ieee->fts;
15509 -
15510 +
15511 /* Determine amount of payload per fragment. Regardless of if
15512 * this stack is providing the full 802.11 header, one will
15513 * eventually be affixed to this fragment -- so we must account for
15514 @@ -379,12 +384,12 @@
15515 if (ieee->config &
15516 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
15517 bytes_per_frag -= IEEE80211_FCS_LEN;
15518 -
15519 +
15520 /* Each fragment may need to have room for encryptiong pre/postfix */
15521 if (encrypt)
15522 bytes_per_frag -= crypt->ops->extra_prefix_len +
15523 crypt->ops->extra_postfix_len;
15524 -
15525 +
15526 /* Number of fragments is the total bytes_per_frag /
15527 * payload_per_fragment */
15528 nr_frags = bytes / bytes_per_frag;
15529 @@ -393,11 +398,11 @@
15530 nr_frags++;
15531 else
15532 bytes_last_frag = bytes_per_frag;
15533 -
15534 +
15535 /* When we allocate the TXB we allocate enough space for the reserve
15536 * and full fragment bytes (bytes_per_frag doesn't include prefix,
15537 * postfix, header, FCS, etc.) */
15538 - txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
15539 + txb = ieee80211_alloc_txb_rtl7(nr_frags, frag_size, GFP_ATOMIC);
15540 if (unlikely(!txb)) {
15541 printk(KERN_WARNING "%s: Could not allocate TXB\n",
15542 ieee->dev->name);
15543 @@ -405,93 +410,94 @@
15544 }
15545 txb->encrypted = encrypt;
15546 txb->payload_size = bytes;
15547 -
15548 +
15549 for (i = 0; i < nr_frags; i++) {
15550 skb_frag = txb->fragments[i];
15551 -
15552 +
15553 if (encrypt)
15554 skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
15555 -
15556 +
15557 frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
15558 memcpy(frag_hdr, &header, hdr_len);
15559 -
15560 +
15561 /* If this is not the last fragment, then add the MOREFRAGS
15562 * bit to the frame control */
15563 if (i != nr_frags - 1) {
15564 frag_hdr->frame_ctl = cpu_to_le16(
15565 fc | IEEE80211_FCTL_MOREFRAGS);
15566 bytes = bytes_per_frag;
15567 -
15568 +
15569 } else {
15570 /* The last fragment takes the remaining length */
15571 bytes = bytes_last_frag;
15572 }
15573 -
15574 +
15575 frag_hdr->seq_ctl = cpu_to_le16(ieee->seq_ctrl<<4 | i);
15576 -
15577 -
15578 +
15579 +
15580 /* Put a SNAP header on the first fragment */
15581 if (i == 0) {
15582 - ieee80211_put_snap(
15583 + ieee80211_put_snap_rtl7(
15584 skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
15585 ether_type);
15586 bytes -= SNAP_SIZE + sizeof(u16);
15587 }
15588 -
15589 +
15590 memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
15591 -
15592 +
15593 /* Advance the SKB... */
15594 skb_pull(skb, bytes);
15595 -
15596 +
15597 /* Encryption routine will move the header forward in order
15598 * to insert the IV between the header and the payload */
15599 if (encrypt)
15600 - ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
15601 + ieee80211_encrypt_fragment_rtl7(ieee, skb_frag, hdr_len);
15602 if (ieee->config &
15603 (CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
15604 skb_put(skb_frag, 4);
15605 }
15606 - // Advance sequence number in data frame.
15607 + // Advance sequence number in data frame.
15608 if (ieee->seq_ctrl == 0xFFF)
15609 ieee->seq_ctrl = 0;
15610 else
15611 ieee->seq_ctrl++;
15612 //---
15613 }else{
15614 - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
15615 +// if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
15616 + if (unlikely(skb->len < 14)) {
15617 printk(KERN_WARNING "%s: skb too small (%d).\n",
15618 ieee->dev->name, skb->len);
15619 goto success;
15620 }
15621 -
15622 - txb = ieee80211_alloc_txb(1, skb->len, GFP_ATOMIC);
15623 +
15624 + txb = ieee80211_alloc_txb_rtl7(1, skb->len, GFP_ATOMIC);
15625 if(!txb){
15626 printk(KERN_WARNING "%s: Could not allocate TXB\n",
15627 ieee->dev->name);
15628 goto failed;
15629 }
15630 -
15631 +
15632 txb->encrypted = 0;
15633 txb->payload_size = skb->len;
15634 memcpy(skb_put(txb->fragments[0],skb->len), skb->data, skb->len);
15635 - }
15636 + }
15637  
15638 success:
15639 spin_unlock_irqrestore(&ieee->lock, flags);
15640 dev_kfree_skb_any(skb);
15641 if (txb) {
15642 if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE){
15643 - ieee80211_softmac_xmit(txb, ieee);
15644 + ieee80211_softmac_xmit_rtl7(txb, ieee);
15645 }else{
15646 if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
15647 stats->tx_packets++;
15648 stats->tx_bytes += txb->payload_size;
15649 return 0;
15650 }
15651 - ieee80211_txb_free(txb);
15652 + ieee80211_txb_free_rtl7(txb);
15653 }
15654 -
15655 -
15656 +
15657 +
15658 }
15659  
15660 return 0;
15661 @@ -504,4 +510,4 @@
15662  
15663 }
15664  
15665 -EXPORT_SYMBOL(ieee80211_txb_free);
15666 +EXPORT_SYMBOL(ieee80211_txb_free_rtl7);
15667 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_wx.c rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c
15668 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/ieee80211_wx.c 2006-06-05 22:57:56.000000000 -0400
15669 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.c 2008-08-12 14:23:46.000000000 -0400
15670 @@ -40,8 +40,9 @@
15671 };
15672  
15673 #define MAX_CUSTOM_LEN 64
15674 -static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
15675 - char *start, char *stop,
15676 +static inline char *ipw2100_translate_scan_rtl7(struct ieee80211_device *ieee,
15677 + struct iw_request_info *info,
15678 + char *start, char *stop,
15679 struct ieee80211_network *network)
15680 {
15681 char custom[MAX_CUSTOM_LEN];
15682 @@ -54,7 +55,11 @@
15683 iwe.cmd = SIOCGIWAP;
15684 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
15685 memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
15686 +#if WIRELESS_EXT >= 22
15687 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
15688 +#else
15689 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
15690 +#endif
15691  
15692 /* Remaining entries will be displayed in the order we provide them */
15693  
15694 @@ -63,16 +68,28 @@
15695 iwe.u.data.flags = 1;
15696 if (network->flags & NETWORK_EMPTY_ESSID) {
15697 iwe.u.data.length = sizeof("<hidden>");
15698 +#if WIRELESS_EXT >= 22
15699 + start = iwe_stream_add_point(info, start, stop, &iwe, "<hidden>");
15700 +#else
15701 start = iwe_stream_add_point(start, stop, &iwe, "<hidden>");
15702 +#endif
15703 } else {
15704 iwe.u.data.length = min(network->ssid_len, (u8)32);
15705 +#if WIRELESS_EXT >= 22
15706 + start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
15707 +#else
15708 start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
15709 +#endif
15710 }
15711  
15712 /* Add the protocol name */
15713 iwe.cmd = SIOCGIWNAME;
15714 snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]);
15715 +#if WIRELESS_EXT >= 22
15716 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN);
15717 +#else
15718 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN);
15719 +#endif
15720  
15721 /* Add mode */
15722 iwe.cmd = SIOCGIWMODE;
15723 @@ -83,8 +100,13 @@
15724 else
15725 iwe.u.mode = IW_MODE_ADHOC;
15726  
15727 +#if WIRELESS_EXT >= 22
15728 + start = iwe_stream_add_event(info, start, stop, &iwe,
15729 + IW_EV_UINT_LEN);
15730 +#else
15731 start = iwe_stream_add_event(start, stop, &iwe,
15732 IW_EV_UINT_LEN);
15733 +#endif
15734 }
15735  
15736 /* Add frequency/channel */
15737 @@ -94,7 +116,11 @@
15738 iwe.u.freq.m = network->channel;
15739 iwe.u.freq.e = 0;
15740 iwe.u.freq.i = 0;
15741 +#if WIRELESS_EXT >= 22
15742 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
15743 +#else
15744 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
15745 +#endif
15746  
15747 /* Add encryption capability */
15748 iwe.cmd = SIOCGIWENCODE;
15749 @@ -103,7 +129,11 @@
15750 else
15751 iwe.u.data.flags = IW_ENCODE_DISABLED;
15752 iwe.u.data.length = 0;
15753 +#if WIRELESS_EXT >= 22
15754 + start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid);
15755 +#else
15756 start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
15757 +#endif
15758  
15759 /* Add basic and extended rates */
15760 max_rate = 0;
15761 @@ -132,13 +162,22 @@
15762 iwe.cmd = SIOCGIWRATE;
15763 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
15764 iwe.u.bitrate.value = max_rate * 500000;
15765 +#if WIRELESS_EXT >= 22
15766 + start = iwe_stream_add_event(info, start, stop, &iwe,
15767 + IW_EV_PARAM_LEN);
15768 +#else
15769 start = iwe_stream_add_event(start, stop, &iwe,
15770 IW_EV_PARAM_LEN);
15771 +#endif
15772  
15773 iwe.cmd = IWEVCUSTOM;
15774 iwe.u.data.length = p - custom;
15775 if (iwe.u.data.length)
15776 +#if WIRELESS_EXT >= 22
15777 + start = iwe_stream_add_point(info, start, stop, &iwe, custom);
15778 +#else
15779 start = iwe_stream_add_point(start, stop, &iwe, custom);
15780 +#endif
15781  
15782 /* Add quality statistics */
15783 /* TODO: Fix these values... */
15784 @@ -154,14 +193,22 @@
15785 if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL))
15786 iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
15787  
15788 +#if WIRELESS_EXT >= 22
15789 + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
15790 +#else
15791 start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
15792 +#endif
15793  
15794 iwe.cmd = IWEVCUSTOM;
15795 p = custom;
15796  
15797 iwe.u.data.length = p - custom;
15798 if (iwe.u.data.length)
15799 +#if WIRELESS_EXT >= 22
15800 + start = iwe_stream_add_point(info, start, stop, &iwe, custom);
15801 +#else
15802 start = iwe_stream_add_point(start, stop, &iwe, custom);
15803 +#endif
15804  
15805 if (ieee->wpa_enabled && network->wpa_ie_len){
15806 char buf[MAX_WPA_IE_LEN * 2 + 30];
15807 @@ -175,7 +222,12 @@
15808 memset(&iwe, 0, sizeof(iwe));
15809 iwe.cmd = IWEVCUSTOM;
15810 iwe.u.data.length = strlen(buf);
15811 +#if WIRELESS_EXT >= 22
15812 + start = iwe_stream_add_point(info, start, stop, &iwe, buf);
15813 +#else
15814 start = iwe_stream_add_point(start, stop, &iwe, buf);
15815 +#endif
15816 +
15817 }
15818  
15819 if (ieee->wpa_enabled && network->rsn_ie_len){
15820 @@ -190,7 +242,11 @@
15821 memset(&iwe, 0, sizeof(iwe));
15822 iwe.cmd = IWEVCUSTOM;
15823 iwe.u.data.length = strlen(buf);
15824 +#if WIRELESS_EXT >= 22
15825 + start = iwe_stream_add_point(info, start, stop, &iwe, buf);
15826 +#else
15827 start = iwe_stream_add_point(start, stop, &iwe, buf);
15828 +#endif
15829 }
15830  
15831 /* Add EXTRA: Age to display seconds since last beacon/probe response
15832 @@ -201,13 +257,17 @@
15833 " Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100));
15834 iwe.u.data.length = p - custom;
15835 if (iwe.u.data.length)
15836 +#if WIRELESS_EXT >= 22
15837 + start = iwe_stream_add_point(info, start, stop, &iwe, custom);
15838 +#else
15839 start = iwe_stream_add_point(start, stop, &iwe, custom);
15840 +#endif
15841  
15842  
15843 return start;
15844 }
15845  
15846 -int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
15847 +int ieee80211_wx_get_scan_rtl7(struct ieee80211_device *ieee,
15848 struct iw_request_info *info,
15849 union iwreq_data *wrqu, char *extra)
15850 {
15851 @@ -220,13 +280,15 @@
15852  
15853 IEEE80211_DEBUG_WX("Getting scan\n");
15854 down(&ieee->wx_sem);
15855 + printk("GOT WX GET SCAN WX_SEM LOCK");
15856 spin_lock_irqsave(&ieee->lock, flags);
15857  
15858 list_for_each_entry(network, &ieee->network_list, list) {
15859 i++;
15860 if (ieee->scan_age == 0 ||
15861 time_after(network->last_scanned + ieee->scan_age, jiffies))
15862 - ev = ipw2100_translate_scan(ieee, ev, stop, network);
15863 + ev = ipw2100_translate_scan_rtl7(ieee, info, ev,
15864 +stop, network);
15865 else
15866 IEEE80211_DEBUG_SCAN(
15867 "Not showing network '%s ("
15868 @@ -247,7 +309,7 @@
15869 return 0;
15870 }
15871  
15872 -int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
15873 +int ieee80211_wx_set_encode_rtl7(struct ieee80211_device *ieee,
15874 struct iw_request_info *info,
15875 union iwreq_data *wrqu, char *keybuf)
15876 {
15877 @@ -259,6 +321,9 @@
15878 int i, key, key_provided, len;
15879 struct ieee80211_crypt_data **crypt;
15880  
15881 + if (erq->flags & IW_ENCODE_RESTRICTED)
15882 + return -EINVAL;
15883 +
15884 IEEE80211_DEBUG_WX("SET_ENCODE\n");
15885  
15886 key = erq->flags & IW_ENCODE_INDEX;
15887 @@ -281,7 +346,7 @@
15888 if (key_provided && *crypt) {
15889 IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
15890 key);
15891 - ieee80211_crypt_delayed_deinit(ieee, crypt);
15892 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
15893 } else
15894 IEEE80211_DEBUG_WX("Disabling encryption.\n");
15895  
15896 @@ -291,7 +356,7 @@
15897 if (ieee->crypt[i] != NULL) {
15898 if (key_provided)
15899 break;
15900 - ieee80211_crypt_delayed_deinit(
15901 + ieee80211_crypt_delayed_deinit_rtl7(
15902 ieee, &ieee->crypt[i]);
15903 }
15904 }
15905 @@ -314,7 +379,7 @@
15906 strcmp((*crypt)->ops->name, "WEP") != 0) {
15907 /* changing to use WEP; deinit previously used algorithm
15908 * on this key */
15909 - ieee80211_crypt_delayed_deinit(ieee, crypt);
15910 + ieee80211_crypt_delayed_deinit_rtl7(ieee, crypt);
15911 }
15912  
15913 if (*crypt == NULL) {
15914 @@ -326,10 +391,10 @@
15915 if (new_crypt == NULL)
15916 return -ENOMEM;
15917 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
15918 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
15919 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
15920 if (!new_crypt->ops) {
15921 - request_module("ieee80211_crypt_wep");
15922 - new_crypt->ops = ieee80211_get_crypto_ops("WEP");
15923 + request_module("ieee80211_crypt_wep_rtl");
15924 + new_crypt->ops = ieee80211_get_crypto_ops_rtl7("WEP");
15925 }
15926  
15927 if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
15928 @@ -340,7 +405,7 @@
15929 new_crypt = NULL;
15930  
15931 printk(KERN_WARNING "%s: could not initialize WEP: "
15932 - "load module ieee80211_crypt_wep\n",
15933 + "load module ieee80211_crypt_wep_rtl\n",
15934 dev->name);
15935 return -EOPNOTSUPP;
15936 }
15937 @@ -418,7 +483,7 @@
15938 return 0;
15939 }
15940  
15941 -int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
15942 +int ieee80211_wx_get_encode_rtl7(struct ieee80211_device *ieee,
15943 struct iw_request_info *info,
15944 union iwreq_data *wrqu, char *keybuf)
15945 {
15946 @@ -430,7 +495,7 @@
15947  
15948 if(ieee->iw_mode == IW_MODE_MONITOR)
15949 return -1;
15950 -
15951 +
15952 key = erq->flags & IW_ENCODE_INDEX;
15953 if (key) {
15954 if (key > WEP_KEYS)
15955 @@ -470,6 +535,6 @@
15956 }
15957  
15958  
15959 -EXPORT_SYMBOL(ieee80211_wx_get_scan);
15960 -EXPORT_SYMBOL(ieee80211_wx_set_encode);
15961 -EXPORT_SYMBOL(ieee80211_wx_get_encode);
15962 +EXPORT_SYMBOL(ieee80211_wx_get_scan_rtl7);
15963 +EXPORT_SYMBOL(ieee80211_wx_set_encode_rtl7);
15964 +EXPORT_SYMBOL(ieee80211_wx_get_encode_rtl7);
15965 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile
15966 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Makefile 2006-06-05 22:57:54.000000000 -0400
15967 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Makefile 2008-08-12 13:11:33.000000000 -0400
15968 @@ -17,6 +17,7 @@
15969 KVER := $(shell uname -r)
15970 KSRC := /lib/modules/$(KVER)/build
15971 INSTALL_PREFIX :=
15972 +PWD = $(shell pwd)
15973  
15974 all: modules
15975  
15976 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Modules.symvers rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers
15977 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/Modules.symvers 2006-06-05 22:57:56.000000000 -0400
15978 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/Modules.symvers 1969-12-31 19:00:00.000000000 -0500
15979 @@ -1,43 +0,0 @@
15980 -0x232e7944 ieee80211_wlan_frequencies /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15981 -0xaeae102f free_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
15982 -0x279e265f ieee80211_crypt_deinit_handler net/ieee80211/ieee80211_crypt
15983 -0xc2411d91 ieee80211_stop_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15984 -0x6ece20e1 ieee80211_wx_get_name_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
15985 -0x5d3847ff ieee80211_rx_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15986 -0x18612027 ieee80211_wx_get_scan_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15987 -0xa0e03ce1 ieee80211_wx_get_name /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15988 -0xee25f349 ieee80211_wx_get_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15989 -0x86013c3d ieee80211_wx_set_mode /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15990 -0x04493cc0 ieee80211_wx_get_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15991 -0x6c6df3b4 ieee80211_wx_set_rate /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15992 -0x82caec02 ieee80211_crypt_deinit_entries net/ieee80211/ieee80211_crypt
15993 -0x347945bf ieee80211_wx_get_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15994 -0x6379d455 ieee80211_wx_set_power /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15995 -0xae62ed59 ieee80211_wx_set_scan /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15996 -0x6621e172 ieee80211_wx_set_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15997 -0x0e052e06 ieee80211_wx_get_freq /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
15998 -0x283f9f5d ieee80211_unregister_crypto_ops net/ieee80211/ieee80211_crypt
15999 -0x9da79aac ieee80211_is_shortslot /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16000 -0x666032dc ieee80211_wx_get_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16001 -0x9f1cbe0e ieee80211_wx_set_wap /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16002 -0x73d1d341 ieee80211_wx_set_rawtx /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16003 -0x2c714184 ieee80211_is_54g /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16004 -0x6892d598 ieee80211_wpa_supplicant_ioctl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16005 -0xc062f1f5 ieee80211_ps_tx_ack /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16006 -0x55534906 ieee80211_get_beacon /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16007 -0xe2679638 ieee80211_crypt_delayed_deinit net/ieee80211/ieee80211_crypt
16008 -0x3a0456bc free_ieee80211 net/ieee80211/ieee80211
16009 -0x7e1ef2c8 ieee80211_wake_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16010 -0xc1b81e9f ieee80211_register_crypto_ops net/ieee80211/ieee80211_crypt
16011 -0x3f795a39 alloc_ieee80211 net/ieee80211/ieee80211
16012 -0x89803c23 ieee80211_get_crypto_ops net/ieee80211/ieee80211_crypt
16013 -0xc6caf2a4 ieee80211_txb_free net/ieee80211/ieee80211
16014 -0x49c1422c ieee80211_rx_mgt net/ieee80211/ieee80211
16015 -0xbf2b4ebd alloc_ieee80211_rtl /usr/rtl8187_linux_2.6_05312006/ieee80211/ieee80211-rtl
16016 -0xd155f7b8 ieee80211_softmac_stop_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16017 -0x9ce2dcde ieee80211_softmac_start_protocol /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16018 -0x00d74bba ieee80211_wx_get_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16019 -0x92b5d996 ieee80211_wx_set_encode_rtl /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16020 -0x2ac9bf95 ieee80211_wx_set_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16021 -0x7dc92e7f ieee80211_wx_get_essid /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16022 -0xd04740ca ieee80211_reset_queue /home/woo/rtl8187_linuxdrv_FC2_V1.1_Src/ieee80211/ieee80211-rtl
16023 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod
16024 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2006-06-05 22:57:54.000000000 -0400
16025 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_ccmp-rtl.mod 2008-08-12 13:11:33.000000000 -0400
16026 @@ -1,2 +1,2 @@
16027 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp-rtl.ko
16028 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_ccmp.o
16029 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp-rtl.ko
16030 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_ccmp.o
16031 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod
16032 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2006-06-05 22:57:54.000000000 -0400
16033 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt-rtl.mod 2008-08-12 13:11:33.000000000 -0400
16034 @@ -1,2 +1,2 @@
16035 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt-rtl.ko
16036 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt.o
16037 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt-rtl.ko
16038 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt.o
16039 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod
16040 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2006-06-05 22:57:54.000000000 -0400
16041 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_tkip-rtl.mod 2008-08-12 13:11:33.000000000 -0400
16042 @@ -1,2 +1,2 @@
16043 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip-rtl.ko
16044 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_tkip.o
16045 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip-rtl.ko
16046 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_tkip.o
16047 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod
16048 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2006-06-05 22:57:54.000000000 -0400
16049 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211_crypt_wep-rtl.mod 2008-08-12 13:11:33.000000000 -0400
16050 @@ -1,2 +1,2 @@
16051 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep-rtl.ko
16052 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_crypt_wep.o
16053 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep-rtl.ko
16054 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_crypt_wep.o
16055 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211-rtl.mod rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod
16056 --- rtl8187_linux_26.1010.0622.2006_orig/ieee80211/.tmp_versions/ieee80211-rtl.mod 2006-06-05 22:57:54.000000000 -0400
16057 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/.tmp_versions/ieee80211-rtl.mod 2008-08-12 13:11:33.000000000 -0400
16058 @@ -1,2 +1,2 @@
16059 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211-rtl.ko
16060 -/usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_rx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_tx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_wx.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_module.o /usr/rtl8187_linux_2.6_06012006/ieee80211/ieee80211_softmac_wx.o
16061 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211-rtl.ko
16062 +/home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_rx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_tx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_wx.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_module.o /home/pete/rtl8187_linux_26.1010.0622.2006_rawtx/ieee80211/ieee80211_softmac_wx.o
16063 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/makedrv~ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~
16064 --- rtl8187_linux_26.1010.0622.2006_orig/makedrv~ 2006-09-05 07:21:10.000000000 -0400
16065 +++ rtl8187_linux_26.1010.0622.2006_rawtx/makedrv~ 1969-12-31 19:00:00.000000000 -0500
16066 @@ -1,13 +0,0 @@
16067 -#!/bin/sh
16068 -
16069 -#tar -zxvf stack.tar.gz
16070 -#tar -zxvf drv.tar.gz
16071 -cd ieee80211
16072 -make clean
16073 -make
16074 -cd ../beta-8187
16075 -make clean
16076 -make
16077 -cd ..
16078 -
16079 -
16080 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/Makefile rtl8187_linux_26.1010.0622.2006_rawtx/Makefile
16081 --- rtl8187_linux_26.1010.0622.2006_orig/Makefile 1969-12-31 19:00:00.000000000 -0500
16082 +++ rtl8187_linux_26.1010.0622.2006_rawtx/Makefile 2008-08-12 13:11:33.000000000 -0400
16083 @@ -0,0 +1,38 @@
16084 +prefix = /lib/modules/$(shell uname -r)/kernel/drivers/net/wireless
16085 +r8187dir = $(prefix)/rtl8187
16086 +ieeedir = $(prefix)/rtl_ieee80211
16087 +
16088 +default: all
16089 +
16090 +all:
16091 + -rm -f ieee80211/Module.symvers 2>/dev/null
16092 + -rm -f ieee80211/Modules.symvers 2>/dev/null
16093 + $(MAKE) -C ieee80211 $(@)
16094 + -chmod +x symvers
16095 + -./symvers
16096 + $(MAKE) -C beta-8187 $(@)
16097 +
16098 +install:
16099 + install -d $(ieeedir)
16100 + install -d $(r8187dir)
16101 + install -m 644 ./ieee80211/*.ko $(ieeedir)
16102 + install -m 644 ./beta-8187/*.ko $(r8187dir)
16103 + -depmod -ae
16104 +
16105 +uninstall:
16106 + -rm -f $(ieeedir)/ieee80211-rtl.ko
16107 + -rm -f $(ieeedir)/ieee80211_crypt-rtl.ko
16108 + -rm -f $(ieeedir)/ieee80211_crypt_ccmp-rtl.ko
16109 + -rm -f $(ieeedir)/ieee80211_crypt_tkip-rtl.ko
16110 + -rm -f $(ieeedir)/ieee80211_crypt_wep-rtl.ko
16111 + -rm -f $(r8187dir)/r8187.ko
16112 + -rm -fr $(ieeedir)
16113 + -rm -fr $(r8187dir)
16114 + -depmod -ae
16115 +
16116 +clean:
16117 + $(MAKE) -C ieee80211 $(@)
16118 + $(MAKE) -C beta-8187 $(@)
16119 +
16120 +distclean: clean
16121 +
16122 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/ReadMe.txt~ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~
16123 --- rtl8187_linux_26.1010.0622.2006_orig/ReadMe.txt~ 2006-06-06 10:58:00.000000000 -0400
16124 +++ rtl8187_linux_26.1010.0622.2006_rawtx/ReadMe.txt~ 1969-12-31 19:00:00.000000000 -0500
16125 @@ -1,129 +0,0 @@
16126 -Release Date: 2006-01-13, ver 1.1
16127 -RTL8187 Linux driver version 1.1
16128 -
16129 - --This driver supports RealTek RTL8187 Wireless LAN driver for
16130 - Fedora Core 2/3/4/5, Debian 3.1, Mandrake 10.2/Mandriva 2006,
16131 - SUSE 9.3/10.1/10.2, Gentoo 3.1, etc.
16132 - - Support Client mode for either infrastructure or adhoc mode
16133 - - Support WEP and WPAPSK connection
16134 -
16135 -< Component >
16136 -The driver is composed of several parts:
16137 - 1. Module source code
16138 - stack.tar.gz
16139 - drv.tar.gz
16140 -
16141 - 2. Script ot build the modules
16142 - makedrv
16143 -
16144 - 3. Script to load/unload modules
16145 - wlan0up
16146 - wlan0down
16147 -
16148 - 4. Script and configuration for DHCP
16149 - wlan0dhcp
16150 - ifcfg-wlan0
16151 - 4. Supplicant source code:
16152 - wpa_supplicant-0.4.9.tar.gz
16153 -
16154 - 5. Example of supplicant configuration file:
16155 - wpa1.conf
16156 -
16157 -< Installation >
16158 -Runing the scripts can finish all operations of building up modules
16159 -from the source code and start the nic.
16160 - 1. Build up the drivers from the source code
16161 - ./makedrv
16162 -
16163 - 2. load the driver module to kernel and start up nic
16164 - ./wlan0up
16165 -
16166 -< Set wireless lan MIBs >
16167 -This driver uses Wireless Extension as an interface allowing you to set
16168 -Wireless LAN specific parameters.
16169 -
16170 -Current driver supports "iwlist" to show the device status of nic
16171 - iwlist wlan0 [parameters]
16172 -where
16173 - parameter explaination [parameters]
16174 - ----------------------- -------------
16175 - Show available chan and freq freq / channel
16176 - Show and Scan BSS and IBSS scan[ning]
16177 - Show supported bit-rate rate / bit[rate]
16178 - Show Power Management mode power
16179 -
16180 -For example:
16181 - iwlist wlan0 channel
16182 - iwlist wlan0 scan
16183 - iwlist wlan0 rate
16184 - iwlist wlan0 power
16185 -
16186 -Driver also supports "iwconfig", manipulate driver private ioctls, to set
16187 -MIBs.
16188 -
16189 - iwconfig wlan0 [parameters] [val]
16190 -where
16191 - parameter explaination [parameters] [val] constraints
16192 - ----------------------- ------------- ------------------
16193 - Connect to AP by address ap [mac_addr]
16194 - Set the essid, join (I)BSS essid [essid]
16195 - Set operation mode mode {Managed|Ad-hoc}
16196 - Set keys and security mode key/enc[ryption] {N|open|restricted|off}
16197 -
16198 -For example:
16199 - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX
16200 - iwconfig wlan0 essid "ap_name"
16201 - iwconfig wlan0 mode Ad-hoc
16202 - iwconfig wlan0 mode essid "name" mode Ad-hoc
16203 - iwconfig wlan0 key 0123456789 [2] open
16204 - iwconfig wlan0 key off
16205 - iwconfig wlan0 key restricted [3] 0123456789
16206 -
16207 -< Getting IP address >
16208 -After start up the nic, the network needs to obtain an IP address before
16209 -transmit/receive data.
16210 -This can be done by setting the static IP via "ifconfig wlan0 IP_ADDRESS"
16211 -command, or using DHCP.
16212 -
16213 -If using DHCP, setting steps is as below:
16214 - (1)connect to an AP via "iwconfig" settings
16215 - iwconfig wlan0 essid [name] or
16216 - iwconfig wlan0 ap XX:XX:XX:XX:XX:XX
16217 -
16218 - (2)run the script which run the dhclient
16219 - ./wlan0dhcp
16220 -
16221 -< WPAPSK >
16222 -WPA_SUPPLICANT help the network to communicate under the protection of WPAPSK
16223 -mechanism
16224 -
16225 - (1)Unpack source code of WPA supplicant:
16226 - tar -zxvf wpa_supplicant-0.4.9.tar.gz
16227 - cd wpa_supplicant-0.4.9
16228 -
16229 - (2)Create .config file:
16230 - cp defconfig .config
16231 -
16232 - (3)Edit .config file, uncomment the following line:
16233 - #CONFIG_DRIVER_IPW=y.
16234 -
16235 - (4)Build WPA supplicant:
16236 - make
16237 -
16238 - (5)Edit wpa_supplicant.conf to set up SSID and its passphrase.
16239 - For example, the following setting in "wpa1.conf" means SSID
16240 - to join is "BufAG54_Ch6" and its passphrase is "87654321".
16241 - network={
16242 - ssid="BufAG54_Ch6"
16243 - proto=WPA
16244 - key_mgmt=WPA-PSK
16245 - pairwise=CCMP TKIP
16246 - group=CCMP TKIP WEP104 WEP40
16247 - psk="87654321"
16248 - priority=2
16249 - }
16250 -
16251 - (6)Execute WPA supplicant (Assume 8187 and related modules had been
16252 - loaded):
16253 - ./wpa_supplicant -D ipw -c wpa1.conf -i wlan0 &
16254 -
16255 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/symvers rtl8187_linux_26.1010.0622.2006_rawtx/symvers
16256 --- rtl8187_linux_26.1010.0622.2006_orig/symvers 1969-12-31 19:00:00.000000000 -0500
16257 +++ rtl8187_linux_26.1010.0622.2006_rawtx/symvers 2008-08-12 13:11:33.000000000 -0400
16258 @@ -0,0 +1,25 @@
16259 +#!/bin/sh
16260 +
16261 +cd beta-8187
16262 +
16263 +if [ -e Module.symvers ]
16264 +then
16265 + rm Module.symvers
16266 +fi
16267 +
16268 +if [ -e Modules.symvers ]
16269 +then
16270 + rm Modules.symvers
16271 +fi
16272 +
16273 +if [ -e ../ieee80211/Module.symvers ]
16274 +then
16275 + ln -sf ../ieee80211/Module.symvers ./
16276 +fi
16277 +
16278 +if [ -e ../ieee80211/Modules.symvers ]
16279 +then
16280 + ln -sf ../ieee80211/Modules.symvers ./
16281 +fi
16282 +
16283 +cd ..
16284 diff -Naur rtl8187_linux_26.1010.0622.2006_orig/wlan0rmv rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv
16285 --- rtl8187_linux_26.1010.0622.2006_orig/wlan0rmv 2006-09-05 07:21:10.000000000 -0400
16286 +++ rtl8187_linux_26.1010.0622.2006_rawtx/wlan0rmv 2008-08-12 13:11:33.000000000 -0400
16287 @@ -1,5 +1,9 @@
16288 #!/bin/bash
16289  
16290 -rmmod r8180
16291 -rmmod ieee80211_r8180
16292 -rmmod ieee80211_crypt_r8180
16293 +rmmod rtl8187 2>/dev/null
16294 +rmmod r8187 2>/dev/null
16295 +rmmod ieee80211_rtl 2>/dev/null
16296 +rmmod ieee80211_crypt_ccmp_rtl 2>/dev/null
16297 +rmmod ieee80211_crypt_tkip_rtl 2>/dev/null
16298 +rmmod ieee80211_crypt_wep_rtl 2>/dev/null
16299 +rmmod ieee80211_crypt_rtl 2>/dev/null