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_wlan_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
,
424 struct net_device
*dev
,
425 enum nl80211_iftype type
, u32
*flags
,
426 struct vif_params
*params
);
428 static int rndis_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
429 struct cfg80211_scan_request
*request
);
431 static struct cfg80211_ops rndis_config_ops
= {
432 .change_virtual_intf
= rndis_change_virtual_intf
,
436 static void *rndis_wiphy_privid
= &rndis_wiphy_privid
;
438 static const int bcm4320_power_output
[4] = { 25, 50, 75, 100 };
440 static const unsigned char zero_bssid
[ETH_ALEN
] = {0,};
441 static const unsigned char ffff_bssid
[ETH_ALEN
] = { 0xff, 0xff, 0xff,
445 static struct rndis_wlan_private
*get_rndis_wlan_priv(struct usbnet
*dev
)
447 return (struct rndis_wlan_private
*)dev
->driver_priv
;
451 static u32
get_bcm4320_power(struct rndis_wlan_private
*priv
)
453 return BCM4320_DEFAULT_TXPOWER
*
454 bcm4320_power_output
[priv
->param_power_output
] / 100;
458 /* translate error code */
459 static int rndis_error_status(__le32 rndis_status
)
462 switch (rndis_status
) {
463 case RNDIS_STATUS_SUCCESS
:
466 case RNDIS_STATUS_FAILURE
:
467 case RNDIS_STATUS_INVALID_DATA
:
470 case RNDIS_STATUS_NOT_SUPPORTED
:
473 case RNDIS_STATUS_ADAPTER_NOT_READY
:
474 case RNDIS_STATUS_ADAPTER_NOT_OPEN
:
482 static int rndis_query_oid(struct usbnet
*dev
, __le32 oid
, void *data
, int *len
)
484 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(dev
);
487 struct rndis_msg_hdr
*header
;
488 struct rndis_query
*get
;
489 struct rndis_query_c
*get_c
;
493 buflen
= *len
+ sizeof(*u
.get
);
494 if (buflen
< CONTROL_BUFFER_SIZE
)
495 buflen
= CONTROL_BUFFER_SIZE
;
497 if (buflen
> COMMAND_BUFFER_SIZE
) {
498 u
.buf
= kmalloc(buflen
, GFP_KERNEL
);
502 u
.buf
= priv
->command_buffer
;
505 mutex_lock(&priv
->command_lock
);
507 memset(u
.get
, 0, sizeof *u
.get
);
508 u
.get
->msg_type
= RNDIS_MSG_QUERY
;
509 u
.get
->msg_len
= cpu_to_le32(sizeof *u
.get
);
512 ret
= rndis_command(dev
, u
.header
, buflen
);
514 ret
= le32_to_cpu(u
.get_c
->len
);
515 *len
= (*len
> ret
) ? ret
: *len
;
516 memcpy(data
, u
.buf
+ le32_to_cpu(u
.get_c
->offset
) + 8, *len
);
517 ret
= rndis_error_status(u
.get_c
->status
);
520 mutex_unlock(&priv
->command_lock
);
522 if (u
.buf
!= priv
->command_buffer
)
528 static int rndis_set_oid(struct usbnet
*dev
, __le32 oid
, void *data
, int len
)
530 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(dev
);
533 struct rndis_msg_hdr
*header
;
534 struct rndis_set
*set
;
535 struct rndis_set_c
*set_c
;
539 buflen
= len
+ sizeof(*u
.set
);
540 if (buflen
< CONTROL_BUFFER_SIZE
)
541 buflen
= CONTROL_BUFFER_SIZE
;
543 if (buflen
> COMMAND_BUFFER_SIZE
) {
544 u
.buf
= kmalloc(buflen
, GFP_KERNEL
);
548 u
.buf
= priv
->command_buffer
;
551 mutex_lock(&priv
->command_lock
);
553 memset(u
.set
, 0, sizeof *u
.set
);
554 u
.set
->msg_type
= RNDIS_MSG_SET
;
555 u
.set
->msg_len
= cpu_to_le32(sizeof(*u
.set
) + len
);
557 u
.set
->len
= cpu_to_le32(len
);
558 u
.set
->offset
= cpu_to_le32(sizeof(*u
.set
) - 8);
559 u
.set
->handle
= cpu_to_le32(0);
560 memcpy(u
.buf
+ sizeof(*u
.set
), data
, len
);
562 ret
= rndis_command(dev
, u
.header
, buflen
);
564 ret
= rndis_error_status(u
.set_c
->status
);
566 mutex_unlock(&priv
->command_lock
);
568 if (u
.buf
!= priv
->command_buffer
)
575 * Specs say that we can only set config parameters only soon after device
577 * value_type: 0 = u32, 2 = unicode string
579 static int rndis_set_config_parameter(struct usbnet
*dev
, char *param
,
580 int value_type
, void *value
)
582 struct ndis_config_param
*infobuf
;
583 int value_len
, info_len
, param_len
, ret
, i
;
588 value_len
= sizeof(__le32
);
589 else if (value_type
== 2)
590 value_len
= strlen(value
) * sizeof(__le16
);
594 param_len
= strlen(param
) * sizeof(__le16
);
595 info_len
= sizeof(*infobuf
) + param_len
+ value_len
;
600 infobuf
= kmalloc(info_len
, GFP_KERNEL
);
606 /* extra 12 bytes are for padding (debug output) */
607 memset(infobuf
, 0xCC, info_len
+ 12);
611 devdbg(dev
, "setting config parameter: %s, value: %s",
614 devdbg(dev
, "setting config parameter: %s, value: %d",
615 param
, *(u32
*)value
);
617 infobuf
->name_offs
= cpu_to_le32(sizeof(*infobuf
));
618 infobuf
->name_length
= cpu_to_le32(param_len
);
619 infobuf
->type
= cpu_to_le32(value_type
);
620 infobuf
->value_offs
= cpu_to_le32(sizeof(*infobuf
) + param_len
);
621 infobuf
->value_length
= cpu_to_le32(value_len
);
623 /* simple string to unicode string conversion */
624 unibuf
= (void *)infobuf
+ sizeof(*infobuf
);
625 for (i
= 0; i
< param_len
/ sizeof(__le16
); i
++)
626 unibuf
[i
] = cpu_to_le16(param
[i
]);
628 if (value_type
== 2) {
629 unibuf
= (void *)infobuf
+ sizeof(*infobuf
) + param_len
;
630 for (i
= 0; i
< value_len
/ sizeof(__le16
); i
++)
631 unibuf
[i
] = cpu_to_le16(((u8
*)value
)[i
]);
633 dst_value
= (void *)infobuf
+ sizeof(*infobuf
) + param_len
;
634 *dst_value
= cpu_to_le32(*(u32
*)value
);
638 devdbg(dev
, "info buffer (len: %d):", info_len
);
639 for (i
= 0; i
< info_len
; i
+= 12) {
640 u32
*tmp
= (u32
*)((u8
*)infobuf
+ i
);
641 devdbg(dev
, "%08X:%08X:%08X",
644 cpu_to_be32(tmp
[2]));
648 ret
= rndis_set_oid(dev
, OID_GEN_RNDIS_CONFIG_PARAMETER
,
651 devdbg(dev
, "setting rndis config parameter failed, %d.", ret
);
657 static int rndis_set_config_parameter_str(struct usbnet
*dev
,
658 char *param
, char *value
)
660 return(rndis_set_config_parameter(dev
, param
, 2, value
));
663 /*static int rndis_set_config_parameter_u32(struct usbnet *dev,
664 char *param, u32 value)
666 return(rndis_set_config_parameter(dev, param, 0, &value));
671 * data conversion functions
673 static int level_to_qual(int level
)
675 int qual
= 100 * (level
- WL_NOISE
) / (WL_SIGMAX
- WL_NOISE
);
676 return qual
>= 0 ? (qual
<= 100 ? qual
: 100) : 0;
680 static void dsconfig_to_freq(unsigned int dsconfig
, struct iw_freq
*freq
)
686 /* see comment in wireless.h above the "struct iw_freq"
687 * definition for an explanation of this if
688 * NOTE: 1000000 is due to the kHz
690 if (dsconfig
> 1000000) {
691 freq
->m
= dsconfig
/ 10;
696 /* convert from kHz to Hz */
701 static int freq_to_dsconfig(struct iw_freq
*freq
, unsigned int *dsconfig
)
703 if (freq
->m
< 1000 && freq
->e
== 0) {
704 if (freq
->m
>= 1 && freq
->m
<= 14)
705 *dsconfig
= ieee80211_dsss_chan_to_freq(freq
->m
) * 1000;
711 for (i
= freq
->e
; i
> 0; i
--)
724 add_wep_key(struct usbnet
*usbdev
, char *key
, int key_len
, int index
);
726 static int get_essid(struct usbnet
*usbdev
, struct ndis_80211_ssid
*ssid
)
731 ret
= rndis_query_oid(usbdev
, OID_802_11_SSID
, ssid
, &len
);
738 unsigned char tmp
[NDIS_802_11_LENGTH_SSID
+ 1];
740 memcpy(tmp
, ssid
->essid
, le32_to_cpu(ssid
->length
));
741 tmp
[le32_to_cpu(ssid
->length
)] = 0;
742 devdbg(usbdev
, "get_essid: '%s', ret: %d", tmp
, ret
);
749 static int set_essid(struct usbnet
*usbdev
, struct ndis_80211_ssid
*ssid
)
751 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
754 ret
= rndis_set_oid(usbdev
, OID_802_11_SSID
, ssid
, sizeof(*ssid
));
756 memcpy(&priv
->essid
, ssid
, sizeof(priv
->essid
));
758 devdbg(usbdev
, "set_essid: radio_on = 1");
765 static int get_bssid(struct usbnet
*usbdev
, u8 bssid
[ETH_ALEN
])
770 ret
= rndis_query_oid(usbdev
, OID_802_11_BSSID
, bssid
, &len
);
773 memset(bssid
, 0, ETH_ALEN
);
778 static int get_association_info(struct usbnet
*usbdev
,
779 struct ndis_80211_assoc_info
*info
, int len
)
781 return rndis_query_oid(usbdev
, OID_802_11_ASSOCIATION_INFORMATION
,
785 static int is_associated(struct usbnet
*usbdev
)
790 ret
= get_bssid(usbdev
, bssid
);
792 return(ret
== 0 && memcmp(bssid
, zero_bssid
, ETH_ALEN
) != 0);
796 static int disassociate(struct usbnet
*usbdev
, int reset_ssid
)
798 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
799 struct ndis_80211_ssid ssid
;
802 if (priv
->radio_on
) {
803 ret
= rndis_set_oid(usbdev
, OID_802_11_DISASSOCIATE
, NULL
, 0);
806 devdbg(usbdev
, "disassociate: radio_on = 0");
813 /* disassociate causes radio to be turned off; if reset_ssid
814 * is given, set random ssid to enable radio */
816 ssid
.length
= cpu_to_le32(sizeof(ssid
.essid
));
817 get_random_bytes(&ssid
.essid
[2], sizeof(ssid
.essid
)-2);
819 ssid
.essid
[1] = 0xff;
820 for (i
= 2; i
< sizeof(ssid
.essid
); i
++)
821 ssid
.essid
[i
] = 0x1 + (ssid
.essid
[i
] * 0xfe / 0xff);
822 ret
= set_essid(usbdev
, &ssid
);
828 static int set_auth_mode(struct usbnet
*usbdev
, int wpa_version
, int authalg
)
830 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
834 devdbg(usbdev
, "set_auth_mode: wpa_version=0x%x authalg=0x%x "
835 "keymgmt=0x%x", wpa_version
, authalg
, priv
->wpa_keymgmt
);
837 if (wpa_version
& IW_AUTH_WPA_VERSION_WPA2
) {
838 if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_802_1X
)
839 auth_mode
= NDIS_80211_AUTH_WPA2
;
841 auth_mode
= NDIS_80211_AUTH_WPA2_PSK
;
842 } else if (wpa_version
& IW_AUTH_WPA_VERSION_WPA
) {
843 if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_802_1X
)
844 auth_mode
= NDIS_80211_AUTH_WPA
;
845 else if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_PSK
)
846 auth_mode
= NDIS_80211_AUTH_WPA_PSK
;
848 auth_mode
= NDIS_80211_AUTH_WPA_NONE
;
849 } else if (authalg
& IW_AUTH_ALG_SHARED_KEY
) {
850 if (authalg
& IW_AUTH_ALG_OPEN_SYSTEM
)
851 auth_mode
= NDIS_80211_AUTH_AUTO_SWITCH
;
853 auth_mode
= NDIS_80211_AUTH_SHARED
;
855 auth_mode
= NDIS_80211_AUTH_OPEN
;
857 tmp
= cpu_to_le32(auth_mode
);
858 ret
= rndis_set_oid(usbdev
, OID_802_11_AUTHENTICATION_MODE
, &tmp
,
861 devwarn(usbdev
, "setting auth mode failed (%08X)", ret
);
865 priv
->wpa_version
= wpa_version
;
866 priv
->wpa_authalg
= authalg
;
871 static int set_priv_filter(struct usbnet
*usbdev
)
873 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
876 devdbg(usbdev
, "set_priv_filter: wpa_version=0x%x", priv
->wpa_version
);
878 if (priv
->wpa_version
& IW_AUTH_WPA_VERSION_WPA2
||
879 priv
->wpa_version
& IW_AUTH_WPA_VERSION_WPA
)
880 tmp
= cpu_to_le32(NDIS_80211_PRIV_8021X_WEP
);
882 tmp
= cpu_to_le32(NDIS_80211_PRIV_ACCEPT_ALL
);
884 return rndis_set_oid(usbdev
, OID_802_11_PRIVACY_FILTER
, &tmp
,
889 static int set_encr_mode(struct usbnet
*usbdev
, int pairwise
, int groupwise
)
891 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
895 devdbg(usbdev
, "set_encr_mode: cipher_pair=0x%x cipher_group=0x%x",
899 if (pairwise
& IW_AUTH_CIPHER_CCMP
)
900 encr_mode
= NDIS_80211_ENCR_CCMP_ENABLED
;
901 else if (pairwise
& IW_AUTH_CIPHER_TKIP
)
902 encr_mode
= NDIS_80211_ENCR_TKIP_ENABLED
;
904 (IW_AUTH_CIPHER_WEP40
| IW_AUTH_CIPHER_WEP104
))
905 encr_mode
= NDIS_80211_ENCR_WEP_ENABLED
;
906 else if (groupwise
& IW_AUTH_CIPHER_CCMP
)
907 encr_mode
= NDIS_80211_ENCR_CCMP_ENABLED
;
908 else if (groupwise
& IW_AUTH_CIPHER_TKIP
)
909 encr_mode
= NDIS_80211_ENCR_TKIP_ENABLED
;
911 encr_mode
= NDIS_80211_ENCR_DISABLED
;
913 tmp
= cpu_to_le32(encr_mode
);
914 ret
= rndis_set_oid(usbdev
, OID_802_11_ENCRYPTION_STATUS
, &tmp
,
917 devwarn(usbdev
, "setting encr mode failed (%08X)", ret
);
921 priv
->wpa_cipher_pair
= pairwise
;
922 priv
->wpa_cipher_group
= groupwise
;
927 static int set_assoc_params(struct usbnet
*usbdev
)
929 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
931 set_auth_mode(usbdev
, priv
->wpa_version
, priv
->wpa_authalg
);
932 set_priv_filter(usbdev
);
933 set_encr_mode(usbdev
, priv
->wpa_cipher_pair
, priv
->wpa_cipher_group
);
939 static int set_infra_mode(struct usbnet
*usbdev
, int mode
)
941 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
945 devdbg(usbdev
, "set_infra_mode: infra_mode=0x%x", priv
->infra_mode
);
947 tmp
= cpu_to_le32(mode
);
948 ret
= rndis_set_oid(usbdev
, OID_802_11_INFRASTRUCTURE_MODE
, &tmp
,
951 devwarn(usbdev
, "setting infra mode failed (%08X)", ret
);
955 /* NDIS drivers clear keys when infrastructure mode is
956 * changed. But Linux tools assume otherwise. So set the
958 if (priv
->wpa_keymgmt
== 0 ||
959 priv
->wpa_keymgmt
== IW_AUTH_KEY_MGMT_802_1X
) {
960 for (i
= 0; i
< 4; i
++) {
961 if (priv
->encr_key_len
[i
] > 0 && !priv
->encr_key_wpa
[i
])
962 add_wep_key(usbdev
, priv
->encr_keys
[i
],
963 priv
->encr_key_len
[i
], i
);
967 priv
->infra_mode
= mode
;
972 static void set_default_iw_params(struct usbnet
*usbdev
)
974 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
976 priv
->wpa_keymgmt
= 0;
977 priv
->wpa_version
= 0;
979 set_infra_mode(usbdev
, NDIS_80211_INFRA_INFRA
);
980 set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
981 IW_AUTH_ALG_OPEN_SYSTEM
);
982 set_priv_filter(usbdev
);
983 set_encr_mode(usbdev
, IW_AUTH_CIPHER_NONE
, IW_AUTH_CIPHER_NONE
);
987 static int deauthenticate(struct usbnet
*usbdev
)
991 ret
= disassociate(usbdev
, 1);
992 set_default_iw_params(usbdev
);
997 /* index must be 0 - N, as per NDIS */
998 static int add_wep_key(struct usbnet
*usbdev
, char *key
, int key_len
, int index
)
1000 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1001 struct ndis_80211_wep_key ndis_key
;
1004 if (key_len
<= 0 || key_len
> 32 || index
< 0 || index
>= 4)
1007 memset(&ndis_key
, 0, sizeof(ndis_key
));
1009 ndis_key
.size
= cpu_to_le32(sizeof(ndis_key
));
1010 ndis_key
.length
= cpu_to_le32(key_len
);
1011 ndis_key
.index
= cpu_to_le32(index
);
1012 memcpy(&ndis_key
.material
, key
, key_len
);
1014 if (index
== priv
->encr_tx_key_index
) {
1015 ndis_key
.index
|= NDIS_80211_ADDWEP_TRANSMIT_KEY
;
1016 ret
= set_encr_mode(usbdev
, IW_AUTH_CIPHER_WEP104
,
1017 IW_AUTH_CIPHER_NONE
);
1019 devwarn(usbdev
, "encryption couldn't be enabled (%08X)",
1023 ret
= rndis_set_oid(usbdev
, OID_802_11_ADD_WEP
, &ndis_key
,
1026 devwarn(usbdev
, "adding encryption key %d failed (%08X)",
1031 priv
->encr_key_len
[index
] = key_len
;
1032 priv
->encr_key_wpa
[index
] = 0;
1033 memcpy(&priv
->encr_keys
[index
], key
, key_len
);
1039 static int add_wpa_key(struct usbnet
*usbdev
, const u8
*key
, int key_len
,
1040 int index
, const struct sockaddr
*addr
,
1041 const u8
*rx_seq
, int alg
, int flags
)
1043 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1044 struct ndis_80211_key ndis_key
;
1047 if (index
< 0 || index
>= 4)
1049 if (key_len
> sizeof(ndis_key
.material
) || key_len
< 0)
1051 if ((flags
& NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
) && !rx_seq
)
1053 if ((flags
& NDIS_80211_ADDKEY_PAIRWISE_KEY
) && !addr
)
1056 devdbg(usbdev
, "add_wpa_key(%i): flags:%i%i%i", index
,
1057 !!(flags
& NDIS_80211_ADDKEY_TRANSMIT_KEY
),
1058 !!(flags
& NDIS_80211_ADDKEY_PAIRWISE_KEY
),
1059 !!(flags
& NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
));
1061 memset(&ndis_key
, 0, sizeof(ndis_key
));
1063 ndis_key
.size
= cpu_to_le32(sizeof(ndis_key
) -
1064 sizeof(ndis_key
.material
) + key_len
);
1065 ndis_key
.length
= cpu_to_le32(key_len
);
1066 ndis_key
.index
= cpu_to_le32(index
) | flags
;
1068 if (alg
== IW_ENCODE_ALG_TKIP
&& key_len
== 32) {
1069 /* wpa_supplicant gives us the Michael MIC RX/TX keys in
1070 * different order than NDIS spec, so swap the order here. */
1071 memcpy(ndis_key
.material
, key
, 16);
1072 memcpy(ndis_key
.material
+ 16, key
+ 24, 8);
1073 memcpy(ndis_key
.material
+ 24, key
+ 16, 8);
1075 memcpy(ndis_key
.material
, key
, key_len
);
1077 if (flags
& NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
)
1078 memcpy(ndis_key
.rsc
, rx_seq
, 6);
1080 if (flags
& NDIS_80211_ADDKEY_PAIRWISE_KEY
) {
1082 memcpy(ndis_key
.bssid
, addr
->sa_data
, ETH_ALEN
);
1085 if (priv
->infra_mode
== NDIS_80211_INFRA_ADHOC
)
1086 memset(ndis_key
.bssid
, 0xff, ETH_ALEN
);
1088 get_bssid(usbdev
, ndis_key
.bssid
);
1091 ret
= rndis_set_oid(usbdev
, OID_802_11_ADD_KEY
, &ndis_key
,
1092 le32_to_cpu(ndis_key
.size
));
1093 devdbg(usbdev
, "add_wpa_key: OID_802_11_ADD_KEY -> %08X", ret
);
1097 priv
->encr_key_len
[index
] = key_len
;
1098 priv
->encr_key_wpa
[index
] = 1;
1100 if (flags
& NDIS_80211_ADDKEY_TRANSMIT_KEY
)
1101 priv
->encr_tx_key_index
= index
;
1107 /* remove_key is for both wep and wpa */
1108 static int remove_key(struct usbnet
*usbdev
, int index
, u8 bssid
[ETH_ALEN
])
1110 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1111 struct ndis_80211_remove_key remove_key
;
1115 if (priv
->encr_key_len
[index
] == 0)
1118 priv
->encr_key_len
[index
] = 0;
1119 priv
->encr_key_wpa
[index
] = 0;
1120 memset(&priv
->encr_keys
[index
], 0, sizeof(priv
->encr_keys
[index
]));
1122 if (priv
->wpa_cipher_pair
== IW_AUTH_CIPHER_TKIP
||
1123 priv
->wpa_cipher_pair
== IW_AUTH_CIPHER_CCMP
||
1124 priv
->wpa_cipher_group
== IW_AUTH_CIPHER_TKIP
||
1125 priv
->wpa_cipher_group
== IW_AUTH_CIPHER_CCMP
) {
1126 remove_key
.size
= cpu_to_le32(sizeof(remove_key
));
1127 remove_key
.index
= cpu_to_le32(index
);
1130 if (memcmp(bssid
, ffff_bssid
, ETH_ALEN
) != 0)
1132 NDIS_80211_ADDKEY_PAIRWISE_KEY
;
1133 memcpy(remove_key
.bssid
, bssid
,
1134 sizeof(remove_key
.bssid
));
1136 memset(remove_key
.bssid
, 0xff,
1137 sizeof(remove_key
.bssid
));
1139 ret
= rndis_set_oid(usbdev
, OID_802_11_REMOVE_KEY
, &remove_key
,
1140 sizeof(remove_key
));
1144 keyindex
= cpu_to_le32(index
);
1145 ret
= rndis_set_oid(usbdev
, OID_802_11_REMOVE_WEP
, &keyindex
,
1149 "removing encryption key %d failed (%08X)",
1155 /* if it is transmit key, disable encryption */
1156 if (index
== priv
->encr_tx_key_index
)
1157 set_encr_mode(usbdev
, IW_AUTH_CIPHER_NONE
, IW_AUTH_CIPHER_NONE
);
1163 static void set_multicast_list(struct usbnet
*usbdev
)
1165 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1166 struct dev_mc_list
*mclist
;
1171 filter
= RNDIS_PACKET_TYPE_DIRECTED
| RNDIS_PACKET_TYPE_BROADCAST
;
1173 if (usbdev
->net
->flags
& IFF_PROMISC
) {
1174 filter
|= RNDIS_PACKET_TYPE_PROMISCUOUS
|
1175 RNDIS_PACKET_TYPE_ALL_LOCAL
;
1176 } else if (usbdev
->net
->flags
& IFF_ALLMULTI
||
1177 usbdev
->net
->mc_count
> priv
->multicast_size
) {
1178 filter
|= RNDIS_PACKET_TYPE_ALL_MULTICAST
;
1179 } else if (usbdev
->net
->mc_count
> 0) {
1180 size
= min(priv
->multicast_size
, usbdev
->net
->mc_count
);
1181 buf
= kmalloc(size
* ETH_ALEN
, GFP_KERNEL
);
1184 "couldn't alloc %d bytes of memory",
1189 mclist
= usbdev
->net
->mc_list
;
1190 for (i
= 0; i
< size
&& mclist
; mclist
= mclist
->next
) {
1191 if (mclist
->dmi_addrlen
!= ETH_ALEN
)
1194 memcpy(buf
+ i
* ETH_ALEN
, mclist
->dmi_addr
, ETH_ALEN
);
1198 ret
= rndis_set_oid(usbdev
, OID_802_3_MULTICAST_LIST
, buf
,
1200 if (ret
== 0 && i
> 0)
1201 filter
|= RNDIS_PACKET_TYPE_MULTICAST
;
1203 filter
|= RNDIS_PACKET_TYPE_ALL_MULTICAST
;
1205 devdbg(usbdev
, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d",
1206 i
, priv
->multicast_size
, ret
);
1211 ret
= rndis_set_oid(usbdev
, OID_GEN_CURRENT_PACKET_FILTER
, &filter
,
1214 devwarn(usbdev
, "couldn't set packet filter: %08x",
1215 le32_to_cpu(filter
));
1218 devdbg(usbdev
, "OID_GEN_CURRENT_PACKET_FILTER(%08x) -> %d",
1219 le32_to_cpu(filter
), ret
);
1226 static int rndis_change_virtual_intf(struct wiphy
*wiphy
,
1227 struct net_device
*dev
,
1228 enum nl80211_iftype type
, u32
*flags
,
1229 struct vif_params
*params
)
1231 struct usbnet
*usbdev
= netdev_priv(dev
);
1235 case NL80211_IFTYPE_ADHOC
:
1236 mode
= NDIS_80211_INFRA_ADHOC
;
1238 case NL80211_IFTYPE_STATION
:
1239 mode
= NDIS_80211_INFRA_INFRA
;
1245 return set_infra_mode(usbdev
, mode
);
1249 #define SCAN_DELAY_JIFFIES (HZ)
1250 static int rndis_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
1251 struct cfg80211_scan_request
*request
)
1253 struct usbnet
*usbdev
= netdev_priv(dev
);
1254 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1258 devdbg(usbdev
, "cfg80211.scan");
1263 if (priv
->scan_request
&& priv
->scan_request
!= request
)
1266 priv
->scan_request
= request
;
1268 tmp
= cpu_to_le32(1);
1269 ret
= rndis_set_oid(usbdev
, OID_802_11_BSSID_LIST_SCAN
, &tmp
,
1272 /* Wait before retrieving scan results from device */
1273 queue_delayed_work(priv
->workqueue
, &priv
->scan_work
,
1274 SCAN_DELAY_JIFFIES
);
1281 static struct cfg80211_bss
*rndis_bss_info_update(struct usbnet
*usbdev
,
1282 struct ndis_80211_bssid_ex
*bssid
)
1284 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1285 struct ieee80211_channel
*channel
;
1289 u16 beacon_interval
;
1290 struct ndis_80211_fixed_ies
*fixed
;
1291 int ie_len
, bssid_len
;
1294 /* parse bssid structure */
1295 bssid_len
= le32_to_cpu(bssid
->length
);
1297 if (bssid_len
< sizeof(struct ndis_80211_bssid_ex
) +
1298 sizeof(struct ndis_80211_fixed_ies
))
1301 fixed
= (struct ndis_80211_fixed_ies
*)bssid
->ies
;
1303 ie
= (void *)(bssid
->ies
+ sizeof(struct ndis_80211_fixed_ies
));
1304 ie_len
= min(bssid_len
- (int)sizeof(*bssid
),
1305 (int)le32_to_cpu(bssid
->ie_length
));
1306 ie_len
-= sizeof(struct ndis_80211_fixed_ies
);
1310 /* extract data for cfg80211_inform_bss */
1311 channel
= ieee80211_get_channel(priv
->wdev
.wiphy
,
1312 KHZ_TO_MHZ(le32_to_cpu(bssid
->config
.ds_config
)));
1316 signal
= level_to_qual(le32_to_cpu(bssid
->rssi
));
1317 timestamp
= le64_to_cpu(*(__le64
*)fixed
->timestamp
);
1318 capability
= le16_to_cpu(fixed
->capabilities
);
1319 beacon_interval
= le16_to_cpu(fixed
->beacon_interval
);
1321 return cfg80211_inform_bss(priv
->wdev
.wiphy
, channel
, bssid
->mac
,
1322 timestamp
, capability
, beacon_interval
, ie
, ie_len
, signal
,
1327 static int rndis_check_bssid_list(struct usbnet
*usbdev
)
1330 struct ndis_80211_bssid_list_ex
*bssid_list
;
1331 struct ndis_80211_bssid_ex
*bssid
;
1332 int ret
= -EINVAL
, len
, count
, bssid_len
;
1334 devdbg(usbdev
, "check_bssid_list");
1336 len
= CONTROL_BUFFER_SIZE
;
1337 buf
= kmalloc(len
, GFP_KERNEL
);
1343 ret
= rndis_query_oid(usbdev
, OID_802_11_BSSID_LIST
, buf
, &len
);
1348 bssid
= bssid_list
->bssid
;
1349 bssid_len
= le32_to_cpu(bssid
->length
);
1350 count
= le32_to_cpu(bssid_list
->num_items
);
1351 devdbg(usbdev
, "check_bssid_list: %d BSSIDs found", count
);
1353 while (count
&& ((void *)bssid
+ bssid_len
) <= (buf
+ len
)) {
1354 rndis_bss_info_update(usbdev
, bssid
);
1356 bssid
= (void *)bssid
+ bssid_len
;
1357 bssid_len
= le32_to_cpu(bssid
->length
);
1367 static void rndis_get_scan_results(struct work_struct
*work
)
1369 struct rndis_wlan_private
*priv
=
1370 container_of(work
, struct rndis_wlan_private
, scan_work
.work
);
1371 struct usbnet
*usbdev
= priv
->usbdev
;
1374 devdbg(usbdev
, "get_scan_results");
1376 ret
= rndis_check_bssid_list(usbdev
);
1378 cfg80211_scan_done(priv
->scan_request
, ret
< 0);
1380 priv
->scan_request
= NULL
;
1385 * wireless extension handlers
1388 static int rndis_iw_commit(struct net_device
*dev
,
1389 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1396 static int rndis_iw_set_essid(struct net_device
*dev
,
1397 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *essid
)
1399 struct ndis_80211_ssid ssid
;
1400 int length
= wrqu
->essid
.length
;
1401 struct usbnet
*usbdev
= netdev_priv(dev
);
1403 devdbg(usbdev
, "SIOCSIWESSID: [flags:%d,len:%d] '%.32s'",
1404 wrqu
->essid
.flags
, wrqu
->essid
.length
, essid
);
1406 if (length
> NDIS_802_11_LENGTH_SSID
)
1407 length
= NDIS_802_11_LENGTH_SSID
;
1409 ssid
.length
= cpu_to_le32(length
);
1411 memcpy(ssid
.essid
, essid
, length
);
1413 memset(ssid
.essid
, 0, NDIS_802_11_LENGTH_SSID
);
1415 set_assoc_params(usbdev
);
1417 if (!wrqu
->essid
.flags
|| length
== 0)
1418 return disassociate(usbdev
, 1);
1420 return set_essid(usbdev
, &ssid
);
1424 static int rndis_iw_get_essid(struct net_device
*dev
,
1425 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *essid
)
1427 struct ndis_80211_ssid ssid
;
1428 struct usbnet
*usbdev
= netdev_priv(dev
);
1431 ret
= get_essid(usbdev
, &ssid
);
1433 if (ret
== 0 && le32_to_cpu(ssid
.length
) > 0) {
1434 wrqu
->essid
.flags
= 1;
1435 wrqu
->essid
.length
= le32_to_cpu(ssid
.length
);
1436 memcpy(essid
, ssid
.essid
, wrqu
->essid
.length
);
1437 essid
[wrqu
->essid
.length
] = 0;
1439 memset(essid
, 0, sizeof(NDIS_802_11_LENGTH_SSID
));
1440 wrqu
->essid
.flags
= 0;
1441 wrqu
->essid
.length
= 0;
1443 devdbg(usbdev
, "SIOCGIWESSID: %s", essid
);
1448 static int rndis_iw_get_bssid(struct net_device
*dev
,
1449 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1451 struct usbnet
*usbdev
= netdev_priv(dev
);
1452 unsigned char bssid
[ETH_ALEN
];
1455 ret
= get_bssid(usbdev
, bssid
);
1458 devdbg(usbdev
, "SIOCGIWAP: %pM", bssid
);
1460 devdbg(usbdev
, "SIOCGIWAP: <not associated>");
1462 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1463 memcpy(wrqu
->ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1469 static int rndis_iw_set_bssid(struct net_device
*dev
,
1470 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1472 struct usbnet
*usbdev
= netdev_priv(dev
);
1473 u8
*bssid
= (u8
*)wrqu
->ap_addr
.sa_data
;
1476 devdbg(usbdev
, "SIOCSIWAP: %pM", bssid
);
1478 ret
= rndis_set_oid(usbdev
, OID_802_11_BSSID
, bssid
, ETH_ALEN
);
1480 /* user apps may set ap's mac address, which is not required;
1481 * they may fail to work if this function fails, so return
1484 devwarn(usbdev
, "setting AP mac address failed (%08X)", ret
);
1490 static int rndis_iw_set_auth(struct net_device
*dev
,
1491 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1493 struct iw_param
*p
= &wrqu
->param
;
1494 struct usbnet
*usbdev
= netdev_priv(dev
);
1495 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1496 int ret
= -ENOTSUPP
;
1498 switch (p
->flags
& IW_AUTH_INDEX
) {
1499 case IW_AUTH_WPA_VERSION
:
1500 devdbg(usbdev
, "SIOCSIWAUTH: WPA_VERSION, %08x", p
->value
);
1501 priv
->wpa_version
= p
->value
;
1505 case IW_AUTH_CIPHER_PAIRWISE
:
1506 devdbg(usbdev
, "SIOCSIWAUTH: CIPHER_PAIRWISE, %08x", p
->value
);
1507 priv
->wpa_cipher_pair
= p
->value
;
1511 case IW_AUTH_CIPHER_GROUP
:
1512 devdbg(usbdev
, "SIOCSIWAUTH: CIPHER_GROUP, %08x", p
->value
);
1513 priv
->wpa_cipher_group
= p
->value
;
1517 case IW_AUTH_KEY_MGMT
:
1518 devdbg(usbdev
, "SIOCSIWAUTH: KEY_MGMT, %08x", p
->value
);
1519 priv
->wpa_keymgmt
= p
->value
;
1523 case IW_AUTH_TKIP_COUNTERMEASURES
:
1524 devdbg(usbdev
, "SIOCSIWAUTH: TKIP_COUNTERMEASURES, %08x",
1529 case IW_AUTH_DROP_UNENCRYPTED
:
1530 devdbg(usbdev
, "SIOCSIWAUTH: DROP_UNENCRYPTED, %08x", p
->value
);
1534 case IW_AUTH_80211_AUTH_ALG
:
1535 devdbg(usbdev
, "SIOCSIWAUTH: 80211_AUTH_ALG, %08x", p
->value
);
1536 priv
->wpa_authalg
= p
->value
;
1540 case IW_AUTH_WPA_ENABLED
:
1541 devdbg(usbdev
, "SIOCSIWAUTH: WPA_ENABLED, %08x", p
->value
);
1542 if (wrqu
->param
.value
)
1543 deauthenticate(usbdev
);
1547 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1548 devdbg(usbdev
, "SIOCSIWAUTH: RX_UNENCRYPTED_EAPOL, %08x",
1553 case IW_AUTH_ROAMING_CONTROL
:
1554 devdbg(usbdev
, "SIOCSIWAUTH: ROAMING_CONTROL, %08x", p
->value
);
1558 case IW_AUTH_PRIVACY_INVOKED
:
1559 devdbg(usbdev
, "SIOCSIWAUTH: invalid cmd %d",
1560 wrqu
->param
.flags
& IW_AUTH_INDEX
);
1564 devdbg(usbdev
, "SIOCSIWAUTH: UNKNOWN %08x, %08x",
1565 p
->flags
& IW_AUTH_INDEX
, p
->value
);
1571 static int rndis_iw_get_auth(struct net_device
*dev
,
1572 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1574 struct iw_param
*p
= &wrqu
->param
;
1575 struct usbnet
*usbdev
= netdev_priv(dev
);
1576 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1578 switch (p
->flags
& IW_AUTH_INDEX
) {
1579 case IW_AUTH_WPA_VERSION
:
1580 p
->value
= priv
->wpa_version
;
1582 case IW_AUTH_CIPHER_PAIRWISE
:
1583 p
->value
= priv
->wpa_cipher_pair
;
1585 case IW_AUTH_CIPHER_GROUP
:
1586 p
->value
= priv
->wpa_cipher_group
;
1588 case IW_AUTH_KEY_MGMT
:
1589 p
->value
= priv
->wpa_keymgmt
;
1591 case IW_AUTH_80211_AUTH_ALG
:
1592 p
->value
= priv
->wpa_authalg
;
1595 devdbg(usbdev
, "SIOCGIWAUTH: invalid cmd %d",
1596 wrqu
->param
.flags
& IW_AUTH_INDEX
);
1603 static int rndis_iw_set_encode(struct net_device
*dev
,
1604 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1606 struct usbnet
*usbdev
= netdev_priv(dev
);
1607 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1608 int ret
, index
, key_len
;
1611 index
= (wrqu
->encoding
.flags
& IW_ENCODE_INDEX
);
1613 /* iwconfig gives index as 1 - N */
1617 index
= priv
->encr_tx_key_index
;
1619 if (index
< 0 || index
>= 4) {
1620 devwarn(usbdev
, "encryption index out of range (%u)", index
);
1624 /* remove key if disabled */
1625 if (wrqu
->data
.flags
& IW_ENCODE_DISABLED
) {
1626 if (remove_key(usbdev
, index
, NULL
))
1632 /* global encryption state (for all keys) */
1633 if (wrqu
->data
.flags
& IW_ENCODE_OPEN
)
1634 ret
= set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1635 IW_AUTH_ALG_OPEN_SYSTEM
);
1636 else /*if (wrqu->data.flags & IW_ENCODE_RESTRICTED)*/
1637 ret
= set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1638 IW_AUTH_ALG_SHARED_KEY
);
1642 if (wrqu
->data
.length
> 0) {
1643 key_len
= wrqu
->data
.length
;
1646 /* must be set as tx key */
1647 if (priv
->encr_key_len
[index
] == 0)
1649 key_len
= priv
->encr_key_len
[index
];
1650 key
= priv
->encr_keys
[index
];
1651 priv
->encr_tx_key_index
= index
;
1654 if (add_wep_key(usbdev
, key
, key_len
, index
) != 0)
1657 if (index
== priv
->encr_tx_key_index
)
1658 /* ndis drivers want essid to be set after setting encr */
1659 set_essid(usbdev
, &priv
->essid
);
1665 static int rndis_iw_set_encode_ext(struct net_device
*dev
,
1666 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1668 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1669 struct usbnet
*usbdev
= netdev_priv(dev
);
1670 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1673 keyidx
= wrqu
->encoding
.flags
& IW_ENCODE_INDEX
;
1675 /* iwconfig gives index as 1 - N */
1679 keyidx
= priv
->encr_tx_key_index
;
1681 if (keyidx
< 0 || keyidx
>= 4)
1684 if (ext
->alg
== WPA_ALG_WEP
) {
1685 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1686 priv
->encr_tx_key_index
= keyidx
;
1687 return add_wep_key(usbdev
, ext
->key
, ext
->key_len
, keyidx
);
1690 if ((wrqu
->encoding
.flags
& IW_ENCODE_DISABLED
) ||
1691 ext
->alg
== IW_ENCODE_ALG_NONE
|| ext
->key_len
== 0)
1692 return remove_key(usbdev
, keyidx
, NULL
);
1695 if (ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
)
1696 flags
|= NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
;
1697 if (!(ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
))
1698 flags
|= NDIS_80211_ADDKEY_PAIRWISE_KEY
;
1699 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1700 flags
|= NDIS_80211_ADDKEY_TRANSMIT_KEY
;
1702 return add_wpa_key(usbdev
, ext
->key
, ext
->key_len
, keyidx
, &ext
->addr
,
1703 ext
->rx_seq
, ext
->alg
, flags
);
1707 static int rndis_iw_set_genie(struct net_device
*dev
,
1708 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1710 struct usbnet
*usbdev
= netdev_priv(dev
);
1711 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1717 for (j
= 0; j
< wrqu
->data
.length
; j
+= 8)
1719 "SIOCSIWGENIE %04x - "
1720 "%02x %02x %02x %02x %02x %02x %02x %02x", j
,
1721 gie
[j
+ 0], gie
[j
+ 1], gie
[j
+ 2], gie
[j
+ 3],
1722 gie
[j
+ 4], gie
[j
+ 5], gie
[j
+ 6], gie
[j
+ 7]);
1724 /* clear existing IEs */
1725 if (priv
->wpa_ie_len
) {
1726 kfree(priv
->wpa_ie
);
1727 priv
->wpa_ie_len
= 0;
1731 priv
->wpa_ie
= kmalloc(wrqu
->data
.length
, GFP_KERNEL
);
1733 priv
->wpa_ie_len
= wrqu
->data
.length
;
1734 memcpy(priv
->wpa_ie
, extra
, priv
->wpa_ie_len
);
1741 static int rndis_iw_get_genie(struct net_device
*dev
,
1742 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1744 struct usbnet
*usbdev
= netdev_priv(dev
);
1745 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1747 devdbg(usbdev
, "SIOCGIWGENIE");
1749 if (priv
->wpa_ie_len
== 0 || priv
->wpa_ie
== NULL
) {
1750 wrqu
->data
.length
= 0;
1754 if (wrqu
->data
.length
< priv
->wpa_ie_len
)
1757 wrqu
->data
.length
= priv
->wpa_ie_len
;
1758 memcpy(extra
, priv
->wpa_ie
, priv
->wpa_ie_len
);
1764 static int rndis_iw_set_rts(struct net_device
*dev
,
1765 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1767 struct usbnet
*usbdev
= netdev_priv(dev
);
1769 devdbg(usbdev
, "SIOCSIWRTS");
1771 tmp
= cpu_to_le32(wrqu
->rts
.value
);
1772 return rndis_set_oid(usbdev
, OID_802_11_RTS_THRESHOLD
, &tmp
,
1777 static int rndis_iw_get_rts(struct net_device
*dev
,
1778 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1780 struct usbnet
*usbdev
= netdev_priv(dev
);
1785 ret
= rndis_query_oid(usbdev
, OID_802_11_RTS_THRESHOLD
, &tmp
, &len
);
1787 wrqu
->rts
.value
= le32_to_cpu(tmp
);
1788 wrqu
->rts
.flags
= 1;
1789 wrqu
->rts
.disabled
= 0;
1792 devdbg(usbdev
, "SIOCGIWRTS: %d", wrqu
->rts
.value
);
1798 static int rndis_iw_set_frag(struct net_device
*dev
,
1799 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1801 struct usbnet
*usbdev
= netdev_priv(dev
);
1804 devdbg(usbdev
, "SIOCSIWFRAG");
1806 tmp
= cpu_to_le32(wrqu
->frag
.value
);
1807 return rndis_set_oid(usbdev
, OID_802_11_FRAGMENTATION_THRESHOLD
, &tmp
,
1812 static int rndis_iw_get_frag(struct net_device
*dev
,
1813 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1815 struct usbnet
*usbdev
= netdev_priv(dev
);
1820 ret
= rndis_query_oid(usbdev
, OID_802_11_FRAGMENTATION_THRESHOLD
, &tmp
,
1823 wrqu
->frag
.value
= le32_to_cpu(tmp
);
1824 wrqu
->frag
.flags
= 1;
1825 wrqu
->frag
.disabled
= 0;
1827 devdbg(usbdev
, "SIOCGIWFRAG: %d", wrqu
->frag
.value
);
1832 static int rndis_iw_set_freq(struct net_device
*dev
,
1833 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1835 struct usbnet
*usbdev
= netdev_priv(dev
);
1836 struct ndis_80211_conf config
;
1837 unsigned int dsconfig
;
1840 /* this OID is valid only when not associated */
1841 if (is_associated(usbdev
))
1845 if (freq_to_dsconfig(&wrqu
->freq
, &dsconfig
))
1848 len
= sizeof(config
);
1849 ret
= rndis_query_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
, &len
);
1851 devdbg(usbdev
, "SIOCSIWFREQ: querying configuration failed");
1855 config
.ds_config
= cpu_to_le32(dsconfig
);
1857 devdbg(usbdev
, "SIOCSIWFREQ: %d * 10^%d", wrqu
->freq
.m
, wrqu
->freq
.e
);
1858 return rndis_set_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
,
1863 static int rndis_iw_get_freq(struct net_device
*dev
,
1864 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1866 struct usbnet
*usbdev
= netdev_priv(dev
);
1867 struct ndis_80211_conf config
;
1870 len
= sizeof(config
);
1871 ret
= rndis_query_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
, &len
);
1873 dsconfig_to_freq(le32_to_cpu(config
.ds_config
), &wrqu
->freq
);
1875 devdbg(usbdev
, "SIOCGIWFREQ: %d", wrqu
->freq
.m
);
1880 static int rndis_iw_get_txpower(struct net_device
*dev
,
1881 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1883 struct usbnet
*usbdev
= netdev_priv(dev
);
1884 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1887 if (priv
->radio_on
) {
1888 /* fake since changing tx_power (by userlevel) not supported */
1889 tx_power
= cpu_to_le32(get_bcm4320_power(priv
));
1891 wrqu
->txpower
.flags
= IW_TXPOW_MWATT
;
1892 wrqu
->txpower
.value
= le32_to_cpu(tx_power
);
1893 wrqu
->txpower
.disabled
= 0;
1895 wrqu
->txpower
.flags
= IW_TXPOW_MWATT
;
1896 wrqu
->txpower
.value
= 0;
1897 wrqu
->txpower
.disabled
= 1;
1900 devdbg(usbdev
, "SIOCGIWTXPOW: %d", wrqu
->txpower
.value
);
1906 static int rndis_iw_set_txpower(struct net_device
*dev
,
1907 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1909 struct usbnet
*usbdev
= netdev_priv(dev
);
1910 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1911 __le32 tx_power
= 0;
1913 if (!wrqu
->txpower
.disabled
) {
1914 if (wrqu
->txpower
.flags
== IW_TXPOW_MWATT
)
1915 tx_power
= cpu_to_le32(wrqu
->txpower
.value
);
1916 else { /* wrqu->txpower.flags == IW_TXPOW_DBM */
1917 if (wrqu
->txpower
.value
> 20)
1918 tx_power
= cpu_to_le32(128);
1919 else if (wrqu
->txpower
.value
< -43)
1920 tx_power
= cpu_to_le32(127);
1923 tmp
= wrqu
->txpower
.value
;
1926 tx_power
= cpu_to_le32((unsigned char)tmp
);
1931 devdbg(usbdev
, "SIOCSIWTXPOW: %d", le32_to_cpu(tx_power
));
1933 if (le32_to_cpu(tx_power
) != 0) {
1934 /* txpower unsupported, just turn radio on */
1935 if (!priv
->radio_on
)
1936 return disassociate(usbdev
, 1);
1937 return 0; /* all ready on */
1940 /* tx_power == 0, turn off radio */
1941 return disassociate(usbdev
, 0);
1945 static int rndis_iw_get_rate(struct net_device
*dev
,
1946 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1948 struct usbnet
*usbdev
= netdev_priv(dev
);
1953 ret
= rndis_query_oid(usbdev
, OID_GEN_LINK_SPEED
, &tmp
, &len
);
1955 wrqu
->bitrate
.value
= le32_to_cpu(tmp
) * 100;
1956 wrqu
->bitrate
.disabled
= 0;
1957 wrqu
->bitrate
.flags
= 1;
1963 static int rndis_iw_set_mlme(struct net_device
*dev
,
1964 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1966 struct usbnet
*usbdev
= netdev_priv(dev
);
1967 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1968 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
1969 unsigned char bssid
[ETH_ALEN
];
1971 get_bssid(usbdev
, bssid
);
1973 if (memcmp(bssid
, mlme
->addr
.sa_data
, ETH_ALEN
))
1976 switch (mlme
->cmd
) {
1977 case IW_MLME_DEAUTH
:
1978 return deauthenticate(usbdev
);
1979 case IW_MLME_DISASSOC
:
1980 return disassociate(usbdev
, priv
->radio_on
);
1989 static struct iw_statistics
*rndis_get_wireless_stats(struct net_device
*dev
)
1991 struct usbnet
*usbdev
= netdev_priv(dev
);
1992 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1993 unsigned long flags
;
1995 spin_lock_irqsave(&priv
->stats_lock
, flags
);
1996 memcpy(&priv
->iwstats
, &priv
->privstats
, sizeof(priv
->iwstats
));
1997 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
1999 return &priv
->iwstats
;
2003 #define IW_IOCTL(x) [(x) - SIOCSIWCOMMIT]
2004 static const iw_handler rndis_iw_handler
[] =
2006 IW_IOCTL(SIOCSIWCOMMIT
) = rndis_iw_commit
,
2007 IW_IOCTL(SIOCGIWNAME
) = (iw_handler
) cfg80211_wext_giwname
,
2008 IW_IOCTL(SIOCSIWFREQ
) = rndis_iw_set_freq
,
2009 IW_IOCTL(SIOCGIWFREQ
) = rndis_iw_get_freq
,
2010 IW_IOCTL(SIOCSIWMODE
) = (iw_handler
) cfg80211_wext_siwmode
,
2011 IW_IOCTL(SIOCGIWMODE
) = (iw_handler
) cfg80211_wext_giwmode
,
2012 IW_IOCTL(SIOCGIWRANGE
) = (iw_handler
) cfg80211_wext_giwrange
,
2013 IW_IOCTL(SIOCSIWAP
) = rndis_iw_set_bssid
,
2014 IW_IOCTL(SIOCGIWAP
) = rndis_iw_get_bssid
,
2015 IW_IOCTL(SIOCSIWSCAN
) = (iw_handler
) cfg80211_wext_siwscan
,
2016 IW_IOCTL(SIOCGIWSCAN
) = (iw_handler
) cfg80211_wext_giwscan
,
2017 IW_IOCTL(SIOCSIWESSID
) = rndis_iw_set_essid
,
2018 IW_IOCTL(SIOCGIWESSID
) = rndis_iw_get_essid
,
2019 IW_IOCTL(SIOCGIWRATE
) = rndis_iw_get_rate
,
2020 IW_IOCTL(SIOCSIWRTS
) = rndis_iw_set_rts
,
2021 IW_IOCTL(SIOCGIWRTS
) = rndis_iw_get_rts
,
2022 IW_IOCTL(SIOCSIWFRAG
) = rndis_iw_set_frag
,
2023 IW_IOCTL(SIOCGIWFRAG
) = rndis_iw_get_frag
,
2024 IW_IOCTL(SIOCSIWTXPOW
) = rndis_iw_set_txpower
,
2025 IW_IOCTL(SIOCGIWTXPOW
) = rndis_iw_get_txpower
,
2026 IW_IOCTL(SIOCSIWENCODE
) = rndis_iw_set_encode
,
2027 IW_IOCTL(SIOCSIWENCODEEXT
) = rndis_iw_set_encode_ext
,
2028 IW_IOCTL(SIOCSIWAUTH
) = rndis_iw_set_auth
,
2029 IW_IOCTL(SIOCGIWAUTH
) = rndis_iw_get_auth
,
2030 IW_IOCTL(SIOCSIWGENIE
) = rndis_iw_set_genie
,
2031 IW_IOCTL(SIOCGIWGENIE
) = rndis_iw_get_genie
,
2032 IW_IOCTL(SIOCSIWMLME
) = rndis_iw_set_mlme
,
2035 static const iw_handler rndis_wlan_private_handler
[] = {
2038 static const struct iw_priv_args rndis_wlan_private_args
[] = {
2042 static const struct iw_handler_def rndis_iw_handlers
= {
2043 .num_standard
= ARRAY_SIZE(rndis_iw_handler
),
2044 .num_private
= ARRAY_SIZE(rndis_wlan_private_handler
),
2045 .num_private_args
= ARRAY_SIZE(rndis_wlan_private_args
),
2046 .standard
= (iw_handler
*)rndis_iw_handler
,
2047 .private = (iw_handler
*)rndis_wlan_private_handler
,
2048 .private_args
= (struct iw_priv_args
*)rndis_wlan_private_args
,
2049 .get_wireless_stats
= rndis_get_wireless_stats
,
2053 static void rndis_wlan_worker(struct work_struct
*work
)
2055 struct rndis_wlan_private
*priv
=
2056 container_of(work
, struct rndis_wlan_private
, work
);
2057 struct usbnet
*usbdev
= priv
->usbdev
;
2058 union iwreq_data evt
;
2059 unsigned char bssid
[ETH_ALEN
];
2060 struct ndis_80211_assoc_info
*info
;
2061 int assoc_size
= sizeof(*info
) + IW_CUSTOM_MAX
+ 32;
2064 if (test_and_clear_bit(WORK_LINK_UP
, &priv
->work_pending
)) {
2065 netif_carrier_on(usbdev
->net
);
2067 info
= kzalloc(assoc_size
, GFP_KERNEL
);
2071 /* Get association info IEs from device and send them back to
2073 ret
= get_association_info(usbdev
, info
, assoc_size
);
2075 evt
.data
.length
= le32_to_cpu(info
->req_ie_length
);
2076 if (evt
.data
.length
> 0) {
2077 offset
= le32_to_cpu(info
->offset_req_ies
);
2078 wireless_send_event(usbdev
->net
,
2079 IWEVASSOCREQIE
, &evt
,
2080 (char *)info
+ offset
);
2083 evt
.data
.length
= le32_to_cpu(info
->resp_ie_length
);
2084 if (evt
.data
.length
> 0) {
2085 offset
= le32_to_cpu(info
->offset_resp_ies
);
2086 wireless_send_event(usbdev
->net
,
2087 IWEVASSOCRESPIE
, &evt
,
2088 (char *)info
+ offset
);
2095 ret
= get_bssid(usbdev
, bssid
);
2098 evt
.data
.length
= 0;
2099 memcpy(evt
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
2100 wireless_send_event(usbdev
->net
, SIOCGIWAP
, &evt
, NULL
);
2104 if (test_and_clear_bit(WORK_LINK_DOWN
, &priv
->work_pending
)) {
2105 netif_carrier_off(usbdev
->net
);
2108 evt
.data
.length
= 0;
2109 memset(evt
.ap_addr
.sa_data
, 0, ETH_ALEN
);
2110 wireless_send_event(usbdev
->net
, SIOCGIWAP
, &evt
, NULL
);
2113 if (test_and_clear_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
))
2114 set_multicast_list(usbdev
);
2117 static void rndis_wlan_set_multicast_list(struct net_device
*dev
)
2119 struct usbnet
*usbdev
= netdev_priv(dev
);
2120 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2122 if (test_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
))
2125 set_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
);
2126 queue_work(priv
->workqueue
, &priv
->work
);
2129 static void rndis_wlan_link_change(struct usbnet
*usbdev
, int state
)
2131 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2133 /* queue work to avoid recursive calls into rndis_command */
2134 set_bit(state
? WORK_LINK_UP
: WORK_LINK_DOWN
, &priv
->work_pending
);
2135 queue_work(priv
->workqueue
, &priv
->work
);
2139 static int rndis_wlan_get_caps(struct usbnet
*usbdev
)
2144 } networks_supported
;
2145 int len
, retval
, i
, n
;
2146 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2148 /* determine supported modes */
2149 len
= sizeof(networks_supported
);
2150 retval
= rndis_query_oid(usbdev
, OID_802_11_NETWORK_TYPES_SUPPORTED
,
2151 &networks_supported
, &len
);
2153 n
= le32_to_cpu(networks_supported
.num_items
);
2156 for (i
= 0; i
< n
; i
++) {
2157 switch (le32_to_cpu(networks_supported
.items
[i
])) {
2158 case NDIS_80211_TYPE_FREQ_HOP
:
2159 case NDIS_80211_TYPE_DIRECT_SEQ
:
2160 priv
->caps
|= CAP_MODE_80211B
;
2162 case NDIS_80211_TYPE_OFDM_A
:
2163 priv
->caps
|= CAP_MODE_80211A
;
2165 case NDIS_80211_TYPE_OFDM_G
:
2166 priv
->caps
|= CAP_MODE_80211G
;
2176 #define STATS_UPDATE_JIFFIES (HZ)
2177 static void rndis_update_wireless_stats(struct work_struct
*work
)
2179 struct rndis_wlan_private
*priv
=
2180 container_of(work
, struct rndis_wlan_private
, stats_work
.work
);
2181 struct usbnet
*usbdev
= priv
->usbdev
;
2182 struct iw_statistics iwstats
;
2185 unsigned long flags
;
2186 int update_jiffies
= STATS_UPDATE_JIFFIES
;
2189 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2190 memcpy(&iwstats
, &priv
->privstats
, sizeof(iwstats
));
2191 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2193 /* only update stats when connected */
2194 if (!is_associated(usbdev
)) {
2195 iwstats
.qual
.qual
= 0;
2196 iwstats
.qual
.level
= 0;
2197 iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2198 | IW_QUAL_LEVEL_UPDATED
2199 | IW_QUAL_NOISE_INVALID
2200 | IW_QUAL_QUAL_INVALID
2201 | IW_QUAL_LEVEL_INVALID
;
2206 ret
= rndis_query_oid(usbdev
, OID_802_11_RSSI
, &rssi
, &len
);
2208 devdbg(usbdev
, "stats: OID_802_11_RSSI -> %d, rssi:%d", ret
,
2211 memset(&iwstats
.qual
, 0, sizeof(iwstats
.qual
));
2212 iwstats
.qual
.qual
= level_to_qual(le32_to_cpu(rssi
));
2213 iwstats
.qual
.level
= level_to_qual(le32_to_cpu(rssi
));
2214 iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2215 | IW_QUAL_LEVEL_UPDATED
2216 | IW_QUAL_NOISE_INVALID
;
2219 memset(&iwstats
.discard
, 0, sizeof(iwstats
.discard
));
2222 ret
= rndis_query_oid(usbdev
, OID_GEN_XMIT_ERROR
, &tmp
, &len
);
2224 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2227 ret
= rndis_query_oid(usbdev
, OID_GEN_RCV_ERROR
, &tmp
, &len
);
2229 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2232 ret
= rndis_query_oid(usbdev
, OID_GEN_RCV_NO_BUFFER
, &tmp
, &len
);
2234 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2236 /* Workaround transfer stalls on poor quality links.
2237 * TODO: find right way to fix these stalls (as stalls do not happen
2238 * with ndiswrapper/windows driver). */
2239 if (iwstats
.qual
.qual
<= 25) {
2240 /* Decrease stats worker interval to catch stalls.
2241 * faster. Faster than 400-500ms causes packet loss,
2242 * Slower doesn't catch stalls fast enough.
2244 j
= msecs_to_jiffies(priv
->param_workaround_interval
);
2245 if (j
> STATS_UPDATE_JIFFIES
)
2246 j
= STATS_UPDATE_JIFFIES
;
2251 /* Send scan OID. Use of both OIDs is required to get device
2254 tmp
= cpu_to_le32(1);
2255 rndis_set_oid(usbdev
, OID_802_11_BSSID_LIST_SCAN
, &tmp
,
2258 len
= CONTROL_BUFFER_SIZE
;
2259 buf
= kmalloc(len
, GFP_KERNEL
);
2263 rndis_query_oid(usbdev
, OID_802_11_BSSID_LIST
, buf
, &len
);
2267 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2268 memcpy(&priv
->privstats
, &iwstats
, sizeof(iwstats
));
2269 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2271 if (update_jiffies
>= HZ
)
2272 update_jiffies
= round_jiffies_relative(update_jiffies
);
2274 j
= round_jiffies_relative(update_jiffies
);
2275 if (abs(j
- update_jiffies
) <= 10)
2279 queue_delayed_work(priv
->workqueue
, &priv
->stats_work
, update_jiffies
);
2283 static int bcm4320a_early_init(struct usbnet
*usbdev
)
2285 /* bcm4320a doesn't handle configuration parameters well. Try
2286 * set any and you get partially zeroed mac and broken device.
2293 static int bcm4320b_early_init(struct usbnet
*usbdev
)
2295 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2298 /* Early initialization settings, setting these won't have effect
2299 * if called after generic_rndis_bind().
2302 priv
->param_country
[0] = modparam_country
[0];
2303 priv
->param_country
[1] = modparam_country
[1];
2304 priv
->param_country
[2] = 0;
2305 priv
->param_frameburst
= modparam_frameburst
;
2306 priv
->param_afterburner
= modparam_afterburner
;
2307 priv
->param_power_save
= modparam_power_save
;
2308 priv
->param_power_output
= modparam_power_output
;
2309 priv
->param_roamtrigger
= modparam_roamtrigger
;
2310 priv
->param_roamdelta
= modparam_roamdelta
;
2312 priv
->param_country
[0] = toupper(priv
->param_country
[0]);
2313 priv
->param_country
[1] = toupper(priv
->param_country
[1]);
2314 /* doesn't support EU as country code, use FI instead */
2315 if (!strcmp(priv
->param_country
, "EU"))
2316 strcpy(priv
->param_country
, "FI");
2318 if (priv
->param_power_save
< 0)
2319 priv
->param_power_save
= 0;
2320 else if (priv
->param_power_save
> 2)
2321 priv
->param_power_save
= 2;
2323 if (priv
->param_power_output
< 0)
2324 priv
->param_power_output
= 0;
2325 else if (priv
->param_power_output
> 3)
2326 priv
->param_power_output
= 3;
2328 if (priv
->param_roamtrigger
< -80)
2329 priv
->param_roamtrigger
= -80;
2330 else if (priv
->param_roamtrigger
> -60)
2331 priv
->param_roamtrigger
= -60;
2333 if (priv
->param_roamdelta
< 0)
2334 priv
->param_roamdelta
= 0;
2335 else if (priv
->param_roamdelta
> 2)
2336 priv
->param_roamdelta
= 2;
2338 if (modparam_workaround_interval
< 0)
2339 priv
->param_workaround_interval
= 500;
2341 priv
->param_workaround_interval
= modparam_workaround_interval
;
2343 rndis_set_config_parameter_str(usbdev
, "Country", priv
->param_country
);
2344 rndis_set_config_parameter_str(usbdev
, "FrameBursting",
2345 priv
->param_frameburst
? "1" : "0");
2346 rndis_set_config_parameter_str(usbdev
, "Afterburner",
2347 priv
->param_afterburner
? "1" : "0");
2348 sprintf(buf
, "%d", priv
->param_power_save
);
2349 rndis_set_config_parameter_str(usbdev
, "PowerSaveMode", buf
);
2350 sprintf(buf
, "%d", priv
->param_power_output
);
2351 rndis_set_config_parameter_str(usbdev
, "PwrOut", buf
);
2352 sprintf(buf
, "%d", priv
->param_roamtrigger
);
2353 rndis_set_config_parameter_str(usbdev
, "RoamTrigger", buf
);
2354 sprintf(buf
, "%d", priv
->param_roamdelta
);
2355 rndis_set_config_parameter_str(usbdev
, "RoamDelta", buf
);
2360 /* same as rndis_netdev_ops but with local multicast handler */
2361 static const struct net_device_ops rndis_wlan_netdev_ops
= {
2362 .ndo_open
= usbnet_open
,
2363 .ndo_stop
= usbnet_stop
,
2364 .ndo_start_xmit
= usbnet_start_xmit
,
2365 .ndo_tx_timeout
= usbnet_tx_timeout
,
2366 .ndo_set_mac_address
= eth_mac_addr
,
2367 .ndo_validate_addr
= eth_validate_addr
,
2368 .ndo_set_multicast_list
= rndis_wlan_set_multicast_list
,
2372 static int rndis_wlan_bind(struct usbnet
*usbdev
, struct usb_interface
*intf
)
2374 struct wiphy
*wiphy
;
2375 struct rndis_wlan_private
*priv
;
2379 /* allocate wiphy and rndis private data
2380 * NOTE: We only support a single virtual interface, so wiphy
2381 * and wireless_dev are somewhat synonymous for this device.
2383 wiphy
= wiphy_new(&rndis_config_ops
, sizeof(struct rndis_wlan_private
));
2387 priv
= wiphy_priv(wiphy
);
2388 usbdev
->net
->ieee80211_ptr
= &priv
->wdev
;
2389 priv
->wdev
.wiphy
= wiphy
;
2390 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2392 /* These have to be initialized before calling generic_rndis_bind().
2393 * Otherwise we'll be in big trouble in rndis_wlan_early_init().
2395 usbdev
->driver_priv
= priv
;
2396 usbdev
->net
->wireless_handlers
= &rndis_iw_handlers
;
2397 priv
->usbdev
= usbdev
;
2399 mutex_init(&priv
->command_lock
);
2400 spin_lock_init(&priv
->stats_lock
);
2402 /* because rndis_command() sleeps we need to use workqueue */
2403 priv
->workqueue
= create_singlethread_workqueue("rndis_wlan");
2404 INIT_WORK(&priv
->work
, rndis_wlan_worker
);
2405 INIT_DELAYED_WORK(&priv
->stats_work
, rndis_update_wireless_stats
);
2406 INIT_DELAYED_WORK(&priv
->scan_work
, rndis_get_scan_results
);
2408 /* try bind rndis_host */
2409 retval
= generic_rndis_bind(usbdev
, intf
, FLAG_RNDIS_PHYM_WIRELESS
);
2413 /* generic_rndis_bind set packet filter to multicast_all+
2414 * promisc mode which doesn't work well for our devices (device
2415 * picks up rssi to closest station instead of to access point).
2417 * rndis_host wants to avoid all OID as much as possible
2418 * so do promisc/multicast handling in rndis_wlan.
2420 usbdev
->net
->netdev_ops
= &rndis_wlan_netdev_ops
;
2422 tmp
= RNDIS_PACKET_TYPE_DIRECTED
| RNDIS_PACKET_TYPE_BROADCAST
;
2423 retval
= rndis_set_oid(usbdev
, OID_GEN_CURRENT_PACKET_FILTER
, &tmp
,
2427 retval
= rndis_query_oid(usbdev
, OID_802_3_MAXIMUM_LIST_SIZE
, &tmp
,
2429 priv
->multicast_size
= le32_to_cpu(tmp
);
2430 if (retval
< 0 || priv
->multicast_size
< 0)
2431 priv
->multicast_size
= 0;
2432 if (priv
->multicast_size
> 0)
2433 usbdev
->net
->flags
|= IFF_MULTICAST
;
2435 usbdev
->net
->flags
&= ~IFF_MULTICAST
;
2437 priv
->iwstats
.qual
.qual
= 0;
2438 priv
->iwstats
.qual
.level
= 0;
2439 priv
->iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2440 | IW_QUAL_LEVEL_UPDATED
2441 | IW_QUAL_NOISE_INVALID
2442 | IW_QUAL_QUAL_INVALID
2443 | IW_QUAL_LEVEL_INVALID
;
2445 /* fill-out wiphy structure and register w/ cfg80211 */
2446 memcpy(wiphy
->perm_addr
, usbdev
->net
->dev_addr
, ETH_ALEN
);
2447 wiphy
->privid
= rndis_wiphy_privid
;
2448 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
)
2449 | BIT(NL80211_IFTYPE_ADHOC
);
2450 wiphy
->max_scan_ssids
= 1;
2452 /* TODO: fill-out band information based on priv->caps */
2453 rndis_wlan_get_caps(usbdev
);
2455 memcpy(priv
->channels
, rndis_channels
, sizeof(rndis_channels
));
2456 memcpy(priv
->rates
, rndis_rates
, sizeof(rndis_rates
));
2457 priv
->band
.channels
= priv
->channels
;
2458 priv
->band
.n_channels
= ARRAY_SIZE(rndis_channels
);
2459 priv
->band
.bitrates
= priv
->rates
;
2460 priv
->band
.n_bitrates
= ARRAY_SIZE(rndis_rates
);
2461 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &priv
->band
;
2462 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_UNSPEC
;
2464 set_wiphy_dev(wiphy
, &usbdev
->udev
->dev
);
2466 if (wiphy_register(wiphy
)) {
2471 set_default_iw_params(usbdev
);
2475 disassociate(usbdev
, 1);
2476 netif_carrier_off(usbdev
->net
);
2478 queue_delayed_work(priv
->workqueue
, &priv
->stats_work
,
2479 round_jiffies_relative(STATS_UPDATE_JIFFIES
));
2484 cancel_delayed_work_sync(&priv
->stats_work
);
2485 cancel_delayed_work_sync(&priv
->scan_work
);
2486 cancel_work_sync(&priv
->work
);
2487 flush_workqueue(priv
->workqueue
);
2488 destroy_workqueue(priv
->workqueue
);
2495 static void rndis_wlan_unbind(struct usbnet
*usbdev
, struct usb_interface
*intf
)
2497 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2499 /* turn radio off */
2500 disassociate(usbdev
, 0);
2502 cancel_delayed_work_sync(&priv
->stats_work
);
2503 cancel_delayed_work_sync(&priv
->scan_work
);
2504 cancel_work_sync(&priv
->work
);
2505 flush_workqueue(priv
->workqueue
);
2506 destroy_workqueue(priv
->workqueue
);
2508 if (priv
&& priv
->wpa_ie_len
)
2509 kfree(priv
->wpa_ie
);
2511 rndis_unbind(usbdev
, intf
);
2513 wiphy_unregister(priv
->wdev
.wiphy
);
2514 wiphy_free(priv
->wdev
.wiphy
);
2518 static int rndis_wlan_reset(struct usbnet
*usbdev
)
2520 return deauthenticate(usbdev
);
2524 static const struct driver_info bcm4320b_info
= {
2525 .description
= "Wireless RNDIS device, BCM4320b based",
2526 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2527 .bind
= rndis_wlan_bind
,
2528 .unbind
= rndis_wlan_unbind
,
2529 .status
= rndis_status
,
2530 .rx_fixup
= rndis_rx_fixup
,
2531 .tx_fixup
= rndis_tx_fixup
,
2532 .reset
= rndis_wlan_reset
,
2533 .early_init
= bcm4320b_early_init
,
2534 .link_change
= rndis_wlan_link_change
,
2537 static const struct driver_info bcm4320a_info
= {
2538 .description
= "Wireless RNDIS device, BCM4320a based",
2539 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2540 .bind
= rndis_wlan_bind
,
2541 .unbind
= rndis_wlan_unbind
,
2542 .status
= rndis_status
,
2543 .rx_fixup
= rndis_rx_fixup
,
2544 .tx_fixup
= rndis_tx_fixup
,
2545 .reset
= rndis_wlan_reset
,
2546 .early_init
= bcm4320a_early_init
,
2547 .link_change
= rndis_wlan_link_change
,
2550 static const struct driver_info rndis_wlan_info
= {
2551 .description
= "Wireless RNDIS device",
2552 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2553 .bind
= rndis_wlan_bind
,
2554 .unbind
= rndis_wlan_unbind
,
2555 .status
= rndis_status
,
2556 .rx_fixup
= rndis_rx_fixup
,
2557 .tx_fixup
= rndis_tx_fixup
,
2558 .reset
= rndis_wlan_reset
,
2559 .early_init
= bcm4320a_early_init
,
2560 .link_change
= rndis_wlan_link_change
,
2563 /*-------------------------------------------------------------------------*/
2565 static const struct usb_device_id products
[] = {
2566 #define RNDIS_MASTER_INTERFACE \
2567 .bInterfaceClass = USB_CLASS_COMM, \
2568 .bInterfaceSubClass = 2 /* ACM */, \
2569 .bInterfaceProtocol = 0x0ff
2571 /* INF driver for these devices have DriverVer >= 4.xx.xx.xx and many custom
2572 * parameters available. Chipset marked as 'BCM4320SKFBG' in NDISwrapper-wiki.
2575 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2576 | USB_DEVICE_ID_MATCH_DEVICE
,
2578 .idProduct
= 0x00bc, /* Buffalo WLI-U2-KG125S */
2579 RNDIS_MASTER_INTERFACE
,
2580 .driver_info
= (unsigned long) &bcm4320b_info
,
2582 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2583 | USB_DEVICE_ID_MATCH_DEVICE
,
2585 .idProduct
= 0x011b, /* U.S. Robotics USR5421 */
2586 RNDIS_MASTER_INTERFACE
,
2587 .driver_info
= (unsigned long) &bcm4320b_info
,
2589 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2590 | USB_DEVICE_ID_MATCH_DEVICE
,
2592 .idProduct
= 0x011b, /* Belkin F5D7051 */
2593 RNDIS_MASTER_INTERFACE
,
2594 .driver_info
= (unsigned long) &bcm4320b_info
,
2596 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2597 | USB_DEVICE_ID_MATCH_DEVICE
,
2598 .idVendor
= 0x1799, /* Belkin has two vendor ids */
2599 .idProduct
= 0x011b, /* Belkin F5D7051 */
2600 RNDIS_MASTER_INTERFACE
,
2601 .driver_info
= (unsigned long) &bcm4320b_info
,
2603 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2604 | USB_DEVICE_ID_MATCH_DEVICE
,
2606 .idProduct
= 0x0014, /* Linksys WUSB54GSv2 */
2607 RNDIS_MASTER_INTERFACE
,
2608 .driver_info
= (unsigned long) &bcm4320b_info
,
2610 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2611 | USB_DEVICE_ID_MATCH_DEVICE
,
2613 .idProduct
= 0x0026, /* Linksys WUSB54GSC */
2614 RNDIS_MASTER_INTERFACE
,
2615 .driver_info
= (unsigned long) &bcm4320b_info
,
2617 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2618 | USB_DEVICE_ID_MATCH_DEVICE
,
2620 .idProduct
= 0x1717, /* Asus WL169gE */
2621 RNDIS_MASTER_INTERFACE
,
2622 .driver_info
= (unsigned long) &bcm4320b_info
,
2624 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2625 | USB_DEVICE_ID_MATCH_DEVICE
,
2627 .idProduct
= 0xd11b, /* Eminent EM4045 */
2628 RNDIS_MASTER_INTERFACE
,
2629 .driver_info
= (unsigned long) &bcm4320b_info
,
2631 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2632 | USB_DEVICE_ID_MATCH_DEVICE
,
2634 .idProduct
= 0x0715, /* BT Voyager 1055 */
2635 RNDIS_MASTER_INTERFACE
,
2636 .driver_info
= (unsigned long) &bcm4320b_info
,
2638 /* These devices have DriverVer < 4.xx.xx.xx and do not have any custom
2639 * parameters available, hardware probably contain older firmware version with
2640 * no way of updating. Chipset marked as 'BCM4320????' in NDISwrapper-wiki.
2643 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2644 | USB_DEVICE_ID_MATCH_DEVICE
,
2646 .idProduct
= 0x000e, /* Linksys WUSB54GSv1 */
2647 RNDIS_MASTER_INTERFACE
,
2648 .driver_info
= (unsigned long) &bcm4320a_info
,
2650 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2651 | USB_DEVICE_ID_MATCH_DEVICE
,
2653 .idProduct
= 0x0111, /* U.S. Robotics USR5420 */
2654 RNDIS_MASTER_INTERFACE
,
2655 .driver_info
= (unsigned long) &bcm4320a_info
,
2657 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2658 | USB_DEVICE_ID_MATCH_DEVICE
,
2660 .idProduct
= 0x004b, /* BUFFALO WLI-USB-G54 */
2661 RNDIS_MASTER_INTERFACE
,
2662 .driver_info
= (unsigned long) &bcm4320a_info
,
2664 /* Generic Wireless RNDIS devices that we don't have exact
2665 * idVendor/idProduct/chip yet.
2668 /* RNDIS is MSFT's un-official variant of CDC ACM */
2669 USB_INTERFACE_INFO(USB_CLASS_COMM
, 2 /* ACM */, 0x0ff),
2670 .driver_info
= (unsigned long) &rndis_wlan_info
,
2672 /* "ActiveSync" is an undocumented variant of RNDIS, used in WM5 */
2673 USB_INTERFACE_INFO(USB_CLASS_MISC
, 1, 1),
2674 .driver_info
= (unsigned long) &rndis_wlan_info
,
2678 MODULE_DEVICE_TABLE(usb
, products
);
2680 static struct usb_driver rndis_wlan_driver
= {
2681 .name
= "rndis_wlan",
2682 .id_table
= products
,
2683 .probe
= usbnet_probe
,
2684 .disconnect
= usbnet_disconnect
,
2685 .suspend
= usbnet_suspend
,
2686 .resume
= usbnet_resume
,
2689 static int __init
rndis_wlan_init(void)
2691 return usb_register(&rndis_wlan_driver
);
2693 module_init(rndis_wlan_init
);
2695 static void __exit
rndis_wlan_exit(void)
2697 usb_deregister(&rndis_wlan_driver
);
2699 module_exit(rndis_wlan_exit
);
2701 MODULE_AUTHOR("Bjorge Dijkstra");
2702 MODULE_AUTHOR("Jussi Kivilinna");
2703 MODULE_DESCRIPTION("Driver for RNDIS based USB Wireless adapters");
2704 MODULE_LICENSE("GPL");