2 * Driver for RNDIS based wireless USB devices.
4 * Copyright (C) 2007 by Bjorge Dijkstra <bjd@jooz.net>
5 * Copyright (C) 2008-2009 by Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Portions of this file are based on NDISwrapper project,
22 * Copyright (C) 2003-2005 Pontus Fuchs, Giridhar Pemmasani
23 * http://ndiswrapper.sourceforge.net/
26 // #define DEBUG // error path messages, extra info
27 // #define VERBOSE // more; success messages
29 #include <linux/module.h>
30 #include <linux/init.h>
31 #include <linux/netdevice.h>
32 #include <linux/etherdevice.h>
33 #include <linux/ethtool.h>
34 #include <linux/workqueue.h>
35 #include <linux/mutex.h>
36 #include <linux/mii.h>
37 #include <linux/usb.h>
38 #include <linux/usb/cdc.h>
39 #include <linux/wireless.h>
40 #include <linux/ieee80211.h>
41 #include <linux/if_arp.h>
42 #include <linux/ctype.h>
43 #include <linux/spinlock.h>
44 #include <net/iw_handler.h>
45 #include <net/cfg80211.h>
46 #include <linux/usb/usbnet.h>
47 #include <linux/usb/rndis_host.h>
50 /* NOTE: All these are settings for Broadcom chipset */
51 static char modparam_country
[4] = "EU";
52 module_param_string(country
, modparam_country
, 4, 0444);
53 MODULE_PARM_DESC(country
, "Country code (ISO 3166-1 alpha-2), default: EU");
55 static int modparam_frameburst
= 1;
56 module_param_named(frameburst
, modparam_frameburst
, int, 0444);
57 MODULE_PARM_DESC(frameburst
, "enable frame bursting (default: on)");
59 static int modparam_afterburner
= 0;
60 module_param_named(afterburner
, modparam_afterburner
, int, 0444);
61 MODULE_PARM_DESC(afterburner
,
62 "enable afterburner aka '125 High Speed Mode' (default: off)");
64 static int modparam_power_save
= 0;
65 module_param_named(power_save
, modparam_power_save
, int, 0444);
66 MODULE_PARM_DESC(power_save
,
67 "set power save mode: 0=off, 1=on, 2=fast (default: off)");
69 static int modparam_power_output
= 3;
70 module_param_named(power_output
, modparam_power_output
, int, 0444);
71 MODULE_PARM_DESC(power_output
,
72 "set power output: 0=25%, 1=50%, 2=75%, 3=100% (default: 100%)");
74 static int modparam_roamtrigger
= -70;
75 module_param_named(roamtrigger
, modparam_roamtrigger
, int, 0444);
76 MODULE_PARM_DESC(roamtrigger
,
77 "set roaming dBm trigger: -80=optimize for distance, "
78 "-60=bandwidth (default: -70)");
80 static int modparam_roamdelta
= 1;
81 module_param_named(roamdelta
, modparam_roamdelta
, int, 0444);
82 MODULE_PARM_DESC(roamdelta
,
83 "set roaming tendency: 0=aggressive, 1=moderate, "
84 "2=conservative (default: moderate)");
86 static int modparam_workaround_interval
= 500;
87 module_param_named(workaround_interval
, modparam_workaround_interval
,
89 MODULE_PARM_DESC(workaround_interval
,
90 "set stall workaround interval in msecs (default: 500)");
93 /* various RNDIS OID defs */
94 #define OID_GEN_LINK_SPEED cpu_to_le32(0x00010107)
95 #define OID_GEN_RNDIS_CONFIG_PARAMETER cpu_to_le32(0x0001021b)
97 #define OID_GEN_XMIT_OK cpu_to_le32(0x00020101)
98 #define OID_GEN_RCV_OK cpu_to_le32(0x00020102)
99 #define OID_GEN_XMIT_ERROR cpu_to_le32(0x00020103)
100 #define OID_GEN_RCV_ERROR cpu_to_le32(0x00020104)
101 #define OID_GEN_RCV_NO_BUFFER cpu_to_le32(0x00020105)
103 #define OID_802_3_PERMANENT_ADDRESS cpu_to_le32(0x01010101)
104 #define OID_802_3_CURRENT_ADDRESS cpu_to_le32(0x01010102)
105 #define OID_802_3_MULTICAST_LIST cpu_to_le32(0x01010103)
106 #define OID_802_3_MAXIMUM_LIST_SIZE cpu_to_le32(0x01010104)
108 #define OID_802_11_BSSID cpu_to_le32(0x0d010101)
109 #define OID_802_11_SSID cpu_to_le32(0x0d010102)
110 #define OID_802_11_INFRASTRUCTURE_MODE cpu_to_le32(0x0d010108)
111 #define OID_802_11_ADD_WEP cpu_to_le32(0x0d010113)
112 #define OID_802_11_REMOVE_WEP cpu_to_le32(0x0d010114)
113 #define OID_802_11_DISASSOCIATE cpu_to_le32(0x0d010115)
114 #define OID_802_11_AUTHENTICATION_MODE cpu_to_le32(0x0d010118)
115 #define OID_802_11_PRIVACY_FILTER cpu_to_le32(0x0d010119)
116 #define OID_802_11_BSSID_LIST_SCAN cpu_to_le32(0x0d01011a)
117 #define OID_802_11_ENCRYPTION_STATUS cpu_to_le32(0x0d01011b)
118 #define OID_802_11_ADD_KEY cpu_to_le32(0x0d01011d)
119 #define OID_802_11_REMOVE_KEY cpu_to_le32(0x0d01011e)
120 #define OID_802_11_ASSOCIATION_INFORMATION cpu_to_le32(0x0d01011f)
121 #define OID_802_11_PMKID cpu_to_le32(0x0d010123)
122 #define OID_802_11_NETWORK_TYPES_SUPPORTED cpu_to_le32(0x0d010203)
123 #define OID_802_11_NETWORK_TYPE_IN_USE cpu_to_le32(0x0d010204)
124 #define OID_802_11_TX_POWER_LEVEL cpu_to_le32(0x0d010205)
125 #define OID_802_11_RSSI cpu_to_le32(0x0d010206)
126 #define OID_802_11_RSSI_TRIGGER cpu_to_le32(0x0d010207)
127 #define OID_802_11_FRAGMENTATION_THRESHOLD cpu_to_le32(0x0d010209)
128 #define OID_802_11_RTS_THRESHOLD cpu_to_le32(0x0d01020a)
129 #define OID_802_11_SUPPORTED_RATES cpu_to_le32(0x0d01020e)
130 #define OID_802_11_CONFIGURATION cpu_to_le32(0x0d010211)
131 #define OID_802_11_BSSID_LIST cpu_to_le32(0x0d010217)
134 /* Typical noise/maximum signal level values taken from ndiswrapper iw_ndis.h */
135 #define WL_NOISE -96 /* typical noise level in dBm */
136 #define WL_SIGMAX -32 /* typical maximum signal level in dBm */
139 /* Assume that Broadcom 4320 (only chipset at time of writing known to be
140 * based on wireless rndis) has default txpower of 13dBm.
141 * This value is from Linksys WUSB54GSC User Guide, Appendix F: Specifications.
144 #define BCM4320_DEFAULT_TXPOWER 20
147 /* codes for "status" field of completion messages */
148 #define RNDIS_STATUS_ADAPTER_NOT_READY cpu_to_le32(0xc0010011)
149 #define RNDIS_STATUS_ADAPTER_NOT_OPEN cpu_to_le32(0xc0010012)
152 /* NDIS data structures. Taken from wpa_supplicant driver_ndis.c
153 * slightly modified for datatype endianess, etc
155 #define NDIS_802_11_LENGTH_SSID 32
156 #define NDIS_802_11_LENGTH_RATES 8
157 #define NDIS_802_11_LENGTH_RATES_EX 16
159 enum ndis_80211_net_type
{
160 ndis_80211_type_freq_hop
,
161 ndis_80211_type_direct_seq
,
162 ndis_80211_type_ofdm_a
,
163 ndis_80211_type_ofdm_g
166 enum ndis_80211_net_infra
{
167 ndis_80211_infra_adhoc
,
168 ndis_80211_infra_infra
,
169 ndis_80211_infra_auto_unknown
172 enum ndis_80211_auth_mode
{
173 ndis_80211_auth_open
,
174 ndis_80211_auth_shared
,
175 ndis_80211_auth_auto_switch
,
177 ndis_80211_auth_wpa_psk
,
178 ndis_80211_auth_wpa_none
,
179 ndis_80211_auth_wpa2
,
180 ndis_80211_auth_wpa2_psk
183 enum ndis_80211_encr_status
{
184 ndis_80211_encr_wep_enabled
,
185 ndis_80211_encr_disabled
,
186 ndis_80211_encr_wep_key_absent
,
187 ndis_80211_encr_not_supported
,
188 ndis_80211_encr_tkip_enabled
,
189 ndis_80211_encr_tkip_key_absent
,
190 ndis_80211_encr_ccmp_enabled
,
191 ndis_80211_encr_ccmp_key_absent
194 enum ndis_80211_priv_filter
{
195 ndis_80211_priv_accept_all
,
196 ndis_80211_priv_8021x_wep
199 enum ndis_80211_addkey_bits
{
200 ndis_80211_addkey_8021x_auth
= cpu_to_le32(1 << 28),
201 ndis_80211_addkey_set_init_recv_seq
= cpu_to_le32(1 << 29),
202 ndis_80211_addkey_pairwise_key
= cpu_to_le32(1 << 30),
203 ndis_80211_addkey_transmit_key
= cpu_to_le32(1 << 31),
206 enum ndis_80211_addwep_bits
{
207 ndis_80211_addwep_perclient_key
= cpu_to_le32(1 << 30),
208 ndis_80211_addwep_transmit_key
= cpu_to_le32(1 << 31),
211 struct ndis_80211_ssid
{
213 u8 essid
[NDIS_802_11_LENGTH_SSID
];
214 } __attribute__((packed
));
216 struct ndis_80211_conf_freq_hop
{
221 } __attribute__((packed
));
223 struct ndis_80211_conf
{
225 __le32 beacon_period
;
228 struct ndis_80211_conf_freq_hop fh_config
;
229 } __attribute__((packed
));
231 struct ndis_80211_bssid_ex
{
235 struct ndis_80211_ssid ssid
;
239 struct ndis_80211_conf config
;
241 u8 rates
[NDIS_802_11_LENGTH_RATES_EX
];
244 } __attribute__((packed
));
246 struct ndis_80211_bssid_list_ex
{
248 struct ndis_80211_bssid_ex bssid
[0];
249 } __attribute__((packed
));
251 struct ndis_80211_fixed_ies
{
253 __le16 beacon_interval
;
255 } __attribute__((packed
));
257 struct ndis_80211_wep_key
{
262 } __attribute__((packed
));
264 struct ndis_80211_key
{
272 } __attribute__((packed
));
274 struct ndis_80211_remove_key
{
278 } __attribute__((packed
));
280 struct ndis_config_param
{
286 } __attribute__((packed
));
288 struct ndis_80211_assoc_info
{
293 __le16 listen_interval
;
294 u8 cur_ap_address
[6];
296 __le32 req_ie_length
;
297 __le32 offset_req_ies
;
304 __le32 resp_ie_length
;
305 __le32 offset_resp_ies
;
306 } __attribute__((packed
));
308 /* these have to match what is in wpa_supplicant */
309 enum wpa_alg
{ WPA_ALG_NONE
, WPA_ALG_WEP
, WPA_ALG_TKIP
, WPA_ALG_CCMP
};
310 enum wpa_cipher
{ CIPHER_NONE
, CIPHER_WEP40
, CIPHER_TKIP
, CIPHER_CCMP
,
312 enum wpa_key_mgmt
{ KEY_MGMT_802_1X
, KEY_MGMT_PSK
, KEY_MGMT_NONE
,
313 KEY_MGMT_802_1X_NO_WPA
, KEY_MGMT_WPA_NONE
};
318 #define NET_TYPE_11FB 0
320 #define CAP_MODE_80211A 1
321 #define CAP_MODE_80211B 2
322 #define CAP_MODE_80211G 4
323 #define CAP_MODE_MASK 7
325 #define WORK_LINK_UP (1<<0)
326 #define WORK_LINK_DOWN (1<<1)
327 #define WORK_SET_MULTICAST_LIST (1<<2)
329 #define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set))
331 static const struct ieee80211_channel rndis_channels
[] = {
332 { .center_freq
= 2412 },
333 { .center_freq
= 2417 },
334 { .center_freq
= 2422 },
335 { .center_freq
= 2427 },
336 { .center_freq
= 2432 },
337 { .center_freq
= 2437 },
338 { .center_freq
= 2442 },
339 { .center_freq
= 2447 },
340 { .center_freq
= 2452 },
341 { .center_freq
= 2457 },
342 { .center_freq
= 2462 },
343 { .center_freq
= 2467 },
344 { .center_freq
= 2472 },
345 { .center_freq
= 2484 },
348 static const struct ieee80211_rate rndis_rates
[] = {
350 { .bitrate
= 20, .flags
= IEEE80211_RATE_SHORT_PREAMBLE
},
351 { .bitrate
= 55, .flags
= IEEE80211_RATE_SHORT_PREAMBLE
},
352 { .bitrate
= 110, .flags
= IEEE80211_RATE_SHORT_PREAMBLE
},
363 /* RNDIS device private data */
364 struct rndis_wext_private
{
365 struct usbnet
*usbdev
;
367 struct wireless_dev wdev
;
369 struct cfg80211_scan_request
*scan_request
;
371 struct workqueue_struct
*workqueue
;
372 struct delayed_work stats_work
;
373 struct delayed_work scan_work
;
374 struct work_struct work
;
375 struct mutex command_lock
;
376 spinlock_t stats_lock
;
377 unsigned long work_pending
;
379 struct ieee80211_supported_band band
;
380 struct ieee80211_channel channels
[ARRAY_SIZE(rndis_channels
)];
381 struct ieee80211_rate rates
[ARRAY_SIZE(rndis_rates
)];
383 struct iw_statistics iwstats
;
384 struct iw_statistics privstats
;
389 /* module parameters */
390 char param_country
[4];
391 int param_frameburst
;
392 int param_afterburner
;
393 int param_power_save
;
394 int param_power_output
;
395 int param_roamtrigger
;
397 u32 param_workaround_interval
;
402 struct ndis_80211_ssid essid
;
404 /* encryption stuff */
405 int encr_tx_key_index
;
406 char encr_keys
[4][32];
408 char encr_key_wpa
[4];
415 int wpa_cipher_group
;
417 u8 command_buffer
[COMMAND_BUFFER_SIZE
];
423 static int rndis_change_virtual_intf(struct wiphy
*wiphy
, int ifindex
,
424 enum nl80211_iftype type
, u32
*flags
,
425 struct vif_params
*params
);
427 static int rndis_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
428 struct cfg80211_scan_request
*request
);
430 static struct cfg80211_ops rndis_config_ops
= {
431 .change_virtual_intf
= rndis_change_virtual_intf
,
435 static void *rndis_wiphy_privid
= &rndis_wiphy_privid
;
437 static const int bcm4320_power_output
[4] = { 25, 50, 75, 100 };
439 static const unsigned char zero_bssid
[ETH_ALEN
] = {0,};
440 static const unsigned char ffff_bssid
[ETH_ALEN
] = { 0xff, 0xff, 0xff,
444 static struct rndis_wext_private
*get_rndis_wext_priv(struct usbnet
*dev
)
446 return (struct rndis_wext_private
*)dev
->driver_priv
;
450 static u32
get_bcm4320_power(struct rndis_wext_private
*priv
)
452 return BCM4320_DEFAULT_TXPOWER
*
453 bcm4320_power_output
[priv
->param_power_output
] / 100;
457 /* translate error code */
458 static int rndis_error_status(__le32 rndis_status
)
461 switch (rndis_status
) {
462 case RNDIS_STATUS_SUCCESS
:
465 case RNDIS_STATUS_FAILURE
:
466 case RNDIS_STATUS_INVALID_DATA
:
469 case RNDIS_STATUS_NOT_SUPPORTED
:
472 case RNDIS_STATUS_ADAPTER_NOT_READY
:
473 case RNDIS_STATUS_ADAPTER_NOT_OPEN
:
481 static int rndis_query_oid(struct usbnet
*dev
, __le32 oid
, void *data
, int *len
)
483 struct rndis_wext_private
*priv
= get_rndis_wext_priv(dev
);
486 struct rndis_msg_hdr
*header
;
487 struct rndis_query
*get
;
488 struct rndis_query_c
*get_c
;
492 buflen
= *len
+ sizeof(*u
.get
);
493 if (buflen
< CONTROL_BUFFER_SIZE
)
494 buflen
= CONTROL_BUFFER_SIZE
;
496 if (buflen
> COMMAND_BUFFER_SIZE
) {
497 u
.buf
= kmalloc(buflen
, GFP_KERNEL
);
501 u
.buf
= priv
->command_buffer
;
504 mutex_lock(&priv
->command_lock
);
506 memset(u
.get
, 0, sizeof *u
.get
);
507 u
.get
->msg_type
= RNDIS_MSG_QUERY
;
508 u
.get
->msg_len
= cpu_to_le32(sizeof *u
.get
);
511 ret
= rndis_command(dev
, u
.header
, buflen
);
513 ret
= le32_to_cpu(u
.get_c
->len
);
514 *len
= (*len
> ret
) ? ret
: *len
;
515 memcpy(data
, u
.buf
+ le32_to_cpu(u
.get_c
->offset
) + 8, *len
);
516 ret
= rndis_error_status(u
.get_c
->status
);
519 mutex_unlock(&priv
->command_lock
);
521 if (u
.buf
!= priv
->command_buffer
)
527 static int rndis_set_oid(struct usbnet
*dev
, __le32 oid
, void *data
, int len
)
529 struct rndis_wext_private
*priv
= get_rndis_wext_priv(dev
);
532 struct rndis_msg_hdr
*header
;
533 struct rndis_set
*set
;
534 struct rndis_set_c
*set_c
;
538 buflen
= len
+ sizeof(*u
.set
);
539 if (buflen
< CONTROL_BUFFER_SIZE
)
540 buflen
= CONTROL_BUFFER_SIZE
;
542 if (buflen
> COMMAND_BUFFER_SIZE
) {
543 u
.buf
= kmalloc(buflen
, GFP_KERNEL
);
547 u
.buf
= priv
->command_buffer
;
550 mutex_lock(&priv
->command_lock
);
552 memset(u
.set
, 0, sizeof *u
.set
);
553 u
.set
->msg_type
= RNDIS_MSG_SET
;
554 u
.set
->msg_len
= cpu_to_le32(sizeof(*u
.set
) + len
);
556 u
.set
->len
= cpu_to_le32(len
);
557 u
.set
->offset
= cpu_to_le32(sizeof(*u
.set
) - 8);
558 u
.set
->handle
= cpu_to_le32(0);
559 memcpy(u
.buf
+ sizeof(*u
.set
), data
, len
);
561 ret
= rndis_command(dev
, u
.header
, buflen
);
563 ret
= rndis_error_status(u
.set_c
->status
);
565 mutex_unlock(&priv
->command_lock
);
567 if (u
.buf
!= priv
->command_buffer
)
574 * Specs say that we can only set config parameters only soon after device
576 * value_type: 0 = u32, 2 = unicode string
578 static int rndis_set_config_parameter(struct usbnet
*dev
, char *param
,
579 int value_type
, void *value
)
581 struct ndis_config_param
*infobuf
;
582 int value_len
, info_len
, param_len
, ret
, i
;
587 value_len
= sizeof(__le32
);
588 else if (value_type
== 2)
589 value_len
= strlen(value
) * sizeof(__le16
);
593 param_len
= strlen(param
) * sizeof(__le16
);
594 info_len
= sizeof(*infobuf
) + param_len
+ value_len
;
599 infobuf
= kmalloc(info_len
, GFP_KERNEL
);
605 /* extra 12 bytes are for padding (debug output) */
606 memset(infobuf
, 0xCC, info_len
+ 12);
610 devdbg(dev
, "setting config parameter: %s, value: %s",
613 devdbg(dev
, "setting config parameter: %s, value: %d",
614 param
, *(u32
*)value
);
616 infobuf
->name_offs
= cpu_to_le32(sizeof(*infobuf
));
617 infobuf
->name_length
= cpu_to_le32(param_len
);
618 infobuf
->type
= cpu_to_le32(value_type
);
619 infobuf
->value_offs
= cpu_to_le32(sizeof(*infobuf
) + param_len
);
620 infobuf
->value_length
= cpu_to_le32(value_len
);
622 /* simple string to unicode string conversion */
623 unibuf
= (void *)infobuf
+ sizeof(*infobuf
);
624 for (i
= 0; i
< param_len
/ sizeof(__le16
); i
++)
625 unibuf
[i
] = cpu_to_le16(param
[i
]);
627 if (value_type
== 2) {
628 unibuf
= (void *)infobuf
+ sizeof(*infobuf
) + param_len
;
629 for (i
= 0; i
< value_len
/ sizeof(__le16
); i
++)
630 unibuf
[i
] = cpu_to_le16(((u8
*)value
)[i
]);
632 dst_value
= (void *)infobuf
+ sizeof(*infobuf
) + param_len
;
633 *dst_value
= cpu_to_le32(*(u32
*)value
);
637 devdbg(dev
, "info buffer (len: %d):", info_len
);
638 for (i
= 0; i
< info_len
; i
+= 12) {
639 u32
*tmp
= (u32
*)((u8
*)infobuf
+ i
);
640 devdbg(dev
, "%08X:%08X:%08X",
643 cpu_to_be32(tmp
[2]));
647 ret
= rndis_set_oid(dev
, OID_GEN_RNDIS_CONFIG_PARAMETER
,
650 devdbg(dev
, "setting rndis config paramater failed, %d.", ret
);
656 static int rndis_set_config_parameter_str(struct usbnet
*dev
,
657 char *param
, char *value
)
659 return(rndis_set_config_parameter(dev
, param
, 2, value
));
662 /*static int rndis_set_config_parameter_u32(struct usbnet *dev,
663 char *param, u32 value)
665 return(rndis_set_config_parameter(dev, param, 0, &value));
670 * data conversion functions
672 static int level_to_qual(int level
)
674 int qual
= 100 * (level
- WL_NOISE
) / (WL_SIGMAX
- WL_NOISE
);
675 return qual
>= 0 ? (qual
<= 100 ? qual
: 100) : 0;
679 static void dsconfig_to_freq(unsigned int dsconfig
, struct iw_freq
*freq
)
685 /* see comment in wireless.h above the "struct iw_freq"
686 * definition for an explanation of this if
687 * NOTE: 1000000 is due to the kHz
689 if (dsconfig
> 1000000) {
690 freq
->m
= dsconfig
/ 10;
695 /* convert from kHz to Hz */
700 static int freq_to_dsconfig(struct iw_freq
*freq
, unsigned int *dsconfig
)
702 if (freq
->m
< 1000 && freq
->e
== 0) {
703 if (freq
->m
>= 1 && freq
->m
<= 14)
704 *dsconfig
= ieee80211_dsss_chan_to_freq(freq
->m
) * 1000;
710 for (i
= freq
->e
; i
> 0; i
--)
723 add_wep_key(struct usbnet
*usbdev
, char *key
, int key_len
, int index
);
725 static int get_essid(struct usbnet
*usbdev
, struct ndis_80211_ssid
*ssid
)
730 ret
= rndis_query_oid(usbdev
, OID_802_11_SSID
, ssid
, &len
);
737 unsigned char tmp
[NDIS_802_11_LENGTH_SSID
+ 1];
739 memcpy(tmp
, ssid
->essid
, le32_to_cpu(ssid
->length
));
740 tmp
[le32_to_cpu(ssid
->length
)] = 0;
741 devdbg(usbdev
, "get_essid: '%s', ret: %d", tmp
, ret
);
748 static int set_essid(struct usbnet
*usbdev
, struct ndis_80211_ssid
*ssid
)
750 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
753 ret
= rndis_set_oid(usbdev
, OID_802_11_SSID
, ssid
, sizeof(*ssid
));
755 memcpy(&priv
->essid
, ssid
, sizeof(priv
->essid
));
757 devdbg(usbdev
, "set_essid: radio_on = 1");
764 static int get_bssid(struct usbnet
*usbdev
, u8 bssid
[ETH_ALEN
])
769 ret
= rndis_query_oid(usbdev
, OID_802_11_BSSID
, bssid
, &len
);
772 memset(bssid
, 0, ETH_ALEN
);
777 static int get_association_info(struct usbnet
*usbdev
,
778 struct ndis_80211_assoc_info
*info
, int len
)
780 return rndis_query_oid(usbdev
, OID_802_11_ASSOCIATION_INFORMATION
,
784 static int is_associated(struct usbnet
*usbdev
)
789 ret
= get_bssid(usbdev
, bssid
);
791 return(ret
== 0 && memcmp(bssid
, zero_bssid
, ETH_ALEN
) != 0);
795 static int disassociate(struct usbnet
*usbdev
, int reset_ssid
)
797 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
798 struct ndis_80211_ssid ssid
;
801 if (priv
->radio_on
) {
802 ret
= rndis_set_oid(usbdev
, OID_802_11_DISASSOCIATE
, NULL
, 0);
805 devdbg(usbdev
, "disassociate: radio_on = 0");
812 /* disassociate causes radio to be turned off; if reset_ssid
813 * is given, set random ssid to enable radio */
815 ssid
.length
= cpu_to_le32(sizeof(ssid
.essid
));
816 get_random_bytes(&ssid
.essid
[2], sizeof(ssid
.essid
)-2);
818 ssid
.essid
[1] = 0xff;
819 for (i
= 2; i
< sizeof(ssid
.essid
); i
++)
820 ssid
.essid
[i
] = 0x1 + (ssid
.essid
[i
] * 0xfe / 0xff);
821 ret
= set_essid(usbdev
, &ssid
);
827 static int set_auth_mode(struct usbnet
*usbdev
, int wpa_version
, int authalg
)
829 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
833 devdbg(usbdev
, "set_auth_mode: wpa_version=0x%x authalg=0x%x "
834 "keymgmt=0x%x", wpa_version
, authalg
, priv
->wpa_keymgmt
);
836 if (wpa_version
& IW_AUTH_WPA_VERSION_WPA2
) {
837 if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_802_1X
)
838 auth_mode
= ndis_80211_auth_wpa2
;
840 auth_mode
= ndis_80211_auth_wpa2_psk
;
841 } else if (wpa_version
& IW_AUTH_WPA_VERSION_WPA
) {
842 if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_802_1X
)
843 auth_mode
= ndis_80211_auth_wpa
;
844 else if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_PSK
)
845 auth_mode
= ndis_80211_auth_wpa_psk
;
847 auth_mode
= ndis_80211_auth_wpa_none
;
848 } else if (authalg
& IW_AUTH_ALG_SHARED_KEY
) {
849 if (authalg
& IW_AUTH_ALG_OPEN_SYSTEM
)
850 auth_mode
= ndis_80211_auth_auto_switch
;
852 auth_mode
= ndis_80211_auth_shared
;
854 auth_mode
= ndis_80211_auth_open
;
856 tmp
= cpu_to_le32(auth_mode
);
857 ret
= rndis_set_oid(usbdev
, OID_802_11_AUTHENTICATION_MODE
, &tmp
,
860 devwarn(usbdev
, "setting auth mode failed (%08X)", ret
);
864 priv
->wpa_version
= wpa_version
;
865 priv
->wpa_authalg
= authalg
;
870 static int set_priv_filter(struct usbnet
*usbdev
)
872 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
875 devdbg(usbdev
, "set_priv_filter: wpa_version=0x%x", priv
->wpa_version
);
877 if (priv
->wpa_version
& IW_AUTH_WPA_VERSION_WPA2
||
878 priv
->wpa_version
& IW_AUTH_WPA_VERSION_WPA
)
879 tmp
= cpu_to_le32(ndis_80211_priv_8021x_wep
);
881 tmp
= cpu_to_le32(ndis_80211_priv_accept_all
);
883 return rndis_set_oid(usbdev
, OID_802_11_PRIVACY_FILTER
, &tmp
,
888 static int set_encr_mode(struct usbnet
*usbdev
, int pairwise
, int groupwise
)
890 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
894 devdbg(usbdev
, "set_encr_mode: cipher_pair=0x%x cipher_group=0x%x",
898 if (pairwise
& IW_AUTH_CIPHER_CCMP
)
899 encr_mode
= ndis_80211_encr_ccmp_enabled
;
900 else if (pairwise
& IW_AUTH_CIPHER_TKIP
)
901 encr_mode
= ndis_80211_encr_tkip_enabled
;
903 (IW_AUTH_CIPHER_WEP40
| IW_AUTH_CIPHER_WEP104
))
904 encr_mode
= ndis_80211_encr_wep_enabled
;
905 else if (groupwise
& IW_AUTH_CIPHER_CCMP
)
906 encr_mode
= ndis_80211_encr_ccmp_enabled
;
907 else if (groupwise
& IW_AUTH_CIPHER_TKIP
)
908 encr_mode
= ndis_80211_encr_tkip_enabled
;
910 encr_mode
= ndis_80211_encr_disabled
;
912 tmp
= cpu_to_le32(encr_mode
);
913 ret
= rndis_set_oid(usbdev
, OID_802_11_ENCRYPTION_STATUS
, &tmp
,
916 devwarn(usbdev
, "setting encr mode failed (%08X)", ret
);
920 priv
->wpa_cipher_pair
= pairwise
;
921 priv
->wpa_cipher_group
= groupwise
;
926 static int set_assoc_params(struct usbnet
*usbdev
)
928 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
930 set_auth_mode(usbdev
, priv
->wpa_version
, priv
->wpa_authalg
);
931 set_priv_filter(usbdev
);
932 set_encr_mode(usbdev
, priv
->wpa_cipher_pair
, priv
->wpa_cipher_group
);
938 static int set_infra_mode(struct usbnet
*usbdev
, int mode
)
940 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
944 devdbg(usbdev
, "set_infra_mode: infra_mode=0x%x", priv
->infra_mode
);
946 tmp
= cpu_to_le32(mode
);
947 ret
= rndis_set_oid(usbdev
, OID_802_11_INFRASTRUCTURE_MODE
, &tmp
,
950 devwarn(usbdev
, "setting infra mode failed (%08X)", ret
);
954 /* NDIS drivers clear keys when infrastructure mode is
955 * changed. But Linux tools assume otherwise. So set the
957 if (priv
->wpa_keymgmt
== 0 ||
958 priv
->wpa_keymgmt
== IW_AUTH_KEY_MGMT_802_1X
) {
959 for (i
= 0; i
< 4; i
++) {
960 if (priv
->encr_key_len
[i
] > 0 && !priv
->encr_key_wpa
[i
])
961 add_wep_key(usbdev
, priv
->encr_keys
[i
],
962 priv
->encr_key_len
[i
], i
);
966 priv
->infra_mode
= mode
;
971 static void set_default_iw_params(struct usbnet
*usbdev
)
973 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
975 priv
->wpa_keymgmt
= 0;
976 priv
->wpa_version
= 0;
978 set_infra_mode(usbdev
, ndis_80211_infra_infra
);
979 set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
980 IW_AUTH_ALG_OPEN_SYSTEM
);
981 set_priv_filter(usbdev
);
982 set_encr_mode(usbdev
, IW_AUTH_CIPHER_NONE
, IW_AUTH_CIPHER_NONE
);
986 static int deauthenticate(struct usbnet
*usbdev
)
990 ret
= disassociate(usbdev
, 1);
991 set_default_iw_params(usbdev
);
996 /* index must be 0 - N, as per NDIS */
997 static int add_wep_key(struct usbnet
*usbdev
, char *key
, int key_len
, int index
)
999 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1000 struct ndis_80211_wep_key ndis_key
;
1003 if (key_len
<= 0 || key_len
> 32 || index
< 0 || index
>= 4)
1006 memset(&ndis_key
, 0, sizeof(ndis_key
));
1008 ndis_key
.size
= cpu_to_le32(sizeof(ndis_key
));
1009 ndis_key
.length
= cpu_to_le32(key_len
);
1010 ndis_key
.index
= cpu_to_le32(index
);
1011 memcpy(&ndis_key
.material
, key
, key_len
);
1013 if (index
== priv
->encr_tx_key_index
) {
1014 ndis_key
.index
|= ndis_80211_addwep_transmit_key
;
1015 ret
= set_encr_mode(usbdev
, IW_AUTH_CIPHER_WEP104
,
1016 IW_AUTH_CIPHER_NONE
);
1018 devwarn(usbdev
, "encryption couldn't be enabled (%08X)",
1022 ret
= rndis_set_oid(usbdev
, OID_802_11_ADD_WEP
, &ndis_key
,
1025 devwarn(usbdev
, "adding encryption key %d failed (%08X)",
1030 priv
->encr_key_len
[index
] = key_len
;
1031 priv
->encr_key_wpa
[index
] = 0;
1032 memcpy(&priv
->encr_keys
[index
], key
, key_len
);
1038 static int add_wpa_key(struct usbnet
*usbdev
, const u8
*key
, int key_len
,
1039 int index
, const struct sockaddr
*addr
,
1040 const u8
*rx_seq
, int alg
, int flags
)
1042 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1043 struct ndis_80211_key ndis_key
;
1046 if (index
< 0 || index
>= 4)
1048 if (key_len
> sizeof(ndis_key
.material
) || key_len
< 0)
1050 if ((flags
& ndis_80211_addkey_set_init_recv_seq
) && !rx_seq
)
1052 if ((flags
& ndis_80211_addkey_pairwise_key
) && !addr
)
1055 devdbg(usbdev
, "add_wpa_key(%i): flags:%i%i%i", index
,
1056 !!(flags
& ndis_80211_addkey_transmit_key
),
1057 !!(flags
& ndis_80211_addkey_pairwise_key
),
1058 !!(flags
& ndis_80211_addkey_set_init_recv_seq
));
1060 memset(&ndis_key
, 0, sizeof(ndis_key
));
1062 ndis_key
.size
= cpu_to_le32(sizeof(ndis_key
) -
1063 sizeof(ndis_key
.material
) + key_len
);
1064 ndis_key
.length
= cpu_to_le32(key_len
);
1065 ndis_key
.index
= cpu_to_le32(index
) | flags
;
1067 if (alg
== IW_ENCODE_ALG_TKIP
&& key_len
== 32) {
1068 /* wpa_supplicant gives us the Michael MIC RX/TX keys in
1069 * different order than NDIS spec, so swap the order here. */
1070 memcpy(ndis_key
.material
, key
, 16);
1071 memcpy(ndis_key
.material
+ 16, key
+ 24, 8);
1072 memcpy(ndis_key
.material
+ 24, key
+ 16, 8);
1074 memcpy(ndis_key
.material
, key
, key_len
);
1076 if (flags
& ndis_80211_addkey_set_init_recv_seq
)
1077 memcpy(ndis_key
.rsc
, rx_seq
, 6);
1079 if (flags
& ndis_80211_addkey_pairwise_key
) {
1081 memcpy(ndis_key
.bssid
, addr
->sa_data
, ETH_ALEN
);
1084 if (priv
->infra_mode
== ndis_80211_infra_adhoc
)
1085 memset(ndis_key
.bssid
, 0xff, ETH_ALEN
);
1087 get_bssid(usbdev
, ndis_key
.bssid
);
1090 ret
= rndis_set_oid(usbdev
, OID_802_11_ADD_KEY
, &ndis_key
,
1091 le32_to_cpu(ndis_key
.size
));
1092 devdbg(usbdev
, "add_wpa_key: OID_802_11_ADD_KEY -> %08X", ret
);
1096 priv
->encr_key_len
[index
] = key_len
;
1097 priv
->encr_key_wpa
[index
] = 1;
1099 if (flags
& ndis_80211_addkey_transmit_key
)
1100 priv
->encr_tx_key_index
= index
;
1106 /* remove_key is for both wep and wpa */
1107 static int remove_key(struct usbnet
*usbdev
, int index
, u8 bssid
[ETH_ALEN
])
1109 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1110 struct ndis_80211_remove_key remove_key
;
1114 if (priv
->encr_key_len
[index
] == 0)
1117 priv
->encr_key_len
[index
] = 0;
1118 priv
->encr_key_wpa
[index
] = 0;
1119 memset(&priv
->encr_keys
[index
], 0, sizeof(priv
->encr_keys
[index
]));
1121 if (priv
->wpa_cipher_pair
== IW_AUTH_CIPHER_TKIP
||
1122 priv
->wpa_cipher_pair
== IW_AUTH_CIPHER_CCMP
||
1123 priv
->wpa_cipher_group
== IW_AUTH_CIPHER_TKIP
||
1124 priv
->wpa_cipher_group
== IW_AUTH_CIPHER_CCMP
) {
1125 remove_key
.size
= cpu_to_le32(sizeof(remove_key
));
1126 remove_key
.index
= cpu_to_le32(index
);
1129 if (memcmp(bssid
, ffff_bssid
, ETH_ALEN
) != 0)
1131 ndis_80211_addkey_pairwise_key
;
1132 memcpy(remove_key
.bssid
, bssid
,
1133 sizeof(remove_key
.bssid
));
1135 memset(remove_key
.bssid
, 0xff,
1136 sizeof(remove_key
.bssid
));
1138 ret
= rndis_set_oid(usbdev
, OID_802_11_REMOVE_KEY
, &remove_key
,
1139 sizeof(remove_key
));
1143 keyindex
= cpu_to_le32(index
);
1144 ret
= rndis_set_oid(usbdev
, OID_802_11_REMOVE_WEP
, &keyindex
,
1148 "removing encryption key %d failed (%08X)",
1154 /* if it is transmit key, disable encryption */
1155 if (index
== priv
->encr_tx_key_index
)
1156 set_encr_mode(usbdev
, IW_AUTH_CIPHER_NONE
, IW_AUTH_CIPHER_NONE
);
1162 static void set_multicast_list(struct usbnet
*usbdev
)
1164 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1165 struct dev_mc_list
*mclist
;
1170 filter
= RNDIS_PACKET_TYPE_DIRECTED
| RNDIS_PACKET_TYPE_BROADCAST
;
1172 if (usbdev
->net
->flags
& IFF_PROMISC
) {
1173 filter
|= RNDIS_PACKET_TYPE_PROMISCUOUS
|
1174 RNDIS_PACKET_TYPE_ALL_LOCAL
;
1175 } else if (usbdev
->net
->flags
& IFF_ALLMULTI
||
1176 usbdev
->net
->mc_count
> priv
->multicast_size
) {
1177 filter
|= RNDIS_PACKET_TYPE_ALL_MULTICAST
;
1178 } else if (usbdev
->net
->mc_count
> 0) {
1179 size
= min(priv
->multicast_size
, usbdev
->net
->mc_count
);
1180 buf
= kmalloc(size
* ETH_ALEN
, GFP_KERNEL
);
1183 "couldn't alloc %d bytes of memory",
1188 mclist
= usbdev
->net
->mc_list
;
1189 for (i
= 0; i
< size
&& mclist
; mclist
= mclist
->next
) {
1190 if (mclist
->dmi_addrlen
!= ETH_ALEN
)
1193 memcpy(buf
+ i
* ETH_ALEN
, mclist
->dmi_addr
, ETH_ALEN
);
1197 ret
= rndis_set_oid(usbdev
, OID_802_3_MULTICAST_LIST
, buf
,
1199 if (ret
== 0 && i
> 0)
1200 filter
|= RNDIS_PACKET_TYPE_MULTICAST
;
1202 filter
|= RNDIS_PACKET_TYPE_ALL_MULTICAST
;
1204 devdbg(usbdev
, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d",
1205 i
, priv
->multicast_size
, ret
);
1210 ret
= rndis_set_oid(usbdev
, OID_GEN_CURRENT_PACKET_FILTER
, &filter
,
1213 devwarn(usbdev
, "couldn't set packet filter: %08x",
1214 le32_to_cpu(filter
));
1217 devdbg(usbdev
, "OID_GEN_CURRENT_PACKET_FILTER(%08x) -> %d",
1218 le32_to_cpu(filter
), ret
);
1225 static int rndis_change_virtual_intf(struct wiphy
*wiphy
, int ifindex
,
1226 enum nl80211_iftype type
, u32
*flags
,
1227 struct vif_params
*params
)
1229 struct net_device
*dev
;
1230 struct usbnet
*usbdev
;
1233 /* we're under RTNL */
1234 dev
= __dev_get_by_index(&init_net
, ifindex
);
1237 usbdev
= netdev_priv(dev
);
1240 case NL80211_IFTYPE_ADHOC
:
1241 mode
= ndis_80211_infra_adhoc
;
1243 case NL80211_IFTYPE_STATION
:
1244 mode
= ndis_80211_infra_infra
;
1250 return set_infra_mode(usbdev
, mode
);
1254 #define SCAN_DELAY_JIFFIES (HZ)
1255 static int rndis_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
1256 struct cfg80211_scan_request
*request
)
1258 struct usbnet
*usbdev
= netdev_priv(dev
);
1259 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1263 devdbg(usbdev
, "cfg80211.scan");
1268 if (priv
->scan_request
&& priv
->scan_request
!= request
)
1271 priv
->scan_request
= request
;
1273 tmp
= cpu_to_le32(1);
1274 ret
= rndis_set_oid(usbdev
, OID_802_11_BSSID_LIST_SCAN
, &tmp
,
1277 /* Wait before retrieving scan results from device */
1278 queue_delayed_work(priv
->workqueue
, &priv
->scan_work
,
1279 SCAN_DELAY_JIFFIES
);
1286 static struct cfg80211_bss
*rndis_bss_info_update(struct usbnet
*usbdev
,
1287 struct ndis_80211_bssid_ex
*bssid
)
1289 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1290 struct ieee80211_channel
*channel
;
1294 u16 beacon_interval
;
1295 struct ndis_80211_fixed_ies
*fixed
;
1296 int ie_len
, bssid_len
;
1299 /* parse bssid structure */
1300 bssid_len
= le32_to_cpu(bssid
->length
);
1302 if (bssid_len
< sizeof(struct ndis_80211_bssid_ex
) +
1303 sizeof(struct ndis_80211_fixed_ies
))
1306 fixed
= (struct ndis_80211_fixed_ies
*)bssid
->ies
;
1308 ie
= (void *)(bssid
->ies
+ sizeof(struct ndis_80211_fixed_ies
));
1309 ie_len
= min(bssid_len
- (int)sizeof(*bssid
),
1310 (int)le32_to_cpu(bssid
->ie_length
));
1311 ie_len
-= sizeof(struct ndis_80211_fixed_ies
);
1315 /* extract data for cfg80211_inform_bss */
1316 channel
= ieee80211_get_channel(priv
->wdev
.wiphy
,
1317 KHZ_TO_MHZ(le32_to_cpu(bssid
->config
.ds_config
)));
1321 signal
= level_to_qual(le32_to_cpu(bssid
->rssi
));
1322 timestamp
= le64_to_cpu(*(__le64
*)fixed
->timestamp
);
1323 capability
= le16_to_cpu(fixed
->capabilities
);
1324 beacon_interval
= le16_to_cpu(fixed
->beacon_interval
);
1326 return cfg80211_inform_bss(priv
->wdev
.wiphy
, channel
, bssid
->mac
,
1327 timestamp
, capability
, beacon_interval
, ie
, ie_len
, signal
,
1332 static int rndis_check_bssid_list(struct usbnet
*usbdev
)
1335 struct ndis_80211_bssid_list_ex
*bssid_list
;
1336 struct ndis_80211_bssid_ex
*bssid
;
1337 int ret
= -EINVAL
, len
, count
, bssid_len
;
1339 devdbg(usbdev
, "check_bssid_list");
1341 len
= CONTROL_BUFFER_SIZE
;
1342 buf
= kmalloc(len
, GFP_KERNEL
);
1348 ret
= rndis_query_oid(usbdev
, OID_802_11_BSSID_LIST
, buf
, &len
);
1353 bssid
= bssid_list
->bssid
;
1354 bssid_len
= le32_to_cpu(bssid
->length
);
1355 count
= le32_to_cpu(bssid_list
->num_items
);
1356 devdbg(usbdev
, "check_bssid_list: %d BSSIDs found", count
);
1358 while (count
&& ((void *)bssid
+ bssid_len
) <= (buf
+ len
)) {
1359 rndis_bss_info_update(usbdev
, bssid
);
1361 bssid
= (void *)bssid
+ bssid_len
;
1362 bssid_len
= le32_to_cpu(bssid
->length
);
1372 static void rndis_get_scan_results(struct work_struct
*work
)
1374 struct rndis_wext_private
*priv
=
1375 container_of(work
, struct rndis_wext_private
, scan_work
.work
);
1376 struct usbnet
*usbdev
= priv
->usbdev
;
1379 devdbg(usbdev
, "get_scan_results");
1381 ret
= rndis_check_bssid_list(usbdev
);
1383 cfg80211_scan_done(priv
->scan_request
, ret
< 0);
1385 priv
->scan_request
= NULL
;
1390 * wireless extension handlers
1393 static int rndis_iw_commit(struct net_device
*dev
,
1394 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1401 static int rndis_iw_set_essid(struct net_device
*dev
,
1402 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *essid
)
1404 struct ndis_80211_ssid ssid
;
1405 int length
= wrqu
->essid
.length
;
1406 struct usbnet
*usbdev
= netdev_priv(dev
);
1408 devdbg(usbdev
, "SIOCSIWESSID: [flags:%d,len:%d] '%.32s'",
1409 wrqu
->essid
.flags
, wrqu
->essid
.length
, essid
);
1411 if (length
> NDIS_802_11_LENGTH_SSID
)
1412 length
= NDIS_802_11_LENGTH_SSID
;
1414 ssid
.length
= cpu_to_le32(length
);
1416 memcpy(ssid
.essid
, essid
, length
);
1418 memset(ssid
.essid
, 0, NDIS_802_11_LENGTH_SSID
);
1420 set_assoc_params(usbdev
);
1422 if (!wrqu
->essid
.flags
|| length
== 0)
1423 return disassociate(usbdev
, 1);
1425 return set_essid(usbdev
, &ssid
);
1429 static int rndis_iw_get_essid(struct net_device
*dev
,
1430 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *essid
)
1432 struct ndis_80211_ssid ssid
;
1433 struct usbnet
*usbdev
= netdev_priv(dev
);
1436 ret
= get_essid(usbdev
, &ssid
);
1438 if (ret
== 0 && le32_to_cpu(ssid
.length
) > 0) {
1439 wrqu
->essid
.flags
= 1;
1440 wrqu
->essid
.length
= le32_to_cpu(ssid
.length
);
1441 memcpy(essid
, ssid
.essid
, wrqu
->essid
.length
);
1442 essid
[wrqu
->essid
.length
] = 0;
1444 memset(essid
, 0, sizeof(NDIS_802_11_LENGTH_SSID
));
1445 wrqu
->essid
.flags
= 0;
1446 wrqu
->essid
.length
= 0;
1448 devdbg(usbdev
, "SIOCGIWESSID: %s", essid
);
1453 static int rndis_iw_get_bssid(struct net_device
*dev
,
1454 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1456 struct usbnet
*usbdev
= netdev_priv(dev
);
1457 unsigned char bssid
[ETH_ALEN
];
1460 ret
= get_bssid(usbdev
, bssid
);
1463 devdbg(usbdev
, "SIOCGIWAP: %pM", bssid
);
1465 devdbg(usbdev
, "SIOCGIWAP: <not associated>");
1467 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1468 memcpy(wrqu
->ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1474 static int rndis_iw_set_bssid(struct net_device
*dev
,
1475 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1477 struct usbnet
*usbdev
= netdev_priv(dev
);
1478 u8
*bssid
= (u8
*)wrqu
->ap_addr
.sa_data
;
1481 devdbg(usbdev
, "SIOCSIWAP: %pM", bssid
);
1483 ret
= rndis_set_oid(usbdev
, OID_802_11_BSSID
, bssid
, ETH_ALEN
);
1485 /* user apps may set ap's mac address, which is not required;
1486 * they may fail to work if this function fails, so return
1489 devwarn(usbdev
, "setting AP mac address failed (%08X)", ret
);
1495 static int rndis_iw_set_auth(struct net_device
*dev
,
1496 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1498 struct iw_param
*p
= &wrqu
->param
;
1499 struct usbnet
*usbdev
= netdev_priv(dev
);
1500 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1501 int ret
= -ENOTSUPP
;
1503 switch (p
->flags
& IW_AUTH_INDEX
) {
1504 case IW_AUTH_WPA_VERSION
:
1505 devdbg(usbdev
, "SIOCSIWAUTH: WPA_VERSION, %08x", p
->value
);
1506 priv
->wpa_version
= p
->value
;
1510 case IW_AUTH_CIPHER_PAIRWISE
:
1511 devdbg(usbdev
, "SIOCSIWAUTH: CIPHER_PAIRWISE, %08x", p
->value
);
1512 priv
->wpa_cipher_pair
= p
->value
;
1516 case IW_AUTH_CIPHER_GROUP
:
1517 devdbg(usbdev
, "SIOCSIWAUTH: CIPHER_GROUP, %08x", p
->value
);
1518 priv
->wpa_cipher_group
= p
->value
;
1522 case IW_AUTH_KEY_MGMT
:
1523 devdbg(usbdev
, "SIOCSIWAUTH: KEY_MGMT, %08x", p
->value
);
1524 priv
->wpa_keymgmt
= p
->value
;
1528 case IW_AUTH_TKIP_COUNTERMEASURES
:
1529 devdbg(usbdev
, "SIOCSIWAUTH: TKIP_COUNTERMEASURES, %08x",
1534 case IW_AUTH_DROP_UNENCRYPTED
:
1535 devdbg(usbdev
, "SIOCSIWAUTH: DROP_UNENCRYPTED, %08x", p
->value
);
1539 case IW_AUTH_80211_AUTH_ALG
:
1540 devdbg(usbdev
, "SIOCSIWAUTH: 80211_AUTH_ALG, %08x", p
->value
);
1541 priv
->wpa_authalg
= p
->value
;
1545 case IW_AUTH_WPA_ENABLED
:
1546 devdbg(usbdev
, "SIOCSIWAUTH: WPA_ENABLED, %08x", p
->value
);
1547 if (wrqu
->param
.value
)
1548 deauthenticate(usbdev
);
1552 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1553 devdbg(usbdev
, "SIOCSIWAUTH: RX_UNENCRYPTED_EAPOL, %08x",
1558 case IW_AUTH_ROAMING_CONTROL
:
1559 devdbg(usbdev
, "SIOCSIWAUTH: ROAMING_CONTROL, %08x", p
->value
);
1563 case IW_AUTH_PRIVACY_INVOKED
:
1564 devdbg(usbdev
, "SIOCSIWAUTH: invalid cmd %d",
1565 wrqu
->param
.flags
& IW_AUTH_INDEX
);
1569 devdbg(usbdev
, "SIOCSIWAUTH: UNKNOWN %08x, %08x",
1570 p
->flags
& IW_AUTH_INDEX
, p
->value
);
1576 static int rndis_iw_get_auth(struct net_device
*dev
,
1577 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1579 struct iw_param
*p
= &wrqu
->param
;
1580 struct usbnet
*usbdev
= netdev_priv(dev
);
1581 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1583 switch (p
->flags
& IW_AUTH_INDEX
) {
1584 case IW_AUTH_WPA_VERSION
:
1585 p
->value
= priv
->wpa_version
;
1587 case IW_AUTH_CIPHER_PAIRWISE
:
1588 p
->value
= priv
->wpa_cipher_pair
;
1590 case IW_AUTH_CIPHER_GROUP
:
1591 p
->value
= priv
->wpa_cipher_group
;
1593 case IW_AUTH_KEY_MGMT
:
1594 p
->value
= priv
->wpa_keymgmt
;
1596 case IW_AUTH_80211_AUTH_ALG
:
1597 p
->value
= priv
->wpa_authalg
;
1600 devdbg(usbdev
, "SIOCGIWAUTH: invalid cmd %d",
1601 wrqu
->param
.flags
& IW_AUTH_INDEX
);
1608 static int rndis_iw_set_encode(struct net_device
*dev
,
1609 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1611 struct usbnet
*usbdev
= netdev_priv(dev
);
1612 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1613 int ret
, index
, key_len
;
1616 index
= (wrqu
->encoding
.flags
& IW_ENCODE_INDEX
);
1618 /* iwconfig gives index as 1 - N */
1622 index
= priv
->encr_tx_key_index
;
1624 if (index
< 0 || index
>= 4) {
1625 devwarn(usbdev
, "encryption index out of range (%u)", index
);
1629 /* remove key if disabled */
1630 if (wrqu
->data
.flags
& IW_ENCODE_DISABLED
) {
1631 if (remove_key(usbdev
, index
, NULL
))
1637 /* global encryption state (for all keys) */
1638 if (wrqu
->data
.flags
& IW_ENCODE_OPEN
)
1639 ret
= set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1640 IW_AUTH_ALG_OPEN_SYSTEM
);
1641 else /*if (wrqu->data.flags & IW_ENCODE_RESTRICTED)*/
1642 ret
= set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1643 IW_AUTH_ALG_SHARED_KEY
);
1647 if (wrqu
->data
.length
> 0) {
1648 key_len
= wrqu
->data
.length
;
1651 /* must be set as tx key */
1652 if (priv
->encr_key_len
[index
] == 0)
1654 key_len
= priv
->encr_key_len
[index
];
1655 key
= priv
->encr_keys
[index
];
1656 priv
->encr_tx_key_index
= index
;
1659 if (add_wep_key(usbdev
, key
, key_len
, index
) != 0)
1662 if (index
== priv
->encr_tx_key_index
)
1663 /* ndis drivers want essid to be set after setting encr */
1664 set_essid(usbdev
, &priv
->essid
);
1670 static int rndis_iw_set_encode_ext(struct net_device
*dev
,
1671 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1673 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1674 struct usbnet
*usbdev
= netdev_priv(dev
);
1675 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1678 keyidx
= wrqu
->encoding
.flags
& IW_ENCODE_INDEX
;
1680 /* iwconfig gives index as 1 - N */
1684 keyidx
= priv
->encr_tx_key_index
;
1686 if (keyidx
< 0 || keyidx
>= 4)
1689 if (ext
->alg
== WPA_ALG_WEP
) {
1690 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1691 priv
->encr_tx_key_index
= keyidx
;
1692 return add_wep_key(usbdev
, ext
->key
, ext
->key_len
, keyidx
);
1695 if ((wrqu
->encoding
.flags
& IW_ENCODE_DISABLED
) ||
1696 ext
->alg
== IW_ENCODE_ALG_NONE
|| ext
->key_len
== 0)
1697 return remove_key(usbdev
, keyidx
, NULL
);
1700 if (ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
)
1701 flags
|= ndis_80211_addkey_set_init_recv_seq
;
1702 if (!(ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
))
1703 flags
|= ndis_80211_addkey_pairwise_key
;
1704 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1705 flags
|= ndis_80211_addkey_transmit_key
;
1707 return add_wpa_key(usbdev
, ext
->key
, ext
->key_len
, keyidx
, &ext
->addr
,
1708 ext
->rx_seq
, ext
->alg
, flags
);
1712 static int rndis_iw_set_genie(struct net_device
*dev
,
1713 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1715 struct usbnet
*usbdev
= netdev_priv(dev
);
1716 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1722 for (j
= 0; j
< wrqu
->data
.length
; j
+= 8)
1724 "SIOCSIWGENIE %04x - "
1725 "%02x %02x %02x %02x %02x %02x %02x %02x", j
,
1726 gie
[j
+ 0], gie
[j
+ 1], gie
[j
+ 2], gie
[j
+ 3],
1727 gie
[j
+ 4], gie
[j
+ 5], gie
[j
+ 6], gie
[j
+ 7]);
1729 /* clear existing IEs */
1730 if (priv
->wpa_ie_len
) {
1731 kfree(priv
->wpa_ie
);
1732 priv
->wpa_ie_len
= 0;
1736 priv
->wpa_ie
= kmalloc(wrqu
->data
.length
, GFP_KERNEL
);
1738 priv
->wpa_ie_len
= wrqu
->data
.length
;
1739 memcpy(priv
->wpa_ie
, extra
, priv
->wpa_ie_len
);
1746 static int rndis_iw_get_genie(struct net_device
*dev
,
1747 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1749 struct usbnet
*usbdev
= netdev_priv(dev
);
1750 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1752 devdbg(usbdev
, "SIOCGIWGENIE");
1754 if (priv
->wpa_ie_len
== 0 || priv
->wpa_ie
== NULL
) {
1755 wrqu
->data
.length
= 0;
1759 if (wrqu
->data
.length
< priv
->wpa_ie_len
)
1762 wrqu
->data
.length
= priv
->wpa_ie_len
;
1763 memcpy(extra
, priv
->wpa_ie
, priv
->wpa_ie_len
);
1769 static int rndis_iw_set_rts(struct net_device
*dev
,
1770 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1772 struct usbnet
*usbdev
= netdev_priv(dev
);
1774 devdbg(usbdev
, "SIOCSIWRTS");
1776 tmp
= cpu_to_le32(wrqu
->rts
.value
);
1777 return rndis_set_oid(usbdev
, OID_802_11_RTS_THRESHOLD
, &tmp
,
1782 static int rndis_iw_get_rts(struct net_device
*dev
,
1783 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1785 struct usbnet
*usbdev
= netdev_priv(dev
);
1790 ret
= rndis_query_oid(usbdev
, OID_802_11_RTS_THRESHOLD
, &tmp
, &len
);
1792 wrqu
->rts
.value
= le32_to_cpu(tmp
);
1793 wrqu
->rts
.flags
= 1;
1794 wrqu
->rts
.disabled
= 0;
1797 devdbg(usbdev
, "SIOCGIWRTS: %d", wrqu
->rts
.value
);
1803 static int rndis_iw_set_frag(struct net_device
*dev
,
1804 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1806 struct usbnet
*usbdev
= netdev_priv(dev
);
1809 devdbg(usbdev
, "SIOCSIWFRAG");
1811 tmp
= cpu_to_le32(wrqu
->frag
.value
);
1812 return rndis_set_oid(usbdev
, OID_802_11_FRAGMENTATION_THRESHOLD
, &tmp
,
1817 static int rndis_iw_get_frag(struct net_device
*dev
,
1818 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1820 struct usbnet
*usbdev
= netdev_priv(dev
);
1825 ret
= rndis_query_oid(usbdev
, OID_802_11_FRAGMENTATION_THRESHOLD
, &tmp
,
1828 wrqu
->frag
.value
= le32_to_cpu(tmp
);
1829 wrqu
->frag
.flags
= 1;
1830 wrqu
->frag
.disabled
= 0;
1832 devdbg(usbdev
, "SIOCGIWFRAG: %d", wrqu
->frag
.value
);
1837 static int rndis_iw_set_freq(struct net_device
*dev
,
1838 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1840 struct usbnet
*usbdev
= netdev_priv(dev
);
1841 struct ndis_80211_conf config
;
1842 unsigned int dsconfig
;
1845 /* this OID is valid only when not associated */
1846 if (is_associated(usbdev
))
1850 if (freq_to_dsconfig(&wrqu
->freq
, &dsconfig
))
1853 len
= sizeof(config
);
1854 ret
= rndis_query_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
, &len
);
1856 devdbg(usbdev
, "SIOCSIWFREQ: querying configuration failed");
1860 config
.ds_config
= cpu_to_le32(dsconfig
);
1862 devdbg(usbdev
, "SIOCSIWFREQ: %d * 10^%d", wrqu
->freq
.m
, wrqu
->freq
.e
);
1863 return rndis_set_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
,
1868 static int rndis_iw_get_freq(struct net_device
*dev
,
1869 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1871 struct usbnet
*usbdev
= netdev_priv(dev
);
1872 struct ndis_80211_conf config
;
1875 len
= sizeof(config
);
1876 ret
= rndis_query_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
, &len
);
1878 dsconfig_to_freq(le32_to_cpu(config
.ds_config
), &wrqu
->freq
);
1880 devdbg(usbdev
, "SIOCGIWFREQ: %d", wrqu
->freq
.m
);
1885 static int rndis_iw_get_txpower(struct net_device
*dev
,
1886 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1888 struct usbnet
*usbdev
= netdev_priv(dev
);
1889 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1892 if (priv
->radio_on
) {
1893 /* fake since changing tx_power (by userlevel) not supported */
1894 tx_power
= cpu_to_le32(get_bcm4320_power(priv
));
1896 wrqu
->txpower
.flags
= IW_TXPOW_MWATT
;
1897 wrqu
->txpower
.value
= le32_to_cpu(tx_power
);
1898 wrqu
->txpower
.disabled
= 0;
1900 wrqu
->txpower
.flags
= IW_TXPOW_MWATT
;
1901 wrqu
->txpower
.value
= 0;
1902 wrqu
->txpower
.disabled
= 1;
1905 devdbg(usbdev
, "SIOCGIWTXPOW: %d", wrqu
->txpower
.value
);
1911 static int rndis_iw_set_txpower(struct net_device
*dev
,
1912 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1914 struct usbnet
*usbdev
= netdev_priv(dev
);
1915 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1916 __le32 tx_power
= 0;
1918 if (!wrqu
->txpower
.disabled
) {
1919 if (wrqu
->txpower
.flags
== IW_TXPOW_MWATT
)
1920 tx_power
= cpu_to_le32(wrqu
->txpower
.value
);
1921 else { /* wrqu->txpower.flags == IW_TXPOW_DBM */
1922 if (wrqu
->txpower
.value
> 20)
1923 tx_power
= cpu_to_le32(128);
1924 else if (wrqu
->txpower
.value
< -43)
1925 tx_power
= cpu_to_le32(127);
1928 tmp
= wrqu
->txpower
.value
;
1931 tx_power
= cpu_to_le32((unsigned char)tmp
);
1936 devdbg(usbdev
, "SIOCSIWTXPOW: %d", le32_to_cpu(tx_power
));
1938 if (le32_to_cpu(tx_power
) != 0) {
1939 /* txpower unsupported, just turn radio on */
1940 if (!priv
->radio_on
)
1941 return disassociate(usbdev
, 1);
1942 return 0; /* all ready on */
1945 /* tx_power == 0, turn off radio */
1946 return disassociate(usbdev
, 0);
1950 static int rndis_iw_get_rate(struct net_device
*dev
,
1951 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1953 struct usbnet
*usbdev
= netdev_priv(dev
);
1958 ret
= rndis_query_oid(usbdev
, OID_GEN_LINK_SPEED
, &tmp
, &len
);
1960 wrqu
->bitrate
.value
= le32_to_cpu(tmp
) * 100;
1961 wrqu
->bitrate
.disabled
= 0;
1962 wrqu
->bitrate
.flags
= 1;
1968 static int rndis_iw_set_mlme(struct net_device
*dev
,
1969 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1971 struct usbnet
*usbdev
= netdev_priv(dev
);
1972 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1973 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
1974 unsigned char bssid
[ETH_ALEN
];
1976 get_bssid(usbdev
, bssid
);
1978 if (memcmp(bssid
, mlme
->addr
.sa_data
, ETH_ALEN
))
1981 switch (mlme
->cmd
) {
1982 case IW_MLME_DEAUTH
:
1983 return deauthenticate(usbdev
);
1984 case IW_MLME_DISASSOC
:
1985 return disassociate(usbdev
, priv
->radio_on
);
1994 static struct iw_statistics
*rndis_get_wireless_stats(struct net_device
*dev
)
1996 struct usbnet
*usbdev
= netdev_priv(dev
);
1997 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
1998 unsigned long flags
;
2000 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2001 memcpy(&priv
->iwstats
, &priv
->privstats
, sizeof(priv
->iwstats
));
2002 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2004 return &priv
->iwstats
;
2008 #define IW_IOCTL(x) [(x) - SIOCSIWCOMMIT]
2009 static const iw_handler rndis_iw_handler
[] =
2011 IW_IOCTL(SIOCSIWCOMMIT
) = rndis_iw_commit
,
2012 IW_IOCTL(SIOCGIWNAME
) = (iw_handler
) cfg80211_wext_giwname
,
2013 IW_IOCTL(SIOCSIWFREQ
) = rndis_iw_set_freq
,
2014 IW_IOCTL(SIOCGIWFREQ
) = rndis_iw_get_freq
,
2015 IW_IOCTL(SIOCSIWMODE
) = (iw_handler
) cfg80211_wext_siwmode
,
2016 IW_IOCTL(SIOCGIWMODE
) = (iw_handler
) cfg80211_wext_giwmode
,
2017 IW_IOCTL(SIOCGIWRANGE
) = (iw_handler
) cfg80211_wext_giwrange
,
2018 IW_IOCTL(SIOCSIWAP
) = rndis_iw_set_bssid
,
2019 IW_IOCTL(SIOCGIWAP
) = rndis_iw_get_bssid
,
2020 IW_IOCTL(SIOCSIWSCAN
) = (iw_handler
) cfg80211_wext_siwscan
,
2021 IW_IOCTL(SIOCGIWSCAN
) = (iw_handler
) cfg80211_wext_giwscan
,
2022 IW_IOCTL(SIOCSIWESSID
) = rndis_iw_set_essid
,
2023 IW_IOCTL(SIOCGIWESSID
) = rndis_iw_get_essid
,
2024 IW_IOCTL(SIOCGIWRATE
) = rndis_iw_get_rate
,
2025 IW_IOCTL(SIOCSIWRTS
) = rndis_iw_set_rts
,
2026 IW_IOCTL(SIOCGIWRTS
) = rndis_iw_get_rts
,
2027 IW_IOCTL(SIOCSIWFRAG
) = rndis_iw_set_frag
,
2028 IW_IOCTL(SIOCGIWFRAG
) = rndis_iw_get_frag
,
2029 IW_IOCTL(SIOCSIWTXPOW
) = rndis_iw_set_txpower
,
2030 IW_IOCTL(SIOCGIWTXPOW
) = rndis_iw_get_txpower
,
2031 IW_IOCTL(SIOCSIWENCODE
) = rndis_iw_set_encode
,
2032 IW_IOCTL(SIOCSIWENCODEEXT
) = rndis_iw_set_encode_ext
,
2033 IW_IOCTL(SIOCSIWAUTH
) = rndis_iw_set_auth
,
2034 IW_IOCTL(SIOCGIWAUTH
) = rndis_iw_get_auth
,
2035 IW_IOCTL(SIOCSIWGENIE
) = rndis_iw_set_genie
,
2036 IW_IOCTL(SIOCGIWGENIE
) = rndis_iw_get_genie
,
2037 IW_IOCTL(SIOCSIWMLME
) = rndis_iw_set_mlme
,
2040 static const iw_handler rndis_wext_private_handler
[] = {
2043 static const struct iw_priv_args rndis_wext_private_args
[] = {
2047 static const struct iw_handler_def rndis_iw_handlers
= {
2048 .num_standard
= ARRAY_SIZE(rndis_iw_handler
),
2049 .num_private
= ARRAY_SIZE(rndis_wext_private_handler
),
2050 .num_private_args
= ARRAY_SIZE(rndis_wext_private_args
),
2051 .standard
= (iw_handler
*)rndis_iw_handler
,
2052 .private = (iw_handler
*)rndis_wext_private_handler
,
2053 .private_args
= (struct iw_priv_args
*)rndis_wext_private_args
,
2054 .get_wireless_stats
= rndis_get_wireless_stats
,
2058 static void rndis_wext_worker(struct work_struct
*work
)
2060 struct rndis_wext_private
*priv
=
2061 container_of(work
, struct rndis_wext_private
, work
);
2062 struct usbnet
*usbdev
= priv
->usbdev
;
2063 union iwreq_data evt
;
2064 unsigned char bssid
[ETH_ALEN
];
2065 struct ndis_80211_assoc_info
*info
;
2066 int assoc_size
= sizeof(*info
) + IW_CUSTOM_MAX
+ 32;
2069 if (test_and_clear_bit(WORK_LINK_UP
, &priv
->work_pending
)) {
2070 netif_carrier_on(usbdev
->net
);
2072 info
= kzalloc(assoc_size
, GFP_KERNEL
);
2076 /* Get association info IEs from device and send them back to
2078 ret
= get_association_info(usbdev
, info
, assoc_size
);
2080 evt
.data
.length
= le32_to_cpu(info
->req_ie_length
);
2081 if (evt
.data
.length
> 0) {
2082 offset
= le32_to_cpu(info
->offset_req_ies
);
2083 wireless_send_event(usbdev
->net
,
2084 IWEVASSOCREQIE
, &evt
,
2085 (char *)info
+ offset
);
2088 evt
.data
.length
= le32_to_cpu(info
->resp_ie_length
);
2089 if (evt
.data
.length
> 0) {
2090 offset
= le32_to_cpu(info
->offset_resp_ies
);
2091 wireless_send_event(usbdev
->net
,
2092 IWEVASSOCRESPIE
, &evt
,
2093 (char *)info
+ offset
);
2100 ret
= get_bssid(usbdev
, bssid
);
2103 evt
.data
.length
= 0;
2104 memcpy(evt
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
2105 wireless_send_event(usbdev
->net
, SIOCGIWAP
, &evt
, NULL
);
2109 if (test_and_clear_bit(WORK_LINK_DOWN
, &priv
->work_pending
)) {
2110 netif_carrier_off(usbdev
->net
);
2113 evt
.data
.length
= 0;
2114 memset(evt
.ap_addr
.sa_data
, 0, ETH_ALEN
);
2115 wireless_send_event(usbdev
->net
, SIOCGIWAP
, &evt
, NULL
);
2118 if (test_and_clear_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
))
2119 set_multicast_list(usbdev
);
2122 static void rndis_wext_set_multicast_list(struct net_device
*dev
)
2124 struct usbnet
*usbdev
= netdev_priv(dev
);
2125 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
2127 if (test_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
))
2130 set_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
);
2131 queue_work(priv
->workqueue
, &priv
->work
);
2134 static void rndis_wext_link_change(struct usbnet
*usbdev
, int state
)
2136 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
2138 /* queue work to avoid recursive calls into rndis_command */
2139 set_bit(state
? WORK_LINK_UP
: WORK_LINK_DOWN
, &priv
->work_pending
);
2140 queue_work(priv
->workqueue
, &priv
->work
);
2144 static int rndis_wext_get_caps(struct usbnet
*usbdev
)
2149 } networks_supported
;
2150 int len
, retval
, i
, n
;
2151 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
2153 /* determine supported modes */
2154 len
= sizeof(networks_supported
);
2155 retval
= rndis_query_oid(usbdev
, OID_802_11_NETWORK_TYPES_SUPPORTED
,
2156 &networks_supported
, &len
);
2158 n
= le32_to_cpu(networks_supported
.num_items
);
2161 for (i
= 0; i
< n
; i
++) {
2162 switch (le32_to_cpu(networks_supported
.items
[i
])) {
2163 case ndis_80211_type_freq_hop
:
2164 case ndis_80211_type_direct_seq
:
2165 priv
->caps
|= CAP_MODE_80211B
;
2167 case ndis_80211_type_ofdm_a
:
2168 priv
->caps
|= CAP_MODE_80211A
;
2170 case ndis_80211_type_ofdm_g
:
2171 priv
->caps
|= CAP_MODE_80211G
;
2181 #define STATS_UPDATE_JIFFIES (HZ)
2182 static void rndis_update_wireless_stats(struct work_struct
*work
)
2184 struct rndis_wext_private
*priv
=
2185 container_of(work
, struct rndis_wext_private
, stats_work
.work
);
2186 struct usbnet
*usbdev
= priv
->usbdev
;
2187 struct iw_statistics iwstats
;
2190 unsigned long flags
;
2191 int update_jiffies
= STATS_UPDATE_JIFFIES
;
2194 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2195 memcpy(&iwstats
, &priv
->privstats
, sizeof(iwstats
));
2196 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2198 /* only update stats when connected */
2199 if (!is_associated(usbdev
)) {
2200 iwstats
.qual
.qual
= 0;
2201 iwstats
.qual
.level
= 0;
2202 iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2203 | IW_QUAL_LEVEL_UPDATED
2204 | IW_QUAL_NOISE_INVALID
2205 | IW_QUAL_QUAL_INVALID
2206 | IW_QUAL_LEVEL_INVALID
;
2211 ret
= rndis_query_oid(usbdev
, OID_802_11_RSSI
, &rssi
, &len
);
2213 devdbg(usbdev
, "stats: OID_802_11_RSSI -> %d, rssi:%d", ret
,
2216 memset(&iwstats
.qual
, 0, sizeof(iwstats
.qual
));
2217 iwstats
.qual
.qual
= level_to_qual(le32_to_cpu(rssi
));
2218 iwstats
.qual
.level
= level_to_qual(le32_to_cpu(rssi
));
2219 iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2220 | IW_QUAL_LEVEL_UPDATED
2221 | IW_QUAL_NOISE_INVALID
;
2224 memset(&iwstats
.discard
, 0, sizeof(iwstats
.discard
));
2227 ret
= rndis_query_oid(usbdev
, OID_GEN_XMIT_ERROR
, &tmp
, &len
);
2229 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2232 ret
= rndis_query_oid(usbdev
, OID_GEN_RCV_ERROR
, &tmp
, &len
);
2234 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2237 ret
= rndis_query_oid(usbdev
, OID_GEN_RCV_NO_BUFFER
, &tmp
, &len
);
2239 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2241 /* Workaround transfer stalls on poor quality links.
2242 * TODO: find right way to fix these stalls (as stalls do not happen
2243 * with ndiswrapper/windows driver). */
2244 if (iwstats
.qual
.qual
<= 25) {
2245 /* Decrease stats worker interval to catch stalls.
2246 * faster. Faster than 400-500ms causes packet loss,
2247 * Slower doesn't catch stalls fast enough.
2249 j
= msecs_to_jiffies(priv
->param_workaround_interval
);
2250 if (j
> STATS_UPDATE_JIFFIES
)
2251 j
= STATS_UPDATE_JIFFIES
;
2256 /* Send scan OID. Use of both OIDs is required to get device
2259 tmp
= cpu_to_le32(1);
2260 rndis_set_oid(usbdev
, OID_802_11_BSSID_LIST_SCAN
, &tmp
,
2263 len
= CONTROL_BUFFER_SIZE
;
2264 buf
= kmalloc(len
, GFP_KERNEL
);
2268 rndis_query_oid(usbdev
, OID_802_11_BSSID_LIST
, buf
, &len
);
2272 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2273 memcpy(&priv
->privstats
, &iwstats
, sizeof(iwstats
));
2274 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2276 if (update_jiffies
>= HZ
)
2277 update_jiffies
= round_jiffies_relative(update_jiffies
);
2279 j
= round_jiffies_relative(update_jiffies
);
2280 if (abs(j
- update_jiffies
) <= 10)
2284 queue_delayed_work(priv
->workqueue
, &priv
->stats_work
, update_jiffies
);
2288 static int bcm4320a_early_init(struct usbnet
*usbdev
)
2290 /* bcm4320a doesn't handle configuration parameters well. Try
2291 * set any and you get partially zeroed mac and broken device.
2298 static int bcm4320b_early_init(struct usbnet
*usbdev
)
2300 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
2303 /* Early initialization settings, setting these won't have effect
2304 * if called after generic_rndis_bind().
2307 priv
->param_country
[0] = modparam_country
[0];
2308 priv
->param_country
[1] = modparam_country
[1];
2309 priv
->param_country
[2] = 0;
2310 priv
->param_frameburst
= modparam_frameburst
;
2311 priv
->param_afterburner
= modparam_afterburner
;
2312 priv
->param_power_save
= modparam_power_save
;
2313 priv
->param_power_output
= modparam_power_output
;
2314 priv
->param_roamtrigger
= modparam_roamtrigger
;
2315 priv
->param_roamdelta
= modparam_roamdelta
;
2317 priv
->param_country
[0] = toupper(priv
->param_country
[0]);
2318 priv
->param_country
[1] = toupper(priv
->param_country
[1]);
2319 /* doesn't support EU as country code, use FI instead */
2320 if (!strcmp(priv
->param_country
, "EU"))
2321 strcpy(priv
->param_country
, "FI");
2323 if (priv
->param_power_save
< 0)
2324 priv
->param_power_save
= 0;
2325 else if (priv
->param_power_save
> 2)
2326 priv
->param_power_save
= 2;
2328 if (priv
->param_power_output
< 0)
2329 priv
->param_power_output
= 0;
2330 else if (priv
->param_power_output
> 3)
2331 priv
->param_power_output
= 3;
2333 if (priv
->param_roamtrigger
< -80)
2334 priv
->param_roamtrigger
= -80;
2335 else if (priv
->param_roamtrigger
> -60)
2336 priv
->param_roamtrigger
= -60;
2338 if (priv
->param_roamdelta
< 0)
2339 priv
->param_roamdelta
= 0;
2340 else if (priv
->param_roamdelta
> 2)
2341 priv
->param_roamdelta
= 2;
2343 if (modparam_workaround_interval
< 0)
2344 priv
->param_workaround_interval
= 500;
2346 priv
->param_workaround_interval
= modparam_workaround_interval
;
2348 rndis_set_config_parameter_str(usbdev
, "Country", priv
->param_country
);
2349 rndis_set_config_parameter_str(usbdev
, "FrameBursting",
2350 priv
->param_frameburst
? "1" : "0");
2351 rndis_set_config_parameter_str(usbdev
, "Afterburner",
2352 priv
->param_afterburner
? "1" : "0");
2353 sprintf(buf
, "%d", priv
->param_power_save
);
2354 rndis_set_config_parameter_str(usbdev
, "PowerSaveMode", buf
);
2355 sprintf(buf
, "%d", priv
->param_power_output
);
2356 rndis_set_config_parameter_str(usbdev
, "PwrOut", buf
);
2357 sprintf(buf
, "%d", priv
->param_roamtrigger
);
2358 rndis_set_config_parameter_str(usbdev
, "RoamTrigger", buf
);
2359 sprintf(buf
, "%d", priv
->param_roamdelta
);
2360 rndis_set_config_parameter_str(usbdev
, "RoamDelta", buf
);
2365 /* same as rndis_netdev_ops but with local multicast handler */
2366 static const struct net_device_ops rndis_wext_netdev_ops
= {
2367 .ndo_open
= usbnet_open
,
2368 .ndo_stop
= usbnet_stop
,
2369 .ndo_start_xmit
= usbnet_start_xmit
,
2370 .ndo_tx_timeout
= usbnet_tx_timeout
,
2371 .ndo_set_mac_address
= eth_mac_addr
,
2372 .ndo_validate_addr
= eth_validate_addr
,
2373 .ndo_set_multicast_list
= rndis_wext_set_multicast_list
,
2377 static int rndis_wext_bind(struct usbnet
*usbdev
, struct usb_interface
*intf
)
2379 struct wiphy
*wiphy
;
2380 struct rndis_wext_private
*priv
;
2384 /* allocate wiphy and rndis private data
2385 * NOTE: We only support a single virtual interface, so wiphy
2386 * and wireless_dev are somewhat synonymous for this device.
2388 wiphy
= wiphy_new(&rndis_config_ops
, sizeof(struct rndis_wext_private
));
2392 priv
= wiphy_priv(wiphy
);
2393 usbdev
->net
->ieee80211_ptr
= &priv
->wdev
;
2394 priv
->wdev
.wiphy
= wiphy
;
2395 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2397 /* These have to be initialized before calling generic_rndis_bind().
2398 * Otherwise we'll be in big trouble in rndis_wext_early_init().
2400 usbdev
->driver_priv
= priv
;
2401 usbdev
->net
->wireless_handlers
= &rndis_iw_handlers
;
2402 priv
->usbdev
= usbdev
;
2404 mutex_init(&priv
->command_lock
);
2405 spin_lock_init(&priv
->stats_lock
);
2407 /* because rndis_command() sleeps we need to use workqueue */
2408 priv
->workqueue
= create_singlethread_workqueue("rndis_wlan");
2409 INIT_WORK(&priv
->work
, rndis_wext_worker
);
2410 INIT_DELAYED_WORK(&priv
->stats_work
, rndis_update_wireless_stats
);
2411 INIT_DELAYED_WORK(&priv
->scan_work
, rndis_get_scan_results
);
2413 /* try bind rndis_host */
2414 retval
= generic_rndis_bind(usbdev
, intf
, FLAG_RNDIS_PHYM_WIRELESS
);
2418 /* generic_rndis_bind set packet filter to multicast_all+
2419 * promisc mode which doesn't work well for our devices (device
2420 * picks up rssi to closest station instead of to access point).
2422 * rndis_host wants to avoid all OID as much as possible
2423 * so do promisc/multicast handling in rndis_wext.
2425 usbdev
->net
->netdev_ops
= &rndis_wext_netdev_ops
;
2427 tmp
= RNDIS_PACKET_TYPE_DIRECTED
| RNDIS_PACKET_TYPE_BROADCAST
;
2428 retval
= rndis_set_oid(usbdev
, OID_GEN_CURRENT_PACKET_FILTER
, &tmp
,
2432 retval
= rndis_query_oid(usbdev
, OID_802_3_MAXIMUM_LIST_SIZE
, &tmp
,
2434 priv
->multicast_size
= le32_to_cpu(tmp
);
2435 if (retval
< 0 || priv
->multicast_size
< 0)
2436 priv
->multicast_size
= 0;
2437 if (priv
->multicast_size
> 0)
2438 usbdev
->net
->flags
|= IFF_MULTICAST
;
2440 usbdev
->net
->flags
&= ~IFF_MULTICAST
;
2442 priv
->iwstats
.qual
.qual
= 0;
2443 priv
->iwstats
.qual
.level
= 0;
2444 priv
->iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2445 | IW_QUAL_LEVEL_UPDATED
2446 | IW_QUAL_NOISE_INVALID
2447 | IW_QUAL_QUAL_INVALID
2448 | IW_QUAL_LEVEL_INVALID
;
2450 /* fill-out wiphy structure and register w/ cfg80211 */
2451 memcpy(wiphy
->perm_addr
, usbdev
->net
->dev_addr
, ETH_ALEN
);
2452 wiphy
->privid
= rndis_wiphy_privid
;
2453 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
)
2454 | BIT(NL80211_IFTYPE_ADHOC
);
2455 wiphy
->max_scan_ssids
= 1;
2457 /* TODO: fill-out band information based on priv->caps */
2458 rndis_wext_get_caps(usbdev
);
2460 memcpy(priv
->channels
, rndis_channels
, sizeof(rndis_channels
));
2461 memcpy(priv
->rates
, rndis_rates
, sizeof(rndis_rates
));
2462 priv
->band
.channels
= priv
->channels
;
2463 priv
->band
.n_channels
= ARRAY_SIZE(rndis_channels
);
2464 priv
->band
.bitrates
= priv
->rates
;
2465 priv
->band
.n_bitrates
= ARRAY_SIZE(rndis_rates
);
2466 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &priv
->band
;
2467 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_UNSPEC
;
2469 set_wiphy_dev(wiphy
, &usbdev
->udev
->dev
);
2471 if (wiphy_register(wiphy
)) {
2476 set_default_iw_params(usbdev
);
2480 disassociate(usbdev
, 1);
2481 netif_carrier_off(usbdev
->net
);
2483 queue_delayed_work(priv
->workqueue
, &priv
->stats_work
,
2484 round_jiffies_relative(STATS_UPDATE_JIFFIES
));
2489 cancel_delayed_work_sync(&priv
->stats_work
);
2490 cancel_delayed_work_sync(&priv
->scan_work
);
2491 cancel_work_sync(&priv
->work
);
2492 flush_workqueue(priv
->workqueue
);
2493 destroy_workqueue(priv
->workqueue
);
2500 static void rndis_wext_unbind(struct usbnet
*usbdev
, struct usb_interface
*intf
)
2502 struct rndis_wext_private
*priv
= get_rndis_wext_priv(usbdev
);
2504 /* turn radio off */
2505 disassociate(usbdev
, 0);
2507 cancel_delayed_work_sync(&priv
->stats_work
);
2508 cancel_delayed_work_sync(&priv
->scan_work
);
2509 cancel_work_sync(&priv
->work
);
2510 flush_workqueue(priv
->workqueue
);
2511 destroy_workqueue(priv
->workqueue
);
2513 if (priv
&& priv
->wpa_ie_len
)
2514 kfree(priv
->wpa_ie
);
2516 rndis_unbind(usbdev
, intf
);
2518 wiphy_unregister(priv
->wdev
.wiphy
);
2519 wiphy_free(priv
->wdev
.wiphy
);
2523 static int rndis_wext_reset(struct usbnet
*usbdev
)
2525 return deauthenticate(usbdev
);
2529 static const struct driver_info bcm4320b_info
= {
2530 .description
= "Wireless RNDIS device, BCM4320b based",
2531 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2532 .bind
= rndis_wext_bind
,
2533 .unbind
= rndis_wext_unbind
,
2534 .status
= rndis_status
,
2535 .rx_fixup
= rndis_rx_fixup
,
2536 .tx_fixup
= rndis_tx_fixup
,
2537 .reset
= rndis_wext_reset
,
2538 .early_init
= bcm4320b_early_init
,
2539 .link_change
= rndis_wext_link_change
,
2542 static const struct driver_info bcm4320a_info
= {
2543 .description
= "Wireless RNDIS device, BCM4320a based",
2544 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2545 .bind
= rndis_wext_bind
,
2546 .unbind
= rndis_wext_unbind
,
2547 .status
= rndis_status
,
2548 .rx_fixup
= rndis_rx_fixup
,
2549 .tx_fixup
= rndis_tx_fixup
,
2550 .reset
= rndis_wext_reset
,
2551 .early_init
= bcm4320a_early_init
,
2552 .link_change
= rndis_wext_link_change
,
2555 static const struct driver_info rndis_wext_info
= {
2556 .description
= "Wireless RNDIS device",
2557 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2558 .bind
= rndis_wext_bind
,
2559 .unbind
= rndis_wext_unbind
,
2560 .status
= rndis_status
,
2561 .rx_fixup
= rndis_rx_fixup
,
2562 .tx_fixup
= rndis_tx_fixup
,
2563 .reset
= rndis_wext_reset
,
2564 .early_init
= bcm4320a_early_init
,
2565 .link_change
= rndis_wext_link_change
,
2568 /*-------------------------------------------------------------------------*/
2570 static const struct usb_device_id products
[] = {
2571 #define RNDIS_MASTER_INTERFACE \
2572 .bInterfaceClass = USB_CLASS_COMM, \
2573 .bInterfaceSubClass = 2 /* ACM */, \
2574 .bInterfaceProtocol = 0x0ff
2576 /* INF driver for these devices have DriverVer >= 4.xx.xx.xx and many custom
2577 * parameters available. Chipset marked as 'BCM4320SKFBG' in NDISwrapper-wiki.
2580 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2581 | USB_DEVICE_ID_MATCH_DEVICE
,
2583 .idProduct
= 0x00bc, /* Buffalo WLI-U2-KG125S */
2584 RNDIS_MASTER_INTERFACE
,
2585 .driver_info
= (unsigned long) &bcm4320b_info
,
2587 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2588 | USB_DEVICE_ID_MATCH_DEVICE
,
2590 .idProduct
= 0x011b, /* U.S. Robotics USR5421 */
2591 RNDIS_MASTER_INTERFACE
,
2592 .driver_info
= (unsigned long) &bcm4320b_info
,
2594 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2595 | USB_DEVICE_ID_MATCH_DEVICE
,
2597 .idProduct
= 0x011b, /* Belkin F5D7051 */
2598 RNDIS_MASTER_INTERFACE
,
2599 .driver_info
= (unsigned long) &bcm4320b_info
,
2601 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2602 | USB_DEVICE_ID_MATCH_DEVICE
,
2603 .idVendor
= 0x1799, /* Belkin has two vendor ids */
2604 .idProduct
= 0x011b, /* Belkin F5D7051 */
2605 RNDIS_MASTER_INTERFACE
,
2606 .driver_info
= (unsigned long) &bcm4320b_info
,
2608 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2609 | USB_DEVICE_ID_MATCH_DEVICE
,
2611 .idProduct
= 0x0014, /* Linksys WUSB54GSv2 */
2612 RNDIS_MASTER_INTERFACE
,
2613 .driver_info
= (unsigned long) &bcm4320b_info
,
2615 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2616 | USB_DEVICE_ID_MATCH_DEVICE
,
2618 .idProduct
= 0x0026, /* Linksys WUSB54GSC */
2619 RNDIS_MASTER_INTERFACE
,
2620 .driver_info
= (unsigned long) &bcm4320b_info
,
2622 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2623 | USB_DEVICE_ID_MATCH_DEVICE
,
2625 .idProduct
= 0x1717, /* Asus WL169gE */
2626 RNDIS_MASTER_INTERFACE
,
2627 .driver_info
= (unsigned long) &bcm4320b_info
,
2629 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2630 | USB_DEVICE_ID_MATCH_DEVICE
,
2632 .idProduct
= 0xd11b, /* Eminent EM4045 */
2633 RNDIS_MASTER_INTERFACE
,
2634 .driver_info
= (unsigned long) &bcm4320b_info
,
2636 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2637 | USB_DEVICE_ID_MATCH_DEVICE
,
2639 .idProduct
= 0x0715, /* BT Voyager 1055 */
2640 RNDIS_MASTER_INTERFACE
,
2641 .driver_info
= (unsigned long) &bcm4320b_info
,
2643 /* These devices have DriverVer < 4.xx.xx.xx and do not have any custom
2644 * parameters available, hardware probably contain older firmware version with
2645 * no way of updating. Chipset marked as 'BCM4320????' in NDISwrapper-wiki.
2648 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2649 | USB_DEVICE_ID_MATCH_DEVICE
,
2651 .idProduct
= 0x000e, /* Linksys WUSB54GSv1 */
2652 RNDIS_MASTER_INTERFACE
,
2653 .driver_info
= (unsigned long) &bcm4320a_info
,
2655 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2656 | USB_DEVICE_ID_MATCH_DEVICE
,
2658 .idProduct
= 0x0111, /* U.S. Robotics USR5420 */
2659 RNDIS_MASTER_INTERFACE
,
2660 .driver_info
= (unsigned long) &bcm4320a_info
,
2662 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2663 | USB_DEVICE_ID_MATCH_DEVICE
,
2665 .idProduct
= 0x004b, /* BUFFALO WLI-USB-G54 */
2666 RNDIS_MASTER_INTERFACE
,
2667 .driver_info
= (unsigned long) &bcm4320a_info
,
2669 /* Generic Wireless RNDIS devices that we don't have exact
2670 * idVendor/idProduct/chip yet.
2673 /* RNDIS is MSFT's un-official variant of CDC ACM */
2674 USB_INTERFACE_INFO(USB_CLASS_COMM
, 2 /* ACM */, 0x0ff),
2675 .driver_info
= (unsigned long) &rndis_wext_info
,
2677 /* "ActiveSync" is an undocumented variant of RNDIS, used in WM5 */
2678 USB_INTERFACE_INFO(USB_CLASS_MISC
, 1, 1),
2679 .driver_info
= (unsigned long) &rndis_wext_info
,
2683 MODULE_DEVICE_TABLE(usb
, products
);
2685 static struct usb_driver rndis_wlan_driver
= {
2686 .name
= "rndis_wlan",
2687 .id_table
= products
,
2688 .probe
= usbnet_probe
,
2689 .disconnect
= usbnet_disconnect
,
2690 .suspend
= usbnet_suspend
,
2691 .resume
= usbnet_resume
,
2694 static int __init
rndis_wlan_init(void)
2696 return usb_register(&rndis_wlan_driver
);
2698 module_init(rndis_wlan_init
);
2700 static void __exit
rndis_wlan_exit(void)
2702 usb_deregister(&rndis_wlan_driver
);
2704 module_exit(rndis_wlan_exit
);
2706 MODULE_AUTHOR("Bjorge Dijkstra");
2707 MODULE_AUTHOR("Jussi Kivilinna");
2708 MODULE_DESCRIPTION("Driver for RNDIS based USB Wireless adapters");
2709 MODULE_LICENSE("GPL");