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.
142 * 100% : 20 mW ~ 13dBm
143 * 75% : 15 mW ~ 12dBm
144 * 50% : 10 mW ~ 10dBm
147 #define BCM4320_DEFAULT_TXPOWER_DBM_100 13
148 #define BCM4320_DEFAULT_TXPOWER_DBM_75 12
149 #define BCM4320_DEFAULT_TXPOWER_DBM_50 10
150 #define BCM4320_DEFAULT_TXPOWER_DBM_25 7
153 /* codes for "status" field of completion messages */
154 #define RNDIS_STATUS_ADAPTER_NOT_READY cpu_to_le32(0xc0010011)
155 #define RNDIS_STATUS_ADAPTER_NOT_OPEN cpu_to_le32(0xc0010012)
158 /* NDIS data structures. Taken from wpa_supplicant driver_ndis.c
159 * slightly modified for datatype endianess, etc
161 #define NDIS_802_11_LENGTH_SSID 32
162 #define NDIS_802_11_LENGTH_RATES 8
163 #define NDIS_802_11_LENGTH_RATES_EX 16
165 enum ndis_80211_net_type
{
166 NDIS_80211_TYPE_FREQ_HOP
,
167 NDIS_80211_TYPE_DIRECT_SEQ
,
168 NDIS_80211_TYPE_OFDM_A
,
169 NDIS_80211_TYPE_OFDM_G
172 enum ndis_80211_net_infra
{
173 NDIS_80211_INFRA_ADHOC
,
174 NDIS_80211_INFRA_INFRA
,
175 NDIS_80211_INFRA_AUTO_UNKNOWN
178 enum ndis_80211_auth_mode
{
179 NDIS_80211_AUTH_OPEN
,
180 NDIS_80211_AUTH_SHARED
,
181 NDIS_80211_AUTH_AUTO_SWITCH
,
183 NDIS_80211_AUTH_WPA_PSK
,
184 NDIS_80211_AUTH_WPA_NONE
,
185 NDIS_80211_AUTH_WPA2
,
186 NDIS_80211_AUTH_WPA2_PSK
189 enum ndis_80211_encr_status
{
190 NDIS_80211_ENCR_WEP_ENABLED
,
191 NDIS_80211_ENCR_DISABLED
,
192 NDIS_80211_ENCR_WEP_KEY_ABSENT
,
193 NDIS_80211_ENCR_NOT_SUPPORTED
,
194 NDIS_80211_ENCR_TKIP_ENABLED
,
195 NDIS_80211_ENCR_TKIP_KEY_ABSENT
,
196 NDIS_80211_ENCR_CCMP_ENABLED
,
197 NDIS_80211_ENCR_CCMP_KEY_ABSENT
200 enum ndis_80211_priv_filter
{
201 NDIS_80211_PRIV_ACCEPT_ALL
,
202 NDIS_80211_PRIV_8021X_WEP
205 enum ndis_80211_addkey_bits
{
206 NDIS_80211_ADDKEY_8021X_AUTH
= cpu_to_le32(1 << 28),
207 NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
= cpu_to_le32(1 << 29),
208 NDIS_80211_ADDKEY_PAIRWISE_KEY
= cpu_to_le32(1 << 30),
209 NDIS_80211_ADDKEY_TRANSMIT_KEY
= cpu_to_le32(1 << 31)
212 enum ndis_80211_addwep_bits
{
213 NDIS_80211_ADDWEP_PERCLIENT_KEY
= cpu_to_le32(1 << 30),
214 NDIS_80211_ADDWEP_TRANSMIT_KEY
= cpu_to_le32(1 << 31)
217 struct ndis_80211_ssid
{
219 u8 essid
[NDIS_802_11_LENGTH_SSID
];
220 } __attribute__((packed
));
222 struct ndis_80211_conf_freq_hop
{
227 } __attribute__((packed
));
229 struct ndis_80211_conf
{
231 __le32 beacon_period
;
234 struct ndis_80211_conf_freq_hop fh_config
;
235 } __attribute__((packed
));
237 struct ndis_80211_bssid_ex
{
241 struct ndis_80211_ssid ssid
;
245 struct ndis_80211_conf config
;
247 u8 rates
[NDIS_802_11_LENGTH_RATES_EX
];
250 } __attribute__((packed
));
252 struct ndis_80211_bssid_list_ex
{
254 struct ndis_80211_bssid_ex bssid
[0];
255 } __attribute__((packed
));
257 struct ndis_80211_fixed_ies
{
259 __le16 beacon_interval
;
261 } __attribute__((packed
));
263 struct ndis_80211_wep_key
{
268 } __attribute__((packed
));
270 struct ndis_80211_key
{
278 } __attribute__((packed
));
280 struct ndis_80211_remove_key
{
284 } __attribute__((packed
));
286 struct ndis_config_param
{
292 } __attribute__((packed
));
294 struct ndis_80211_assoc_info
{
299 __le16 listen_interval
;
300 u8 cur_ap_address
[6];
302 __le32 req_ie_length
;
303 __le32 offset_req_ies
;
310 __le32 resp_ie_length
;
311 __le32 offset_resp_ies
;
312 } __attribute__((packed
));
314 /* these have to match what is in wpa_supplicant */
315 enum wpa_alg
{ WPA_ALG_NONE
, WPA_ALG_WEP
, WPA_ALG_TKIP
, WPA_ALG_CCMP
};
316 enum wpa_cipher
{ CIPHER_NONE
, CIPHER_WEP40
, CIPHER_TKIP
, CIPHER_CCMP
,
318 enum wpa_key_mgmt
{ KEY_MGMT_802_1X
, KEY_MGMT_PSK
, KEY_MGMT_NONE
,
319 KEY_MGMT_802_1X_NO_WPA
, KEY_MGMT_WPA_NONE
};
324 #define NET_TYPE_11FB 0
326 #define CAP_MODE_80211A 1
327 #define CAP_MODE_80211B 2
328 #define CAP_MODE_80211G 4
329 #define CAP_MODE_MASK 7
331 #define WORK_LINK_UP (1<<0)
332 #define WORK_LINK_DOWN (1<<1)
333 #define WORK_SET_MULTICAST_LIST (1<<2)
335 #define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set))
337 static const struct ieee80211_channel rndis_channels
[] = {
338 { .center_freq
= 2412 },
339 { .center_freq
= 2417 },
340 { .center_freq
= 2422 },
341 { .center_freq
= 2427 },
342 { .center_freq
= 2432 },
343 { .center_freq
= 2437 },
344 { .center_freq
= 2442 },
345 { .center_freq
= 2447 },
346 { .center_freq
= 2452 },
347 { .center_freq
= 2457 },
348 { .center_freq
= 2462 },
349 { .center_freq
= 2467 },
350 { .center_freq
= 2472 },
351 { .center_freq
= 2484 },
354 static const struct ieee80211_rate rndis_rates
[] = {
356 { .bitrate
= 20, .flags
= IEEE80211_RATE_SHORT_PREAMBLE
},
357 { .bitrate
= 55, .flags
= IEEE80211_RATE_SHORT_PREAMBLE
},
358 { .bitrate
= 110, .flags
= IEEE80211_RATE_SHORT_PREAMBLE
},
369 /* RNDIS device private data */
370 struct rndis_wlan_private
{
371 struct usbnet
*usbdev
;
373 struct wireless_dev wdev
;
375 struct cfg80211_scan_request
*scan_request
;
377 struct workqueue_struct
*workqueue
;
378 struct delayed_work stats_work
;
379 struct delayed_work scan_work
;
380 struct work_struct work
;
381 struct mutex command_lock
;
382 spinlock_t stats_lock
;
383 unsigned long work_pending
;
385 struct ieee80211_supported_band band
;
386 struct ieee80211_channel channels
[ARRAY_SIZE(rndis_channels
)];
387 struct ieee80211_rate rates
[ARRAY_SIZE(rndis_rates
)];
389 struct iw_statistics iwstats
;
390 struct iw_statistics privstats
;
395 /* module parameters */
396 char param_country
[4];
397 int param_frameburst
;
398 int param_afterburner
;
399 int param_power_save
;
400 int param_power_output
;
401 int param_roamtrigger
;
403 u32 param_workaround_interval
;
408 struct ndis_80211_ssid essid
;
410 /* encryption stuff */
411 int encr_tx_key_index
;
412 char encr_keys
[4][32];
414 char encr_key_wpa
[4];
421 int wpa_cipher_group
;
423 u8 command_buffer
[COMMAND_BUFFER_SIZE
];
429 static int rndis_change_virtual_intf(struct wiphy
*wiphy
,
430 struct net_device
*dev
,
431 enum nl80211_iftype type
, u32
*flags
,
432 struct vif_params
*params
);
434 static int rndis_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
435 struct cfg80211_scan_request
*request
);
437 static int rndis_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
);
439 static int rndis_set_tx_power(struct wiphy
*wiphy
, enum tx_power_setting type
,
441 static int rndis_get_tx_power(struct wiphy
*wiphy
, int *dbm
);
443 static struct cfg80211_ops rndis_config_ops
= {
444 .change_virtual_intf
= rndis_change_virtual_intf
,
446 .set_wiphy_params
= rndis_set_wiphy_params
,
447 .set_tx_power
= rndis_set_tx_power
,
448 .get_tx_power
= rndis_get_tx_power
,
451 static void *rndis_wiphy_privid
= &rndis_wiphy_privid
;
454 static const unsigned char zero_bssid
[ETH_ALEN
] = {0,};
455 static const unsigned char ffff_bssid
[ETH_ALEN
] = { 0xff, 0xff, 0xff,
459 static struct rndis_wlan_private
*get_rndis_wlan_priv(struct usbnet
*dev
)
461 return (struct rndis_wlan_private
*)dev
->driver_priv
;
465 static u32
get_bcm4320_power_dbm(struct rndis_wlan_private
*priv
)
467 switch (priv
->param_power_output
) {
470 return BCM4320_DEFAULT_TXPOWER_DBM_100
;
472 return BCM4320_DEFAULT_TXPOWER_DBM_75
;
474 return BCM4320_DEFAULT_TXPOWER_DBM_50
;
476 return BCM4320_DEFAULT_TXPOWER_DBM_25
;
481 /* translate error code */
482 static int rndis_error_status(__le32 rndis_status
)
485 switch (rndis_status
) {
486 case RNDIS_STATUS_SUCCESS
:
489 case RNDIS_STATUS_FAILURE
:
490 case RNDIS_STATUS_INVALID_DATA
:
493 case RNDIS_STATUS_NOT_SUPPORTED
:
496 case RNDIS_STATUS_ADAPTER_NOT_READY
:
497 case RNDIS_STATUS_ADAPTER_NOT_OPEN
:
505 static int rndis_query_oid(struct usbnet
*dev
, __le32 oid
, void *data
, int *len
)
507 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(dev
);
510 struct rndis_msg_hdr
*header
;
511 struct rndis_query
*get
;
512 struct rndis_query_c
*get_c
;
516 buflen
= *len
+ sizeof(*u
.get
);
517 if (buflen
< CONTROL_BUFFER_SIZE
)
518 buflen
= CONTROL_BUFFER_SIZE
;
520 if (buflen
> COMMAND_BUFFER_SIZE
) {
521 u
.buf
= kmalloc(buflen
, GFP_KERNEL
);
525 u
.buf
= priv
->command_buffer
;
528 mutex_lock(&priv
->command_lock
);
530 memset(u
.get
, 0, sizeof *u
.get
);
531 u
.get
->msg_type
= RNDIS_MSG_QUERY
;
532 u
.get
->msg_len
= cpu_to_le32(sizeof *u
.get
);
535 ret
= rndis_command(dev
, u
.header
, buflen
);
537 ret
= le32_to_cpu(u
.get_c
->len
);
538 *len
= (*len
> ret
) ? ret
: *len
;
539 memcpy(data
, u
.buf
+ le32_to_cpu(u
.get_c
->offset
) + 8, *len
);
540 ret
= rndis_error_status(u
.get_c
->status
);
543 mutex_unlock(&priv
->command_lock
);
545 if (u
.buf
!= priv
->command_buffer
)
551 static int rndis_set_oid(struct usbnet
*dev
, __le32 oid
, void *data
, int len
)
553 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(dev
);
556 struct rndis_msg_hdr
*header
;
557 struct rndis_set
*set
;
558 struct rndis_set_c
*set_c
;
562 buflen
= len
+ sizeof(*u
.set
);
563 if (buflen
< CONTROL_BUFFER_SIZE
)
564 buflen
= CONTROL_BUFFER_SIZE
;
566 if (buflen
> COMMAND_BUFFER_SIZE
) {
567 u
.buf
= kmalloc(buflen
, GFP_KERNEL
);
571 u
.buf
= priv
->command_buffer
;
574 mutex_lock(&priv
->command_lock
);
576 memset(u
.set
, 0, sizeof *u
.set
);
577 u
.set
->msg_type
= RNDIS_MSG_SET
;
578 u
.set
->msg_len
= cpu_to_le32(sizeof(*u
.set
) + len
);
580 u
.set
->len
= cpu_to_le32(len
);
581 u
.set
->offset
= cpu_to_le32(sizeof(*u
.set
) - 8);
582 u
.set
->handle
= cpu_to_le32(0);
583 memcpy(u
.buf
+ sizeof(*u
.set
), data
, len
);
585 ret
= rndis_command(dev
, u
.header
, buflen
);
587 ret
= rndis_error_status(u
.set_c
->status
);
589 mutex_unlock(&priv
->command_lock
);
591 if (u
.buf
!= priv
->command_buffer
)
598 * Specs say that we can only set config parameters only soon after device
600 * value_type: 0 = u32, 2 = unicode string
602 static int rndis_set_config_parameter(struct usbnet
*dev
, char *param
,
603 int value_type
, void *value
)
605 struct ndis_config_param
*infobuf
;
606 int value_len
, info_len
, param_len
, ret
, i
;
611 value_len
= sizeof(__le32
);
612 else if (value_type
== 2)
613 value_len
= strlen(value
) * sizeof(__le16
);
617 param_len
= strlen(param
) * sizeof(__le16
);
618 info_len
= sizeof(*infobuf
) + param_len
+ value_len
;
623 infobuf
= kmalloc(info_len
, GFP_KERNEL
);
629 /* extra 12 bytes are for padding (debug output) */
630 memset(infobuf
, 0xCC, info_len
+ 12);
634 devdbg(dev
, "setting config parameter: %s, value: %s",
637 devdbg(dev
, "setting config parameter: %s, value: %d",
638 param
, *(u32
*)value
);
640 infobuf
->name_offs
= cpu_to_le32(sizeof(*infobuf
));
641 infobuf
->name_length
= cpu_to_le32(param_len
);
642 infobuf
->type
= cpu_to_le32(value_type
);
643 infobuf
->value_offs
= cpu_to_le32(sizeof(*infobuf
) + param_len
);
644 infobuf
->value_length
= cpu_to_le32(value_len
);
646 /* simple string to unicode string conversion */
647 unibuf
= (void *)infobuf
+ sizeof(*infobuf
);
648 for (i
= 0; i
< param_len
/ sizeof(__le16
); i
++)
649 unibuf
[i
] = cpu_to_le16(param
[i
]);
651 if (value_type
== 2) {
652 unibuf
= (void *)infobuf
+ sizeof(*infobuf
) + param_len
;
653 for (i
= 0; i
< value_len
/ sizeof(__le16
); i
++)
654 unibuf
[i
] = cpu_to_le16(((u8
*)value
)[i
]);
656 dst_value
= (void *)infobuf
+ sizeof(*infobuf
) + param_len
;
657 *dst_value
= cpu_to_le32(*(u32
*)value
);
661 devdbg(dev
, "info buffer (len: %d):", info_len
);
662 for (i
= 0; i
< info_len
; i
+= 12) {
663 u32
*tmp
= (u32
*)((u8
*)infobuf
+ i
);
664 devdbg(dev
, "%08X:%08X:%08X",
667 cpu_to_be32(tmp
[2]));
671 ret
= rndis_set_oid(dev
, OID_GEN_RNDIS_CONFIG_PARAMETER
,
674 devdbg(dev
, "setting rndis config parameter failed, %d.", ret
);
680 static int rndis_set_config_parameter_str(struct usbnet
*dev
,
681 char *param
, char *value
)
683 return(rndis_set_config_parameter(dev
, param
, 2, value
));
686 /*static int rndis_set_config_parameter_u32(struct usbnet *dev,
687 char *param, u32 value)
689 return(rndis_set_config_parameter(dev, param, 0, &value));
694 * data conversion functions
696 static int level_to_qual(int level
)
698 int qual
= 100 * (level
- WL_NOISE
) / (WL_SIGMAX
- WL_NOISE
);
699 return qual
>= 0 ? (qual
<= 100 ? qual
: 100) : 0;
703 static void dsconfig_to_freq(unsigned int dsconfig
, struct iw_freq
*freq
)
709 /* see comment in wireless.h above the "struct iw_freq"
710 * definition for an explanation of this if
711 * NOTE: 1000000 is due to the kHz
713 if (dsconfig
> 1000000) {
714 freq
->m
= dsconfig
/ 10;
719 /* convert from kHz to Hz */
724 static int freq_to_dsconfig(struct iw_freq
*freq
, unsigned int *dsconfig
)
726 if (freq
->m
< 1000 && freq
->e
== 0) {
727 if (freq
->m
>= 1 && freq
->m
<= 14)
728 *dsconfig
= ieee80211_dsss_chan_to_freq(freq
->m
) * 1000;
734 for (i
= freq
->e
; i
> 0; i
--)
747 add_wep_key(struct usbnet
*usbdev
, char *key
, int key_len
, int index
);
749 static int get_essid(struct usbnet
*usbdev
, struct ndis_80211_ssid
*ssid
)
754 ret
= rndis_query_oid(usbdev
, OID_802_11_SSID
, ssid
, &len
);
761 unsigned char tmp
[NDIS_802_11_LENGTH_SSID
+ 1];
763 memcpy(tmp
, ssid
->essid
, le32_to_cpu(ssid
->length
));
764 tmp
[le32_to_cpu(ssid
->length
)] = 0;
765 devdbg(usbdev
, "get_essid: '%s', ret: %d", tmp
, ret
);
772 static int set_essid(struct usbnet
*usbdev
, struct ndis_80211_ssid
*ssid
)
774 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
777 ret
= rndis_set_oid(usbdev
, OID_802_11_SSID
, ssid
, sizeof(*ssid
));
779 memcpy(&priv
->essid
, ssid
, sizeof(priv
->essid
));
781 devdbg(usbdev
, "set_essid: radio_on = 1");
788 static int get_bssid(struct usbnet
*usbdev
, u8 bssid
[ETH_ALEN
])
793 ret
= rndis_query_oid(usbdev
, OID_802_11_BSSID
, bssid
, &len
);
796 memset(bssid
, 0, ETH_ALEN
);
801 static int get_association_info(struct usbnet
*usbdev
,
802 struct ndis_80211_assoc_info
*info
, int len
)
804 return rndis_query_oid(usbdev
, OID_802_11_ASSOCIATION_INFORMATION
,
808 static int is_associated(struct usbnet
*usbdev
)
813 ret
= get_bssid(usbdev
, bssid
);
815 return(ret
== 0 && memcmp(bssid
, zero_bssid
, ETH_ALEN
) != 0);
819 static int disassociate(struct usbnet
*usbdev
, int reset_ssid
)
821 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
822 struct ndis_80211_ssid ssid
;
825 if (priv
->radio_on
) {
826 ret
= rndis_set_oid(usbdev
, OID_802_11_DISASSOCIATE
, NULL
, 0);
829 devdbg(usbdev
, "disassociate: radio_on = 0");
836 /* disassociate causes radio to be turned off; if reset_ssid
837 * is given, set random ssid to enable radio */
839 ssid
.length
= cpu_to_le32(sizeof(ssid
.essid
));
840 get_random_bytes(&ssid
.essid
[2], sizeof(ssid
.essid
)-2);
842 ssid
.essid
[1] = 0xff;
843 for (i
= 2; i
< sizeof(ssid
.essid
); i
++)
844 ssid
.essid
[i
] = 0x1 + (ssid
.essid
[i
] * 0xfe / 0xff);
845 ret
= set_essid(usbdev
, &ssid
);
851 static int set_auth_mode(struct usbnet
*usbdev
, int wpa_version
, int authalg
)
853 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
857 devdbg(usbdev
, "set_auth_mode: wpa_version=0x%x authalg=0x%x "
858 "keymgmt=0x%x", wpa_version
, authalg
, priv
->wpa_keymgmt
);
860 if (wpa_version
& IW_AUTH_WPA_VERSION_WPA2
) {
861 if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_802_1X
)
862 auth_mode
= NDIS_80211_AUTH_WPA2
;
864 auth_mode
= NDIS_80211_AUTH_WPA2_PSK
;
865 } else if (wpa_version
& IW_AUTH_WPA_VERSION_WPA
) {
866 if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_802_1X
)
867 auth_mode
= NDIS_80211_AUTH_WPA
;
868 else if (priv
->wpa_keymgmt
& IW_AUTH_KEY_MGMT_PSK
)
869 auth_mode
= NDIS_80211_AUTH_WPA_PSK
;
871 auth_mode
= NDIS_80211_AUTH_WPA_NONE
;
872 } else if (authalg
& IW_AUTH_ALG_SHARED_KEY
) {
873 if (authalg
& IW_AUTH_ALG_OPEN_SYSTEM
)
874 auth_mode
= NDIS_80211_AUTH_AUTO_SWITCH
;
876 auth_mode
= NDIS_80211_AUTH_SHARED
;
878 auth_mode
= NDIS_80211_AUTH_OPEN
;
880 tmp
= cpu_to_le32(auth_mode
);
881 ret
= rndis_set_oid(usbdev
, OID_802_11_AUTHENTICATION_MODE
, &tmp
,
884 devwarn(usbdev
, "setting auth mode failed (%08X)", ret
);
888 priv
->wpa_version
= wpa_version
;
889 priv
->wpa_authalg
= authalg
;
894 static int set_priv_filter(struct usbnet
*usbdev
)
896 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
899 devdbg(usbdev
, "set_priv_filter: wpa_version=0x%x", priv
->wpa_version
);
901 if (priv
->wpa_version
& IW_AUTH_WPA_VERSION_WPA2
||
902 priv
->wpa_version
& IW_AUTH_WPA_VERSION_WPA
)
903 tmp
= cpu_to_le32(NDIS_80211_PRIV_8021X_WEP
);
905 tmp
= cpu_to_le32(NDIS_80211_PRIV_ACCEPT_ALL
);
907 return rndis_set_oid(usbdev
, OID_802_11_PRIVACY_FILTER
, &tmp
,
912 static int set_encr_mode(struct usbnet
*usbdev
, int pairwise
, int groupwise
)
914 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
918 devdbg(usbdev
, "set_encr_mode: cipher_pair=0x%x cipher_group=0x%x",
922 if (pairwise
& IW_AUTH_CIPHER_CCMP
)
923 encr_mode
= NDIS_80211_ENCR_CCMP_ENABLED
;
924 else if (pairwise
& IW_AUTH_CIPHER_TKIP
)
925 encr_mode
= NDIS_80211_ENCR_TKIP_ENABLED
;
927 (IW_AUTH_CIPHER_WEP40
| IW_AUTH_CIPHER_WEP104
))
928 encr_mode
= NDIS_80211_ENCR_WEP_ENABLED
;
929 else if (groupwise
& IW_AUTH_CIPHER_CCMP
)
930 encr_mode
= NDIS_80211_ENCR_CCMP_ENABLED
;
931 else if (groupwise
& IW_AUTH_CIPHER_TKIP
)
932 encr_mode
= NDIS_80211_ENCR_TKIP_ENABLED
;
934 encr_mode
= NDIS_80211_ENCR_DISABLED
;
936 tmp
= cpu_to_le32(encr_mode
);
937 ret
= rndis_set_oid(usbdev
, OID_802_11_ENCRYPTION_STATUS
, &tmp
,
940 devwarn(usbdev
, "setting encr mode failed (%08X)", ret
);
944 priv
->wpa_cipher_pair
= pairwise
;
945 priv
->wpa_cipher_group
= groupwise
;
950 static int set_assoc_params(struct usbnet
*usbdev
)
952 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
954 set_auth_mode(usbdev
, priv
->wpa_version
, priv
->wpa_authalg
);
955 set_priv_filter(usbdev
);
956 set_encr_mode(usbdev
, priv
->wpa_cipher_pair
, priv
->wpa_cipher_group
);
962 static int set_infra_mode(struct usbnet
*usbdev
, int mode
)
964 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
968 devdbg(usbdev
, "set_infra_mode: infra_mode=0x%x", priv
->infra_mode
);
970 tmp
= cpu_to_le32(mode
);
971 ret
= rndis_set_oid(usbdev
, OID_802_11_INFRASTRUCTURE_MODE
, &tmp
,
974 devwarn(usbdev
, "setting infra mode failed (%08X)", ret
);
978 /* NDIS drivers clear keys when infrastructure mode is
979 * changed. But Linux tools assume otherwise. So set the
981 if (priv
->wpa_keymgmt
== 0 ||
982 priv
->wpa_keymgmt
== IW_AUTH_KEY_MGMT_802_1X
) {
983 for (i
= 0; i
< 4; i
++) {
984 if (priv
->encr_key_len
[i
] > 0 && !priv
->encr_key_wpa
[i
])
985 add_wep_key(usbdev
, priv
->encr_keys
[i
],
986 priv
->encr_key_len
[i
], i
);
990 priv
->infra_mode
= mode
;
995 static int set_rts_threshold(struct usbnet
*usbdev
, u32 rts_threshold
)
999 devdbg(usbdev
, "set_rts_threshold %i", rts_threshold
);
1001 if (rts_threshold
< 0 || rts_threshold
> 2347)
1002 rts_threshold
= 2347;
1004 tmp
= cpu_to_le32(rts_threshold
);
1005 return rndis_set_oid(usbdev
, OID_802_11_RTS_THRESHOLD
, &tmp
,
1010 static int set_frag_threshold(struct usbnet
*usbdev
, u32 frag_threshold
)
1014 devdbg(usbdev
, "set_frag_threshold %i", frag_threshold
);
1016 if (frag_threshold
< 256 || frag_threshold
> 2346)
1017 frag_threshold
= 2346;
1019 tmp
= cpu_to_le32(frag_threshold
);
1020 return rndis_set_oid(usbdev
, OID_802_11_FRAGMENTATION_THRESHOLD
, &tmp
,
1025 static void set_default_iw_params(struct usbnet
*usbdev
)
1027 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1029 priv
->wpa_keymgmt
= 0;
1030 priv
->wpa_version
= 0;
1032 set_infra_mode(usbdev
, NDIS_80211_INFRA_INFRA
);
1033 set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1034 IW_AUTH_ALG_OPEN_SYSTEM
);
1035 set_priv_filter(usbdev
);
1036 set_encr_mode(usbdev
, IW_AUTH_CIPHER_NONE
, IW_AUTH_CIPHER_NONE
);
1040 static int deauthenticate(struct usbnet
*usbdev
)
1044 ret
= disassociate(usbdev
, 1);
1045 set_default_iw_params(usbdev
);
1050 /* index must be 0 - N, as per NDIS */
1051 static int add_wep_key(struct usbnet
*usbdev
, char *key
, int key_len
, int index
)
1053 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1054 struct ndis_80211_wep_key ndis_key
;
1057 if (key_len
<= 0 || key_len
> 32 || index
< 0 || index
>= 4)
1060 memset(&ndis_key
, 0, sizeof(ndis_key
));
1062 ndis_key
.size
= cpu_to_le32(sizeof(ndis_key
));
1063 ndis_key
.length
= cpu_to_le32(key_len
);
1064 ndis_key
.index
= cpu_to_le32(index
);
1065 memcpy(&ndis_key
.material
, key
, key_len
);
1067 if (index
== priv
->encr_tx_key_index
) {
1068 ndis_key
.index
|= NDIS_80211_ADDWEP_TRANSMIT_KEY
;
1069 ret
= set_encr_mode(usbdev
, IW_AUTH_CIPHER_WEP104
,
1070 IW_AUTH_CIPHER_NONE
);
1072 devwarn(usbdev
, "encryption couldn't be enabled (%08X)",
1076 ret
= rndis_set_oid(usbdev
, OID_802_11_ADD_WEP
, &ndis_key
,
1079 devwarn(usbdev
, "adding encryption key %d failed (%08X)",
1084 priv
->encr_key_len
[index
] = key_len
;
1085 priv
->encr_key_wpa
[index
] = 0;
1086 memcpy(&priv
->encr_keys
[index
], key
, key_len
);
1092 static int add_wpa_key(struct usbnet
*usbdev
, const u8
*key
, int key_len
,
1093 int index
, const struct sockaddr
*addr
,
1094 const u8
*rx_seq
, int alg
, int flags
)
1096 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1097 struct ndis_80211_key ndis_key
;
1100 if (index
< 0 || index
>= 4)
1102 if (key_len
> sizeof(ndis_key
.material
) || key_len
< 0)
1104 if ((flags
& NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
) && !rx_seq
)
1106 if ((flags
& NDIS_80211_ADDKEY_PAIRWISE_KEY
) && !addr
)
1109 devdbg(usbdev
, "add_wpa_key(%i): flags:%i%i%i", index
,
1110 !!(flags
& NDIS_80211_ADDKEY_TRANSMIT_KEY
),
1111 !!(flags
& NDIS_80211_ADDKEY_PAIRWISE_KEY
),
1112 !!(flags
& NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
));
1114 memset(&ndis_key
, 0, sizeof(ndis_key
));
1116 ndis_key
.size
= cpu_to_le32(sizeof(ndis_key
) -
1117 sizeof(ndis_key
.material
) + key_len
);
1118 ndis_key
.length
= cpu_to_le32(key_len
);
1119 ndis_key
.index
= cpu_to_le32(index
) | flags
;
1121 if (alg
== IW_ENCODE_ALG_TKIP
&& key_len
== 32) {
1122 /* wpa_supplicant gives us the Michael MIC RX/TX keys in
1123 * different order than NDIS spec, so swap the order here. */
1124 memcpy(ndis_key
.material
, key
, 16);
1125 memcpy(ndis_key
.material
+ 16, key
+ 24, 8);
1126 memcpy(ndis_key
.material
+ 24, key
+ 16, 8);
1128 memcpy(ndis_key
.material
, key
, key_len
);
1130 if (flags
& NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
)
1131 memcpy(ndis_key
.rsc
, rx_seq
, 6);
1133 if (flags
& NDIS_80211_ADDKEY_PAIRWISE_KEY
) {
1135 memcpy(ndis_key
.bssid
, addr
->sa_data
, ETH_ALEN
);
1138 if (priv
->infra_mode
== NDIS_80211_INFRA_ADHOC
)
1139 memset(ndis_key
.bssid
, 0xff, ETH_ALEN
);
1141 get_bssid(usbdev
, ndis_key
.bssid
);
1144 ret
= rndis_set_oid(usbdev
, OID_802_11_ADD_KEY
, &ndis_key
,
1145 le32_to_cpu(ndis_key
.size
));
1146 devdbg(usbdev
, "add_wpa_key: OID_802_11_ADD_KEY -> %08X", ret
);
1150 priv
->encr_key_len
[index
] = key_len
;
1151 priv
->encr_key_wpa
[index
] = 1;
1153 if (flags
& NDIS_80211_ADDKEY_TRANSMIT_KEY
)
1154 priv
->encr_tx_key_index
= index
;
1160 /* remove_key is for both wep and wpa */
1161 static int remove_key(struct usbnet
*usbdev
, int index
, u8 bssid
[ETH_ALEN
])
1163 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1164 struct ndis_80211_remove_key remove_key
;
1168 if (priv
->encr_key_len
[index
] == 0)
1171 priv
->encr_key_len
[index
] = 0;
1172 priv
->encr_key_wpa
[index
] = 0;
1173 memset(&priv
->encr_keys
[index
], 0, sizeof(priv
->encr_keys
[index
]));
1175 if (priv
->wpa_cipher_pair
== IW_AUTH_CIPHER_TKIP
||
1176 priv
->wpa_cipher_pair
== IW_AUTH_CIPHER_CCMP
||
1177 priv
->wpa_cipher_group
== IW_AUTH_CIPHER_TKIP
||
1178 priv
->wpa_cipher_group
== IW_AUTH_CIPHER_CCMP
) {
1179 remove_key
.size
= cpu_to_le32(sizeof(remove_key
));
1180 remove_key
.index
= cpu_to_le32(index
);
1183 if (memcmp(bssid
, ffff_bssid
, ETH_ALEN
) != 0)
1185 NDIS_80211_ADDKEY_PAIRWISE_KEY
;
1186 memcpy(remove_key
.bssid
, bssid
,
1187 sizeof(remove_key
.bssid
));
1189 memset(remove_key
.bssid
, 0xff,
1190 sizeof(remove_key
.bssid
));
1192 ret
= rndis_set_oid(usbdev
, OID_802_11_REMOVE_KEY
, &remove_key
,
1193 sizeof(remove_key
));
1197 keyindex
= cpu_to_le32(index
);
1198 ret
= rndis_set_oid(usbdev
, OID_802_11_REMOVE_WEP
, &keyindex
,
1202 "removing encryption key %d failed (%08X)",
1208 /* if it is transmit key, disable encryption */
1209 if (index
== priv
->encr_tx_key_index
)
1210 set_encr_mode(usbdev
, IW_AUTH_CIPHER_NONE
, IW_AUTH_CIPHER_NONE
);
1216 static void set_multicast_list(struct usbnet
*usbdev
)
1218 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1219 struct dev_mc_list
*mclist
;
1224 filter
= RNDIS_PACKET_TYPE_DIRECTED
| RNDIS_PACKET_TYPE_BROADCAST
;
1226 if (usbdev
->net
->flags
& IFF_PROMISC
) {
1227 filter
|= RNDIS_PACKET_TYPE_PROMISCUOUS
|
1228 RNDIS_PACKET_TYPE_ALL_LOCAL
;
1229 } else if (usbdev
->net
->flags
& IFF_ALLMULTI
||
1230 usbdev
->net
->mc_count
> priv
->multicast_size
) {
1231 filter
|= RNDIS_PACKET_TYPE_ALL_MULTICAST
;
1232 } else if (usbdev
->net
->mc_count
> 0) {
1233 size
= min(priv
->multicast_size
, usbdev
->net
->mc_count
);
1234 buf
= kmalloc(size
* ETH_ALEN
, GFP_KERNEL
);
1237 "couldn't alloc %d bytes of memory",
1242 mclist
= usbdev
->net
->mc_list
;
1243 for (i
= 0; i
< size
&& mclist
; mclist
= mclist
->next
) {
1244 if (mclist
->dmi_addrlen
!= ETH_ALEN
)
1247 memcpy(buf
+ i
* ETH_ALEN
, mclist
->dmi_addr
, ETH_ALEN
);
1251 ret
= rndis_set_oid(usbdev
, OID_802_3_MULTICAST_LIST
, buf
,
1253 if (ret
== 0 && i
> 0)
1254 filter
|= RNDIS_PACKET_TYPE_MULTICAST
;
1256 filter
|= RNDIS_PACKET_TYPE_ALL_MULTICAST
;
1258 devdbg(usbdev
, "OID_802_3_MULTICAST_LIST(%d, max: %d) -> %d",
1259 i
, priv
->multicast_size
, ret
);
1264 ret
= rndis_set_oid(usbdev
, OID_GEN_CURRENT_PACKET_FILTER
, &filter
,
1267 devwarn(usbdev
, "couldn't set packet filter: %08x",
1268 le32_to_cpu(filter
));
1271 devdbg(usbdev
, "OID_GEN_CURRENT_PACKET_FILTER(%08x) -> %d",
1272 le32_to_cpu(filter
), ret
);
1279 static int rndis_change_virtual_intf(struct wiphy
*wiphy
,
1280 struct net_device
*dev
,
1281 enum nl80211_iftype type
, u32
*flags
,
1282 struct vif_params
*params
)
1284 struct usbnet
*usbdev
= netdev_priv(dev
);
1288 case NL80211_IFTYPE_ADHOC
:
1289 mode
= NDIS_80211_INFRA_ADHOC
;
1291 case NL80211_IFTYPE_STATION
:
1292 mode
= NDIS_80211_INFRA_INFRA
;
1298 return set_infra_mode(usbdev
, mode
);
1302 static int rndis_set_wiphy_params(struct wiphy
*wiphy
, u32 changed
)
1304 struct rndis_wlan_private
*priv
= wiphy_priv(wiphy
);
1305 struct usbnet
*usbdev
= priv
->usbdev
;
1308 if (changed
& WIPHY_PARAM_FRAG_THRESHOLD
) {
1309 err
= set_frag_threshold(usbdev
, wiphy
->frag_threshold
);
1314 if (changed
& WIPHY_PARAM_RTS_THRESHOLD
) {
1315 err
= set_rts_threshold(usbdev
, wiphy
->rts_threshold
);
1324 static int rndis_set_tx_power(struct wiphy
*wiphy
, enum tx_power_setting type
,
1327 struct rndis_wlan_private
*priv
= wiphy_priv(wiphy
);
1328 struct usbnet
*usbdev
= priv
->usbdev
;
1330 devdbg(usbdev
, "rndis_set_tx_power type:0x%x dbm:%i", type
, dbm
);
1332 /* Device doesn't support changing txpower after initialization, only
1333 * turn off/on radio. Support 'auto' mode and setting same dBm that is
1336 if (type
== TX_POWER_AUTOMATIC
|| dbm
== get_bcm4320_power_dbm(priv
)) {
1337 if (!priv
->radio_on
)
1338 disassociate(usbdev
, 1); /* turn on radio */
1347 static int rndis_get_tx_power(struct wiphy
*wiphy
, int *dbm
)
1349 struct rndis_wlan_private
*priv
= wiphy_priv(wiphy
);
1350 struct usbnet
*usbdev
= priv
->usbdev
;
1352 *dbm
= get_bcm4320_power_dbm(priv
);
1354 devdbg(usbdev
, "rndis_get_tx_power dbm:%i", *dbm
);
1360 #define SCAN_DELAY_JIFFIES (HZ)
1361 static int rndis_scan(struct wiphy
*wiphy
, struct net_device
*dev
,
1362 struct cfg80211_scan_request
*request
)
1364 struct usbnet
*usbdev
= netdev_priv(dev
);
1365 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1369 devdbg(usbdev
, "cfg80211.scan");
1374 if (priv
->scan_request
&& priv
->scan_request
!= request
)
1377 priv
->scan_request
= request
;
1379 tmp
= cpu_to_le32(1);
1380 ret
= rndis_set_oid(usbdev
, OID_802_11_BSSID_LIST_SCAN
, &tmp
,
1383 /* Wait before retrieving scan results from device */
1384 queue_delayed_work(priv
->workqueue
, &priv
->scan_work
,
1385 SCAN_DELAY_JIFFIES
);
1392 static struct cfg80211_bss
*rndis_bss_info_update(struct usbnet
*usbdev
,
1393 struct ndis_80211_bssid_ex
*bssid
)
1395 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1396 struct ieee80211_channel
*channel
;
1400 u16 beacon_interval
;
1401 struct ndis_80211_fixed_ies
*fixed
;
1402 int ie_len
, bssid_len
;
1405 /* parse bssid structure */
1406 bssid_len
= le32_to_cpu(bssid
->length
);
1408 if (bssid_len
< sizeof(struct ndis_80211_bssid_ex
) +
1409 sizeof(struct ndis_80211_fixed_ies
))
1412 fixed
= (struct ndis_80211_fixed_ies
*)bssid
->ies
;
1414 ie
= (void *)(bssid
->ies
+ sizeof(struct ndis_80211_fixed_ies
));
1415 ie_len
= min(bssid_len
- (int)sizeof(*bssid
),
1416 (int)le32_to_cpu(bssid
->ie_length
));
1417 ie_len
-= sizeof(struct ndis_80211_fixed_ies
);
1421 /* extract data for cfg80211_inform_bss */
1422 channel
= ieee80211_get_channel(priv
->wdev
.wiphy
,
1423 KHZ_TO_MHZ(le32_to_cpu(bssid
->config
.ds_config
)));
1427 signal
= level_to_qual(le32_to_cpu(bssid
->rssi
));
1428 timestamp
= le64_to_cpu(*(__le64
*)fixed
->timestamp
);
1429 capability
= le16_to_cpu(fixed
->capabilities
);
1430 beacon_interval
= le16_to_cpu(fixed
->beacon_interval
);
1432 return cfg80211_inform_bss(priv
->wdev
.wiphy
, channel
, bssid
->mac
,
1433 timestamp
, capability
, beacon_interval
, ie
, ie_len
, signal
,
1438 static int rndis_check_bssid_list(struct usbnet
*usbdev
)
1441 struct ndis_80211_bssid_list_ex
*bssid_list
;
1442 struct ndis_80211_bssid_ex
*bssid
;
1443 int ret
= -EINVAL
, len
, count
, bssid_len
;
1445 devdbg(usbdev
, "check_bssid_list");
1447 len
= CONTROL_BUFFER_SIZE
;
1448 buf
= kmalloc(len
, GFP_KERNEL
);
1454 ret
= rndis_query_oid(usbdev
, OID_802_11_BSSID_LIST
, buf
, &len
);
1459 bssid
= bssid_list
->bssid
;
1460 bssid_len
= le32_to_cpu(bssid
->length
);
1461 count
= le32_to_cpu(bssid_list
->num_items
);
1462 devdbg(usbdev
, "check_bssid_list: %d BSSIDs found", count
);
1464 while (count
&& ((void *)bssid
+ bssid_len
) <= (buf
+ len
)) {
1465 rndis_bss_info_update(usbdev
, bssid
);
1467 bssid
= (void *)bssid
+ bssid_len
;
1468 bssid_len
= le32_to_cpu(bssid
->length
);
1478 static void rndis_get_scan_results(struct work_struct
*work
)
1480 struct rndis_wlan_private
*priv
=
1481 container_of(work
, struct rndis_wlan_private
, scan_work
.work
);
1482 struct usbnet
*usbdev
= priv
->usbdev
;
1485 devdbg(usbdev
, "get_scan_results");
1487 ret
= rndis_check_bssid_list(usbdev
);
1489 cfg80211_scan_done(priv
->scan_request
, ret
< 0);
1491 priv
->scan_request
= NULL
;
1496 * wireless extension handlers
1499 static int rndis_iw_commit(struct net_device
*dev
,
1500 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1507 static int rndis_iw_set_essid(struct net_device
*dev
,
1508 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *essid
)
1510 struct ndis_80211_ssid ssid
;
1511 int length
= wrqu
->essid
.length
;
1512 struct usbnet
*usbdev
= netdev_priv(dev
);
1514 devdbg(usbdev
, "SIOCSIWESSID: [flags:%d,len:%d] '%.32s'",
1515 wrqu
->essid
.flags
, wrqu
->essid
.length
, essid
);
1517 if (length
> NDIS_802_11_LENGTH_SSID
)
1518 length
= NDIS_802_11_LENGTH_SSID
;
1520 ssid
.length
= cpu_to_le32(length
);
1522 memcpy(ssid
.essid
, essid
, length
);
1524 memset(ssid
.essid
, 0, NDIS_802_11_LENGTH_SSID
);
1526 set_assoc_params(usbdev
);
1528 if (!wrqu
->essid
.flags
|| length
== 0)
1529 return disassociate(usbdev
, 1);
1531 return set_essid(usbdev
, &ssid
);
1535 static int rndis_iw_get_essid(struct net_device
*dev
,
1536 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *essid
)
1538 struct ndis_80211_ssid ssid
;
1539 struct usbnet
*usbdev
= netdev_priv(dev
);
1542 ret
= get_essid(usbdev
, &ssid
);
1544 if (ret
== 0 && le32_to_cpu(ssid
.length
) > 0) {
1545 wrqu
->essid
.flags
= 1;
1546 wrqu
->essid
.length
= le32_to_cpu(ssid
.length
);
1547 memcpy(essid
, ssid
.essid
, wrqu
->essid
.length
);
1548 essid
[wrqu
->essid
.length
] = 0;
1550 memset(essid
, 0, sizeof(NDIS_802_11_LENGTH_SSID
));
1551 wrqu
->essid
.flags
= 0;
1552 wrqu
->essid
.length
= 0;
1554 devdbg(usbdev
, "SIOCGIWESSID: %s", essid
);
1559 static int rndis_iw_get_bssid(struct net_device
*dev
,
1560 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1562 struct usbnet
*usbdev
= netdev_priv(dev
);
1563 unsigned char bssid
[ETH_ALEN
];
1566 ret
= get_bssid(usbdev
, bssid
);
1569 devdbg(usbdev
, "SIOCGIWAP: %pM", bssid
);
1571 devdbg(usbdev
, "SIOCGIWAP: <not associated>");
1573 wrqu
->ap_addr
.sa_family
= ARPHRD_ETHER
;
1574 memcpy(wrqu
->ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1580 static int rndis_iw_set_bssid(struct net_device
*dev
,
1581 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1583 struct usbnet
*usbdev
= netdev_priv(dev
);
1584 u8
*bssid
= (u8
*)wrqu
->ap_addr
.sa_data
;
1587 devdbg(usbdev
, "SIOCSIWAP: %pM", bssid
);
1589 ret
= rndis_set_oid(usbdev
, OID_802_11_BSSID
, bssid
, ETH_ALEN
);
1591 /* user apps may set ap's mac address, which is not required;
1592 * they may fail to work if this function fails, so return
1595 devwarn(usbdev
, "setting AP mac address failed (%08X)", ret
);
1601 static int rndis_iw_set_auth(struct net_device
*dev
,
1602 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1604 struct iw_param
*p
= &wrqu
->param
;
1605 struct usbnet
*usbdev
= netdev_priv(dev
);
1606 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1607 int ret
= -ENOTSUPP
;
1609 switch (p
->flags
& IW_AUTH_INDEX
) {
1610 case IW_AUTH_WPA_VERSION
:
1611 devdbg(usbdev
, "SIOCSIWAUTH: WPA_VERSION, %08x", p
->value
);
1612 priv
->wpa_version
= p
->value
;
1616 case IW_AUTH_CIPHER_PAIRWISE
:
1617 devdbg(usbdev
, "SIOCSIWAUTH: CIPHER_PAIRWISE, %08x", p
->value
);
1618 priv
->wpa_cipher_pair
= p
->value
;
1622 case IW_AUTH_CIPHER_GROUP
:
1623 devdbg(usbdev
, "SIOCSIWAUTH: CIPHER_GROUP, %08x", p
->value
);
1624 priv
->wpa_cipher_group
= p
->value
;
1628 case IW_AUTH_KEY_MGMT
:
1629 devdbg(usbdev
, "SIOCSIWAUTH: KEY_MGMT, %08x", p
->value
);
1630 priv
->wpa_keymgmt
= p
->value
;
1634 case IW_AUTH_TKIP_COUNTERMEASURES
:
1635 devdbg(usbdev
, "SIOCSIWAUTH: TKIP_COUNTERMEASURES, %08x",
1640 case IW_AUTH_DROP_UNENCRYPTED
:
1641 devdbg(usbdev
, "SIOCSIWAUTH: DROP_UNENCRYPTED, %08x", p
->value
);
1645 case IW_AUTH_80211_AUTH_ALG
:
1646 devdbg(usbdev
, "SIOCSIWAUTH: 80211_AUTH_ALG, %08x", p
->value
);
1647 priv
->wpa_authalg
= p
->value
;
1651 case IW_AUTH_WPA_ENABLED
:
1652 devdbg(usbdev
, "SIOCSIWAUTH: WPA_ENABLED, %08x", p
->value
);
1653 if (wrqu
->param
.value
)
1654 deauthenticate(usbdev
);
1658 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1659 devdbg(usbdev
, "SIOCSIWAUTH: RX_UNENCRYPTED_EAPOL, %08x",
1664 case IW_AUTH_ROAMING_CONTROL
:
1665 devdbg(usbdev
, "SIOCSIWAUTH: ROAMING_CONTROL, %08x", p
->value
);
1669 case IW_AUTH_PRIVACY_INVOKED
:
1670 devdbg(usbdev
, "SIOCSIWAUTH: invalid cmd %d",
1671 wrqu
->param
.flags
& IW_AUTH_INDEX
);
1675 devdbg(usbdev
, "SIOCSIWAUTH: UNKNOWN %08x, %08x",
1676 p
->flags
& IW_AUTH_INDEX
, p
->value
);
1682 static int rndis_iw_get_auth(struct net_device
*dev
,
1683 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1685 struct iw_param
*p
= &wrqu
->param
;
1686 struct usbnet
*usbdev
= netdev_priv(dev
);
1687 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1689 switch (p
->flags
& IW_AUTH_INDEX
) {
1690 case IW_AUTH_WPA_VERSION
:
1691 p
->value
= priv
->wpa_version
;
1693 case IW_AUTH_CIPHER_PAIRWISE
:
1694 p
->value
= priv
->wpa_cipher_pair
;
1696 case IW_AUTH_CIPHER_GROUP
:
1697 p
->value
= priv
->wpa_cipher_group
;
1699 case IW_AUTH_KEY_MGMT
:
1700 p
->value
= priv
->wpa_keymgmt
;
1702 case IW_AUTH_80211_AUTH_ALG
:
1703 p
->value
= priv
->wpa_authalg
;
1706 devdbg(usbdev
, "SIOCGIWAUTH: invalid cmd %d",
1707 wrqu
->param
.flags
& IW_AUTH_INDEX
);
1714 static int rndis_iw_set_encode(struct net_device
*dev
,
1715 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1717 struct usbnet
*usbdev
= netdev_priv(dev
);
1718 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1719 int ret
, index
, key_len
;
1722 index
= (wrqu
->encoding
.flags
& IW_ENCODE_INDEX
);
1724 /* iwconfig gives index as 1 - N */
1728 index
= priv
->encr_tx_key_index
;
1730 if (index
< 0 || index
>= 4) {
1731 devwarn(usbdev
, "encryption index out of range (%u)", index
);
1735 /* remove key if disabled */
1736 if (wrqu
->data
.flags
& IW_ENCODE_DISABLED
) {
1737 if (remove_key(usbdev
, index
, NULL
))
1743 /* global encryption state (for all keys) */
1744 if (wrqu
->data
.flags
& IW_ENCODE_OPEN
)
1745 ret
= set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1746 IW_AUTH_ALG_OPEN_SYSTEM
);
1747 else /*if (wrqu->data.flags & IW_ENCODE_RESTRICTED)*/
1748 ret
= set_auth_mode(usbdev
, IW_AUTH_WPA_VERSION_DISABLED
,
1749 IW_AUTH_ALG_SHARED_KEY
);
1753 if (wrqu
->data
.length
> 0) {
1754 key_len
= wrqu
->data
.length
;
1757 /* must be set as tx key */
1758 if (priv
->encr_key_len
[index
] == 0)
1760 key_len
= priv
->encr_key_len
[index
];
1761 key
= priv
->encr_keys
[index
];
1762 priv
->encr_tx_key_index
= index
;
1765 if (add_wep_key(usbdev
, key
, key_len
, index
) != 0)
1768 if (index
== priv
->encr_tx_key_index
)
1769 /* ndis drivers want essid to be set after setting encr */
1770 set_essid(usbdev
, &priv
->essid
);
1776 static int rndis_iw_set_encode_ext(struct net_device
*dev
,
1777 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1779 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1780 struct usbnet
*usbdev
= netdev_priv(dev
);
1781 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1784 keyidx
= wrqu
->encoding
.flags
& IW_ENCODE_INDEX
;
1786 /* iwconfig gives index as 1 - N */
1790 keyidx
= priv
->encr_tx_key_index
;
1792 if (keyidx
< 0 || keyidx
>= 4)
1795 if (ext
->alg
== WPA_ALG_WEP
) {
1796 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1797 priv
->encr_tx_key_index
= keyidx
;
1798 return add_wep_key(usbdev
, ext
->key
, ext
->key_len
, keyidx
);
1801 if ((wrqu
->encoding
.flags
& IW_ENCODE_DISABLED
) ||
1802 ext
->alg
== IW_ENCODE_ALG_NONE
|| ext
->key_len
== 0)
1803 return remove_key(usbdev
, keyidx
, NULL
);
1806 if (ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
)
1807 flags
|= NDIS_80211_ADDKEY_SET_INIT_RECV_SEQ
;
1808 if (!(ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
))
1809 flags
|= NDIS_80211_ADDKEY_PAIRWISE_KEY
;
1810 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
)
1811 flags
|= NDIS_80211_ADDKEY_TRANSMIT_KEY
;
1813 return add_wpa_key(usbdev
, ext
->key
, ext
->key_len
, keyidx
, &ext
->addr
,
1814 ext
->rx_seq
, ext
->alg
, flags
);
1818 static int rndis_iw_set_genie(struct net_device
*dev
,
1819 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1821 struct usbnet
*usbdev
= netdev_priv(dev
);
1822 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1828 for (j
= 0; j
< wrqu
->data
.length
; j
+= 8)
1830 "SIOCSIWGENIE %04x - "
1831 "%02x %02x %02x %02x %02x %02x %02x %02x", j
,
1832 gie
[j
+ 0], gie
[j
+ 1], gie
[j
+ 2], gie
[j
+ 3],
1833 gie
[j
+ 4], gie
[j
+ 5], gie
[j
+ 6], gie
[j
+ 7]);
1835 /* clear existing IEs */
1836 if (priv
->wpa_ie_len
) {
1837 kfree(priv
->wpa_ie
);
1838 priv
->wpa_ie_len
= 0;
1842 priv
->wpa_ie
= kmalloc(wrqu
->data
.length
, GFP_KERNEL
);
1844 priv
->wpa_ie_len
= wrqu
->data
.length
;
1845 memcpy(priv
->wpa_ie
, extra
, priv
->wpa_ie_len
);
1852 static int rndis_iw_get_genie(struct net_device
*dev
,
1853 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1855 struct usbnet
*usbdev
= netdev_priv(dev
);
1856 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1858 devdbg(usbdev
, "SIOCGIWGENIE");
1860 if (priv
->wpa_ie_len
== 0 || priv
->wpa_ie
== NULL
) {
1861 wrqu
->data
.length
= 0;
1865 if (wrqu
->data
.length
< priv
->wpa_ie_len
)
1868 wrqu
->data
.length
= priv
->wpa_ie_len
;
1869 memcpy(extra
, priv
->wpa_ie
, priv
->wpa_ie_len
);
1875 static int rndis_iw_set_freq(struct net_device
*dev
,
1876 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1878 struct usbnet
*usbdev
= netdev_priv(dev
);
1879 struct ndis_80211_conf config
;
1880 unsigned int dsconfig
;
1883 /* this OID is valid only when not associated */
1884 if (is_associated(usbdev
))
1888 if (freq_to_dsconfig(&wrqu
->freq
, &dsconfig
))
1891 len
= sizeof(config
);
1892 ret
= rndis_query_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
, &len
);
1894 devdbg(usbdev
, "SIOCSIWFREQ: querying configuration failed");
1898 config
.ds_config
= cpu_to_le32(dsconfig
);
1900 devdbg(usbdev
, "SIOCSIWFREQ: %d * 10^%d", wrqu
->freq
.m
, wrqu
->freq
.e
);
1901 return rndis_set_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
,
1906 static int rndis_iw_get_freq(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 ndis_80211_conf config
;
1913 len
= sizeof(config
);
1914 ret
= rndis_query_oid(usbdev
, OID_802_11_CONFIGURATION
, &config
, &len
);
1916 dsconfig_to_freq(le32_to_cpu(config
.ds_config
), &wrqu
->freq
);
1918 devdbg(usbdev
, "SIOCGIWFREQ: %d", wrqu
->freq
.m
);
1923 static int rndis_iw_get_rate(struct net_device
*dev
,
1924 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1926 struct usbnet
*usbdev
= netdev_priv(dev
);
1931 ret
= rndis_query_oid(usbdev
, OID_GEN_LINK_SPEED
, &tmp
, &len
);
1933 wrqu
->bitrate
.value
= le32_to_cpu(tmp
) * 100;
1934 wrqu
->bitrate
.disabled
= 0;
1935 wrqu
->bitrate
.flags
= 1;
1941 static int rndis_iw_set_mlme(struct net_device
*dev
,
1942 struct iw_request_info
*info
, union iwreq_data
*wrqu
, char *extra
)
1944 struct usbnet
*usbdev
= netdev_priv(dev
);
1945 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1946 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
1947 unsigned char bssid
[ETH_ALEN
];
1949 get_bssid(usbdev
, bssid
);
1951 if (memcmp(bssid
, mlme
->addr
.sa_data
, ETH_ALEN
))
1954 switch (mlme
->cmd
) {
1955 case IW_MLME_DEAUTH
:
1956 return deauthenticate(usbdev
);
1957 case IW_MLME_DISASSOC
:
1958 return disassociate(usbdev
, priv
->radio_on
);
1967 static struct iw_statistics
*rndis_get_wireless_stats(struct net_device
*dev
)
1969 struct usbnet
*usbdev
= netdev_priv(dev
);
1970 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
1971 unsigned long flags
;
1973 spin_lock_irqsave(&priv
->stats_lock
, flags
);
1974 memcpy(&priv
->iwstats
, &priv
->privstats
, sizeof(priv
->iwstats
));
1975 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
1977 return &priv
->iwstats
;
1981 #define IW_IOCTL(x) [(x) - SIOCSIWCOMMIT]
1982 static const iw_handler rndis_iw_handler
[] =
1984 IW_IOCTL(SIOCSIWCOMMIT
) = rndis_iw_commit
,
1985 IW_IOCTL(SIOCGIWNAME
) = (iw_handler
) cfg80211_wext_giwname
,
1986 IW_IOCTL(SIOCSIWFREQ
) = rndis_iw_set_freq
,
1987 IW_IOCTL(SIOCGIWFREQ
) = rndis_iw_get_freq
,
1988 IW_IOCTL(SIOCSIWMODE
) = (iw_handler
) cfg80211_wext_siwmode
,
1989 IW_IOCTL(SIOCGIWMODE
) = (iw_handler
) cfg80211_wext_giwmode
,
1990 IW_IOCTL(SIOCGIWRANGE
) = (iw_handler
) cfg80211_wext_giwrange
,
1991 IW_IOCTL(SIOCSIWAP
) = rndis_iw_set_bssid
,
1992 IW_IOCTL(SIOCGIWAP
) = rndis_iw_get_bssid
,
1993 IW_IOCTL(SIOCSIWSCAN
) = (iw_handler
) cfg80211_wext_siwscan
,
1994 IW_IOCTL(SIOCGIWSCAN
) = (iw_handler
) cfg80211_wext_giwscan
,
1995 IW_IOCTL(SIOCSIWESSID
) = rndis_iw_set_essid
,
1996 IW_IOCTL(SIOCGIWESSID
) = rndis_iw_get_essid
,
1997 IW_IOCTL(SIOCGIWRATE
) = rndis_iw_get_rate
,
1998 IW_IOCTL(SIOCSIWRTS
) = (iw_handler
) cfg80211_wext_siwrts
,
1999 IW_IOCTL(SIOCGIWRTS
) = (iw_handler
) cfg80211_wext_giwrts
,
2000 IW_IOCTL(SIOCSIWFRAG
) = (iw_handler
) cfg80211_wext_siwfrag
,
2001 IW_IOCTL(SIOCGIWFRAG
) = (iw_handler
) cfg80211_wext_giwfrag
,
2002 IW_IOCTL(SIOCSIWTXPOW
) = (iw_handler
) cfg80211_wext_siwtxpower
,
2003 IW_IOCTL(SIOCGIWTXPOW
) = (iw_handler
) cfg80211_wext_giwtxpower
,
2004 IW_IOCTL(SIOCSIWENCODE
) = rndis_iw_set_encode
,
2005 IW_IOCTL(SIOCSIWENCODEEXT
) = rndis_iw_set_encode_ext
,
2006 IW_IOCTL(SIOCSIWAUTH
) = rndis_iw_set_auth
,
2007 IW_IOCTL(SIOCGIWAUTH
) = rndis_iw_get_auth
,
2008 IW_IOCTL(SIOCSIWGENIE
) = rndis_iw_set_genie
,
2009 IW_IOCTL(SIOCGIWGENIE
) = rndis_iw_get_genie
,
2010 IW_IOCTL(SIOCSIWMLME
) = rndis_iw_set_mlme
,
2013 static const iw_handler rndis_wlan_private_handler
[] = {
2016 static const struct iw_priv_args rndis_wlan_private_args
[] = {
2020 static const struct iw_handler_def rndis_iw_handlers
= {
2021 .num_standard
= ARRAY_SIZE(rndis_iw_handler
),
2022 .num_private
= ARRAY_SIZE(rndis_wlan_private_handler
),
2023 .num_private_args
= ARRAY_SIZE(rndis_wlan_private_args
),
2024 .standard
= (iw_handler
*)rndis_iw_handler
,
2025 .private = (iw_handler
*)rndis_wlan_private_handler
,
2026 .private_args
= (struct iw_priv_args
*)rndis_wlan_private_args
,
2027 .get_wireless_stats
= rndis_get_wireless_stats
,
2031 static void rndis_wlan_worker(struct work_struct
*work
)
2033 struct rndis_wlan_private
*priv
=
2034 container_of(work
, struct rndis_wlan_private
, work
);
2035 struct usbnet
*usbdev
= priv
->usbdev
;
2036 union iwreq_data evt
;
2037 unsigned char bssid
[ETH_ALEN
];
2038 struct ndis_80211_assoc_info
*info
;
2039 int assoc_size
= sizeof(*info
) + IW_CUSTOM_MAX
+ 32;
2042 if (test_and_clear_bit(WORK_LINK_UP
, &priv
->work_pending
)) {
2043 netif_carrier_on(usbdev
->net
);
2045 info
= kzalloc(assoc_size
, GFP_KERNEL
);
2049 /* Get association info IEs from device and send them back to
2051 ret
= get_association_info(usbdev
, info
, assoc_size
);
2053 evt
.data
.length
= le32_to_cpu(info
->req_ie_length
);
2054 if (evt
.data
.length
> 0) {
2055 offset
= le32_to_cpu(info
->offset_req_ies
);
2056 wireless_send_event(usbdev
->net
,
2057 IWEVASSOCREQIE
, &evt
,
2058 (char *)info
+ offset
);
2061 evt
.data
.length
= le32_to_cpu(info
->resp_ie_length
);
2062 if (evt
.data
.length
> 0) {
2063 offset
= le32_to_cpu(info
->offset_resp_ies
);
2064 wireless_send_event(usbdev
->net
,
2065 IWEVASSOCRESPIE
, &evt
,
2066 (char *)info
+ offset
);
2073 ret
= get_bssid(usbdev
, bssid
);
2076 evt
.data
.length
= 0;
2077 memcpy(evt
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
2078 wireless_send_event(usbdev
->net
, SIOCGIWAP
, &evt
, NULL
);
2082 if (test_and_clear_bit(WORK_LINK_DOWN
, &priv
->work_pending
)) {
2083 netif_carrier_off(usbdev
->net
);
2086 evt
.data
.length
= 0;
2087 memset(evt
.ap_addr
.sa_data
, 0, ETH_ALEN
);
2088 wireless_send_event(usbdev
->net
, SIOCGIWAP
, &evt
, NULL
);
2091 if (test_and_clear_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
))
2092 set_multicast_list(usbdev
);
2095 static void rndis_wlan_set_multicast_list(struct net_device
*dev
)
2097 struct usbnet
*usbdev
= netdev_priv(dev
);
2098 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2100 if (test_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
))
2103 set_bit(WORK_SET_MULTICAST_LIST
, &priv
->work_pending
);
2104 queue_work(priv
->workqueue
, &priv
->work
);
2107 static void rndis_wlan_link_change(struct usbnet
*usbdev
, int state
)
2109 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2111 /* queue work to avoid recursive calls into rndis_command */
2112 set_bit(state
? WORK_LINK_UP
: WORK_LINK_DOWN
, &priv
->work_pending
);
2113 queue_work(priv
->workqueue
, &priv
->work
);
2117 static int rndis_wlan_get_caps(struct usbnet
*usbdev
)
2122 } networks_supported
;
2123 int len
, retval
, i
, n
;
2124 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2126 /* determine supported modes */
2127 len
= sizeof(networks_supported
);
2128 retval
= rndis_query_oid(usbdev
, OID_802_11_NETWORK_TYPES_SUPPORTED
,
2129 &networks_supported
, &len
);
2131 n
= le32_to_cpu(networks_supported
.num_items
);
2134 for (i
= 0; i
< n
; i
++) {
2135 switch (le32_to_cpu(networks_supported
.items
[i
])) {
2136 case NDIS_80211_TYPE_FREQ_HOP
:
2137 case NDIS_80211_TYPE_DIRECT_SEQ
:
2138 priv
->caps
|= CAP_MODE_80211B
;
2140 case NDIS_80211_TYPE_OFDM_A
:
2141 priv
->caps
|= CAP_MODE_80211A
;
2143 case NDIS_80211_TYPE_OFDM_G
:
2144 priv
->caps
|= CAP_MODE_80211G
;
2154 #define STATS_UPDATE_JIFFIES (HZ)
2155 static void rndis_update_wireless_stats(struct work_struct
*work
)
2157 struct rndis_wlan_private
*priv
=
2158 container_of(work
, struct rndis_wlan_private
, stats_work
.work
);
2159 struct usbnet
*usbdev
= priv
->usbdev
;
2160 struct iw_statistics iwstats
;
2163 unsigned long flags
;
2164 int update_jiffies
= STATS_UPDATE_JIFFIES
;
2167 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2168 memcpy(&iwstats
, &priv
->privstats
, sizeof(iwstats
));
2169 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2171 /* only update stats when connected */
2172 if (!is_associated(usbdev
)) {
2173 iwstats
.qual
.qual
= 0;
2174 iwstats
.qual
.level
= 0;
2175 iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2176 | IW_QUAL_LEVEL_UPDATED
2177 | IW_QUAL_NOISE_INVALID
2178 | IW_QUAL_QUAL_INVALID
2179 | IW_QUAL_LEVEL_INVALID
;
2184 ret
= rndis_query_oid(usbdev
, OID_802_11_RSSI
, &rssi
, &len
);
2186 devdbg(usbdev
, "stats: OID_802_11_RSSI -> %d, rssi:%d", ret
,
2189 memset(&iwstats
.qual
, 0, sizeof(iwstats
.qual
));
2190 iwstats
.qual
.qual
= level_to_qual(le32_to_cpu(rssi
));
2191 iwstats
.qual
.level
= level_to_qual(le32_to_cpu(rssi
));
2192 iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2193 | IW_QUAL_LEVEL_UPDATED
2194 | IW_QUAL_NOISE_INVALID
;
2197 memset(&iwstats
.discard
, 0, sizeof(iwstats
.discard
));
2200 ret
= rndis_query_oid(usbdev
, OID_GEN_XMIT_ERROR
, &tmp
, &len
);
2202 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2205 ret
= rndis_query_oid(usbdev
, OID_GEN_RCV_ERROR
, &tmp
, &len
);
2207 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2210 ret
= rndis_query_oid(usbdev
, OID_GEN_RCV_NO_BUFFER
, &tmp
, &len
);
2212 iwstats
.discard
.misc
+= le32_to_cpu(tmp
);
2214 /* Workaround transfer stalls on poor quality links.
2215 * TODO: find right way to fix these stalls (as stalls do not happen
2216 * with ndiswrapper/windows driver). */
2217 if (iwstats
.qual
.qual
<= 25) {
2218 /* Decrease stats worker interval to catch stalls.
2219 * faster. Faster than 400-500ms causes packet loss,
2220 * Slower doesn't catch stalls fast enough.
2222 j
= msecs_to_jiffies(priv
->param_workaround_interval
);
2223 if (j
> STATS_UPDATE_JIFFIES
)
2224 j
= STATS_UPDATE_JIFFIES
;
2229 /* Send scan OID. Use of both OIDs is required to get device
2232 tmp
= cpu_to_le32(1);
2233 rndis_set_oid(usbdev
, OID_802_11_BSSID_LIST_SCAN
, &tmp
,
2236 len
= CONTROL_BUFFER_SIZE
;
2237 buf
= kmalloc(len
, GFP_KERNEL
);
2241 rndis_query_oid(usbdev
, OID_802_11_BSSID_LIST
, buf
, &len
);
2245 spin_lock_irqsave(&priv
->stats_lock
, flags
);
2246 memcpy(&priv
->privstats
, &iwstats
, sizeof(iwstats
));
2247 spin_unlock_irqrestore(&priv
->stats_lock
, flags
);
2249 if (update_jiffies
>= HZ
)
2250 update_jiffies
= round_jiffies_relative(update_jiffies
);
2252 j
= round_jiffies_relative(update_jiffies
);
2253 if (abs(j
- update_jiffies
) <= 10)
2257 queue_delayed_work(priv
->workqueue
, &priv
->stats_work
, update_jiffies
);
2261 static int bcm4320a_early_init(struct usbnet
*usbdev
)
2263 /* bcm4320a doesn't handle configuration parameters well. Try
2264 * set any and you get partially zeroed mac and broken device.
2271 static int bcm4320b_early_init(struct usbnet
*usbdev
)
2273 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2276 /* Early initialization settings, setting these won't have effect
2277 * if called after generic_rndis_bind().
2280 priv
->param_country
[0] = modparam_country
[0];
2281 priv
->param_country
[1] = modparam_country
[1];
2282 priv
->param_country
[2] = 0;
2283 priv
->param_frameburst
= modparam_frameburst
;
2284 priv
->param_afterburner
= modparam_afterburner
;
2285 priv
->param_power_save
= modparam_power_save
;
2286 priv
->param_power_output
= modparam_power_output
;
2287 priv
->param_roamtrigger
= modparam_roamtrigger
;
2288 priv
->param_roamdelta
= modparam_roamdelta
;
2290 priv
->param_country
[0] = toupper(priv
->param_country
[0]);
2291 priv
->param_country
[1] = toupper(priv
->param_country
[1]);
2292 /* doesn't support EU as country code, use FI instead */
2293 if (!strcmp(priv
->param_country
, "EU"))
2294 strcpy(priv
->param_country
, "FI");
2296 if (priv
->param_power_save
< 0)
2297 priv
->param_power_save
= 0;
2298 else if (priv
->param_power_save
> 2)
2299 priv
->param_power_save
= 2;
2301 if (priv
->param_power_output
< 0)
2302 priv
->param_power_output
= 0;
2303 else if (priv
->param_power_output
> 3)
2304 priv
->param_power_output
= 3;
2306 if (priv
->param_roamtrigger
< -80)
2307 priv
->param_roamtrigger
= -80;
2308 else if (priv
->param_roamtrigger
> -60)
2309 priv
->param_roamtrigger
= -60;
2311 if (priv
->param_roamdelta
< 0)
2312 priv
->param_roamdelta
= 0;
2313 else if (priv
->param_roamdelta
> 2)
2314 priv
->param_roamdelta
= 2;
2316 if (modparam_workaround_interval
< 0)
2317 priv
->param_workaround_interval
= 500;
2319 priv
->param_workaround_interval
= modparam_workaround_interval
;
2321 rndis_set_config_parameter_str(usbdev
, "Country", priv
->param_country
);
2322 rndis_set_config_parameter_str(usbdev
, "FrameBursting",
2323 priv
->param_frameburst
? "1" : "0");
2324 rndis_set_config_parameter_str(usbdev
, "Afterburner",
2325 priv
->param_afterburner
? "1" : "0");
2326 sprintf(buf
, "%d", priv
->param_power_save
);
2327 rndis_set_config_parameter_str(usbdev
, "PowerSaveMode", buf
);
2328 sprintf(buf
, "%d", priv
->param_power_output
);
2329 rndis_set_config_parameter_str(usbdev
, "PwrOut", buf
);
2330 sprintf(buf
, "%d", priv
->param_roamtrigger
);
2331 rndis_set_config_parameter_str(usbdev
, "RoamTrigger", buf
);
2332 sprintf(buf
, "%d", priv
->param_roamdelta
);
2333 rndis_set_config_parameter_str(usbdev
, "RoamDelta", buf
);
2338 /* same as rndis_netdev_ops but with local multicast handler */
2339 static const struct net_device_ops rndis_wlan_netdev_ops
= {
2340 .ndo_open
= usbnet_open
,
2341 .ndo_stop
= usbnet_stop
,
2342 .ndo_start_xmit
= usbnet_start_xmit
,
2343 .ndo_tx_timeout
= usbnet_tx_timeout
,
2344 .ndo_set_mac_address
= eth_mac_addr
,
2345 .ndo_validate_addr
= eth_validate_addr
,
2346 .ndo_set_multicast_list
= rndis_wlan_set_multicast_list
,
2350 static int rndis_wlan_bind(struct usbnet
*usbdev
, struct usb_interface
*intf
)
2352 struct wiphy
*wiphy
;
2353 struct rndis_wlan_private
*priv
;
2357 /* allocate wiphy and rndis private data
2358 * NOTE: We only support a single virtual interface, so wiphy
2359 * and wireless_dev are somewhat synonymous for this device.
2361 wiphy
= wiphy_new(&rndis_config_ops
, sizeof(struct rndis_wlan_private
));
2365 priv
= wiphy_priv(wiphy
);
2366 usbdev
->net
->ieee80211_ptr
= &priv
->wdev
;
2367 priv
->wdev
.wiphy
= wiphy
;
2368 priv
->wdev
.iftype
= NL80211_IFTYPE_STATION
;
2370 /* These have to be initialized before calling generic_rndis_bind().
2371 * Otherwise we'll be in big trouble in rndis_wlan_early_init().
2373 usbdev
->driver_priv
= priv
;
2374 usbdev
->net
->wireless_handlers
= &rndis_iw_handlers
;
2375 priv
->usbdev
= usbdev
;
2377 mutex_init(&priv
->command_lock
);
2378 spin_lock_init(&priv
->stats_lock
);
2380 /* because rndis_command() sleeps we need to use workqueue */
2381 priv
->workqueue
= create_singlethread_workqueue("rndis_wlan");
2382 INIT_WORK(&priv
->work
, rndis_wlan_worker
);
2383 INIT_DELAYED_WORK(&priv
->stats_work
, rndis_update_wireless_stats
);
2384 INIT_DELAYED_WORK(&priv
->scan_work
, rndis_get_scan_results
);
2386 /* try bind rndis_host */
2387 retval
= generic_rndis_bind(usbdev
, intf
, FLAG_RNDIS_PHYM_WIRELESS
);
2391 /* generic_rndis_bind set packet filter to multicast_all+
2392 * promisc mode which doesn't work well for our devices (device
2393 * picks up rssi to closest station instead of to access point).
2395 * rndis_host wants to avoid all OID as much as possible
2396 * so do promisc/multicast handling in rndis_wlan.
2398 usbdev
->net
->netdev_ops
= &rndis_wlan_netdev_ops
;
2400 tmp
= RNDIS_PACKET_TYPE_DIRECTED
| RNDIS_PACKET_TYPE_BROADCAST
;
2401 retval
= rndis_set_oid(usbdev
, OID_GEN_CURRENT_PACKET_FILTER
, &tmp
,
2405 retval
= rndis_query_oid(usbdev
, OID_802_3_MAXIMUM_LIST_SIZE
, &tmp
,
2407 priv
->multicast_size
= le32_to_cpu(tmp
);
2408 if (retval
< 0 || priv
->multicast_size
< 0)
2409 priv
->multicast_size
= 0;
2410 if (priv
->multicast_size
> 0)
2411 usbdev
->net
->flags
|= IFF_MULTICAST
;
2413 usbdev
->net
->flags
&= ~IFF_MULTICAST
;
2415 priv
->iwstats
.qual
.qual
= 0;
2416 priv
->iwstats
.qual
.level
= 0;
2417 priv
->iwstats
.qual
.updated
= IW_QUAL_QUAL_UPDATED
2418 | IW_QUAL_LEVEL_UPDATED
2419 | IW_QUAL_NOISE_INVALID
2420 | IW_QUAL_QUAL_INVALID
2421 | IW_QUAL_LEVEL_INVALID
;
2423 /* fill-out wiphy structure and register w/ cfg80211 */
2424 memcpy(wiphy
->perm_addr
, usbdev
->net
->dev_addr
, ETH_ALEN
);
2425 wiphy
->privid
= rndis_wiphy_privid
;
2426 wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
)
2427 | BIT(NL80211_IFTYPE_ADHOC
);
2428 wiphy
->max_scan_ssids
= 1;
2430 /* TODO: fill-out band information based on priv->caps */
2431 rndis_wlan_get_caps(usbdev
);
2433 memcpy(priv
->channels
, rndis_channels
, sizeof(rndis_channels
));
2434 memcpy(priv
->rates
, rndis_rates
, sizeof(rndis_rates
));
2435 priv
->band
.channels
= priv
->channels
;
2436 priv
->band
.n_channels
= ARRAY_SIZE(rndis_channels
);
2437 priv
->band
.bitrates
= priv
->rates
;
2438 priv
->band
.n_bitrates
= ARRAY_SIZE(rndis_rates
);
2439 wiphy
->bands
[IEEE80211_BAND_2GHZ
] = &priv
->band
;
2440 wiphy
->signal_type
= CFG80211_SIGNAL_TYPE_UNSPEC
;
2442 set_wiphy_dev(wiphy
, &usbdev
->udev
->dev
);
2444 if (wiphy_register(wiphy
)) {
2449 set_default_iw_params(usbdev
);
2451 /* set default rts/frag */
2452 rndis_set_wiphy_params(wiphy
,
2453 WIPHY_PARAM_FRAG_THRESHOLD
| WIPHY_PARAM_RTS_THRESHOLD
);
2457 disassociate(usbdev
, 1);
2458 netif_carrier_off(usbdev
->net
);
2460 queue_delayed_work(priv
->workqueue
, &priv
->stats_work
,
2461 round_jiffies_relative(STATS_UPDATE_JIFFIES
));
2466 cancel_delayed_work_sync(&priv
->stats_work
);
2467 cancel_delayed_work_sync(&priv
->scan_work
);
2468 cancel_work_sync(&priv
->work
);
2469 flush_workqueue(priv
->workqueue
);
2470 destroy_workqueue(priv
->workqueue
);
2477 static void rndis_wlan_unbind(struct usbnet
*usbdev
, struct usb_interface
*intf
)
2479 struct rndis_wlan_private
*priv
= get_rndis_wlan_priv(usbdev
);
2481 /* turn radio off */
2482 disassociate(usbdev
, 0);
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
);
2490 if (priv
&& priv
->wpa_ie_len
)
2491 kfree(priv
->wpa_ie
);
2493 rndis_unbind(usbdev
, intf
);
2495 wiphy_unregister(priv
->wdev
.wiphy
);
2496 wiphy_free(priv
->wdev
.wiphy
);
2500 static int rndis_wlan_reset(struct usbnet
*usbdev
)
2502 devdbg(usbdev
, "rndis_wlan_reset");
2503 return deauthenticate(usbdev
);
2507 static int rndis_wlan_stop(struct usbnet
*usbdev
)
2509 devdbg(usbdev
, "rndis_wlan_stop");
2510 return disassociate(usbdev
, 0);
2514 static const struct driver_info bcm4320b_info
= {
2515 .description
= "Wireless RNDIS device, BCM4320b based",
2516 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2517 .bind
= rndis_wlan_bind
,
2518 .unbind
= rndis_wlan_unbind
,
2519 .status
= rndis_status
,
2520 .rx_fixup
= rndis_rx_fixup
,
2521 .tx_fixup
= rndis_tx_fixup
,
2522 .reset
= rndis_wlan_reset
,
2523 .stop
= rndis_wlan_stop
,
2524 .early_init
= bcm4320b_early_init
,
2525 .link_change
= rndis_wlan_link_change
,
2528 static const struct driver_info bcm4320a_info
= {
2529 .description
= "Wireless RNDIS device, BCM4320a based",
2530 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2531 .bind
= rndis_wlan_bind
,
2532 .unbind
= rndis_wlan_unbind
,
2533 .status
= rndis_status
,
2534 .rx_fixup
= rndis_rx_fixup
,
2535 .tx_fixup
= rndis_tx_fixup
,
2536 .reset
= rndis_wlan_reset
,
2537 .stop
= rndis_wlan_stop
,
2538 .early_init
= bcm4320a_early_init
,
2539 .link_change
= rndis_wlan_link_change
,
2542 static const struct driver_info rndis_wlan_info
= {
2543 .description
= "Wireless RNDIS device",
2544 .flags
= FLAG_WLAN
| FLAG_FRAMING_RN
| FLAG_NO_SETINT
,
2545 .bind
= rndis_wlan_bind
,
2546 .unbind
= rndis_wlan_unbind
,
2547 .status
= rndis_status
,
2548 .rx_fixup
= rndis_rx_fixup
,
2549 .tx_fixup
= rndis_tx_fixup
,
2550 .reset
= rndis_wlan_reset
,
2551 .stop
= rndis_wlan_stop
,
2552 .early_init
= bcm4320a_early_init
,
2553 .link_change
= rndis_wlan_link_change
,
2556 /*-------------------------------------------------------------------------*/
2558 static const struct usb_device_id products
[] = {
2559 #define RNDIS_MASTER_INTERFACE \
2560 .bInterfaceClass = USB_CLASS_COMM, \
2561 .bInterfaceSubClass = 2 /* ACM */, \
2562 .bInterfaceProtocol = 0x0ff
2564 /* INF driver for these devices have DriverVer >= 4.xx.xx.xx and many custom
2565 * parameters available. Chipset marked as 'BCM4320SKFBG' in NDISwrapper-wiki.
2568 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2569 | USB_DEVICE_ID_MATCH_DEVICE
,
2571 .idProduct
= 0x00bc, /* Buffalo WLI-U2-KG125S */
2572 RNDIS_MASTER_INTERFACE
,
2573 .driver_info
= (unsigned long) &bcm4320b_info
,
2575 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2576 | USB_DEVICE_ID_MATCH_DEVICE
,
2578 .idProduct
= 0x011b, /* U.S. Robotics USR5421 */
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, /* Belkin F5D7051 */
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
,
2591 .idVendor
= 0x1799, /* Belkin has two vendor ids */
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
,
2599 .idProduct
= 0x0014, /* Linksys WUSB54GSv2 */
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
= 0x0026, /* Linksys WUSB54GSC */
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
= 0x1717, /* Asus WL169gE */
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
= 0xd11b, /* Eminent EM4045 */
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
= 0x0715, /* BT Voyager 1055 */
2628 RNDIS_MASTER_INTERFACE
,
2629 .driver_info
= (unsigned long) &bcm4320b_info
,
2631 /* These devices have DriverVer < 4.xx.xx.xx and do not have any custom
2632 * parameters available, hardware probably contain older firmware version with
2633 * no way of updating. Chipset marked as 'BCM4320????' in NDISwrapper-wiki.
2636 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2637 | USB_DEVICE_ID_MATCH_DEVICE
,
2639 .idProduct
= 0x000e, /* Linksys WUSB54GSv1 */
2640 RNDIS_MASTER_INTERFACE
,
2641 .driver_info
= (unsigned long) &bcm4320a_info
,
2643 .match_flags
= USB_DEVICE_ID_MATCH_INT_INFO
2644 | USB_DEVICE_ID_MATCH_DEVICE
,
2646 .idProduct
= 0x0111, /* U.S. Robotics USR5420 */
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
= 0x004b, /* BUFFALO WLI-USB-G54 */
2654 RNDIS_MASTER_INTERFACE
,
2655 .driver_info
= (unsigned long) &bcm4320a_info
,
2657 /* Generic Wireless RNDIS devices that we don't have exact
2658 * idVendor/idProduct/chip yet.
2661 /* RNDIS is MSFT's un-official variant of CDC ACM */
2662 USB_INTERFACE_INFO(USB_CLASS_COMM
, 2 /* ACM */, 0x0ff),
2663 .driver_info
= (unsigned long) &rndis_wlan_info
,
2665 /* "ActiveSync" is an undocumented variant of RNDIS, used in WM5 */
2666 USB_INTERFACE_INFO(USB_CLASS_MISC
, 1, 1),
2667 .driver_info
= (unsigned long) &rndis_wlan_info
,
2671 MODULE_DEVICE_TABLE(usb
, products
);
2673 static struct usb_driver rndis_wlan_driver
= {
2674 .name
= "rndis_wlan",
2675 .id_table
= products
,
2676 .probe
= usbnet_probe
,
2677 .disconnect
= usbnet_disconnect
,
2678 .suspend
= usbnet_suspend
,
2679 .resume
= usbnet_resume
,
2682 static int __init
rndis_wlan_init(void)
2684 return usb_register(&rndis_wlan_driver
);
2686 module_init(rndis_wlan_init
);
2688 static void __exit
rndis_wlan_exit(void)
2690 usb_deregister(&rndis_wlan_driver
);
2692 module_exit(rndis_wlan_exit
);
2694 MODULE_AUTHOR("Bjorge Dijkstra");
2695 MODULE_AUTHOR("Jussi Kivilinna");
2696 MODULE_DESCRIPTION("Driver for RNDIS based USB Wireless adapters");
2697 MODULE_LICENSE("GPL");