2 * This file contains ioctl functions
4 #include <linux/ctype.h>
5 #include <linux/slab.h>
6 #include <linux/delay.h>
8 #include <linux/if_arp.h>
9 #include <linux/wireless.h>
10 #include <linux/bitops.h>
12 #include <net/lib80211.h>
13 #include <net/iw_handler.h>
26 static inline void lbs_postpone_association_work(struct lbs_private
*priv
)
28 if (priv
->surpriseremoved
)
30 cancel_delayed_work(&priv
->assoc_work
);
31 queue_delayed_work(priv
->work_thread
, &priv
->assoc_work
, HZ
/ 2);
34 static inline void lbs_do_association_work(struct lbs_private
*priv
)
36 if (priv
->surpriseremoved
)
38 cancel_delayed_work(&priv
->assoc_work
);
39 queue_delayed_work(priv
->work_thread
, &priv
->assoc_work
, 0);
42 static inline void lbs_cancel_association_work(struct lbs_private
*priv
)
44 cancel_delayed_work(&priv
->assoc_work
);
45 kfree(priv
->pending_assoc_req
);
46 priv
->pending_assoc_req
= NULL
;
49 void lbs_send_disconnect_notification(struct lbs_private
*priv
)
51 union iwreq_data wrqu
;
53 memset(wrqu
.ap_addr
.sa_data
, 0x00, ETH_ALEN
);
54 wrqu
.ap_addr
.sa_family
= ARPHRD_ETHER
;
55 wireless_send_event(priv
->dev
, SIOCGIWAP
, &wrqu
, NULL
);
58 static void lbs_send_iwevcustom_event(struct lbs_private
*priv
, s8
*str
)
60 union iwreq_data iwrq
;
63 lbs_deb_enter(LBS_DEB_WEXT
);
65 memset(&iwrq
, 0, sizeof(union iwreq_data
));
66 memset(buf
, 0, sizeof(buf
));
68 snprintf(buf
, sizeof(buf
) - 1, "%s", str
);
70 iwrq
.data
.length
= strlen(buf
) + 1 + IW_EV_LCP_LEN
;
72 /* Send Event to upper layer */
73 lbs_deb_wext("event indication string %s\n", (char *)buf
);
74 lbs_deb_wext("event indication length %d\n", iwrq
.data
.length
);
75 lbs_deb_wext("sending wireless event IWEVCUSTOM for %s\n", str
);
77 wireless_send_event(priv
->dev
, IWEVCUSTOM
, &iwrq
, buf
);
79 lbs_deb_leave(LBS_DEB_WEXT
);
83 * @brief This function handles MIC failure event.
85 * @param priv A pointer to struct lbs_private structure
86 * @para event the event id
89 void lbs_send_mic_failureevent(struct lbs_private
*priv
, u32 event
)
93 lbs_deb_enter(LBS_DEB_CMD
);
94 memset(buf
, 0, sizeof(buf
));
96 sprintf(buf
, "%s", "MLME-MICHAELMICFAILURE.indication ");
98 if (event
== MACREG_INT_CODE_MIC_ERR_UNICAST
)
99 strcat(buf
, "unicast ");
101 strcat(buf
, "multicast ");
103 lbs_send_iwevcustom_event(priv
, buf
);
104 lbs_deb_leave(LBS_DEB_CMD
);
108 * @brief Find the channel frequency power info with specific channel
110 * @param priv A pointer to struct lbs_private structure
111 * @param band it can be BAND_A, BAND_G or BAND_B
112 * @param channel the channel for looking
113 * @return A pointer to struct chan_freq_power structure or NULL if not find.
115 struct chan_freq_power
*lbs_find_cfp_by_band_and_channel(
116 struct lbs_private
*priv
,
120 struct chan_freq_power
*cfp
= NULL
;
121 struct region_channel
*rc
;
124 for (j
= 0; !cfp
&& (j
< ARRAY_SIZE(priv
->region_channel
)); j
++) {
125 rc
= &priv
->region_channel
[j
];
127 if (!rc
->valid
|| !rc
->CFP
)
129 if (rc
->band
!= band
)
131 for (i
= 0; i
< rc
->nrcfp
; i
++) {
132 if (rc
->CFP
[i
].channel
== channel
) {
140 lbs_deb_wext("lbs_find_cfp_by_band_and_channel: can't find "
141 "cfp by band %d / channel %d\n", band
, channel
);
147 * @brief Find the channel frequency power info with specific frequency
149 * @param priv A pointer to struct lbs_private structure
150 * @param band it can be BAND_A, BAND_G or BAND_B
151 * @param freq the frequency for looking
152 * @return A pointer to struct chan_freq_power structure or NULL if not find.
154 static struct chan_freq_power
*find_cfp_by_band_and_freq(
155 struct lbs_private
*priv
,
159 struct chan_freq_power
*cfp
= NULL
;
160 struct region_channel
*rc
;
163 for (j
= 0; !cfp
&& (j
< ARRAY_SIZE(priv
->region_channel
)); j
++) {
164 rc
= &priv
->region_channel
[j
];
166 if (!rc
->valid
|| !rc
->CFP
)
168 if (rc
->band
!= band
)
170 for (i
= 0; i
< rc
->nrcfp
; i
++) {
171 if (rc
->CFP
[i
].freq
== freq
) {
179 lbs_deb_wext("find_cfp_by_band_and_freql: can't find cfp by "
180 "band %d / freq %d\n", band
, freq
);
186 * @brief Copy active data rates based on adapter mode and status
188 * @param priv A pointer to struct lbs_private structure
189 * @param rate The buf to return the active rates
191 static void copy_active_data_rates(struct lbs_private
*priv
, u8
*rates
)
193 lbs_deb_enter(LBS_DEB_WEXT
);
195 if ((priv
->connect_status
!= LBS_CONNECTED
) &&
196 !lbs_mesh_connected(priv
))
197 memcpy(rates
, lbs_bg_rates
, MAX_RATES
);
199 memcpy(rates
, priv
->curbssparams
.rates
, MAX_RATES
);
201 lbs_deb_leave(LBS_DEB_WEXT
);
204 static int lbs_get_name(struct net_device
*dev
, struct iw_request_info
*info
,
205 char *cwrq
, char *extra
)
208 lbs_deb_enter(LBS_DEB_WEXT
);
210 /* We could add support for 802.11n here as needed. Jean II */
211 snprintf(cwrq
, IFNAMSIZ
, "IEEE 802.11b/g");
213 lbs_deb_leave(LBS_DEB_WEXT
);
217 static int lbs_get_freq(struct net_device
*dev
, struct iw_request_info
*info
,
218 struct iw_freq
*fwrq
, char *extra
)
220 struct lbs_private
*priv
= dev
->ml_priv
;
221 struct chan_freq_power
*cfp
;
223 lbs_deb_enter(LBS_DEB_WEXT
);
225 cfp
= lbs_find_cfp_by_band_and_channel(priv
, 0,
230 lbs_deb_wext("invalid channel %d\n",
235 fwrq
->m
= (long)cfp
->freq
* 100000;
238 lbs_deb_wext("freq %u\n", fwrq
->m
);
239 lbs_deb_leave(LBS_DEB_WEXT
);
243 static int lbs_get_wap(struct net_device
*dev
, struct iw_request_info
*info
,
244 struct sockaddr
*awrq
, char *extra
)
246 struct lbs_private
*priv
= dev
->ml_priv
;
248 lbs_deb_enter(LBS_DEB_WEXT
);
250 if (priv
->connect_status
== LBS_CONNECTED
) {
251 memcpy(awrq
->sa_data
, priv
->curbssparams
.bssid
, ETH_ALEN
);
253 memset(awrq
->sa_data
, 0, ETH_ALEN
);
255 awrq
->sa_family
= ARPHRD_ETHER
;
257 lbs_deb_leave(LBS_DEB_WEXT
);
261 static int lbs_set_nick(struct net_device
*dev
, struct iw_request_info
*info
,
262 struct iw_point
*dwrq
, char *extra
)
264 struct lbs_private
*priv
= dev
->ml_priv
;
266 lbs_deb_enter(LBS_DEB_WEXT
);
269 * Check the size of the string
272 if (dwrq
->length
> 16) {
276 mutex_lock(&priv
->lock
);
277 memset(priv
->nodename
, 0, sizeof(priv
->nodename
));
278 memcpy(priv
->nodename
, extra
, dwrq
->length
);
279 mutex_unlock(&priv
->lock
);
281 lbs_deb_leave(LBS_DEB_WEXT
);
285 static int lbs_get_nick(struct net_device
*dev
, struct iw_request_info
*info
,
286 struct iw_point
*dwrq
, char *extra
)
288 struct lbs_private
*priv
= dev
->ml_priv
;
290 lbs_deb_enter(LBS_DEB_WEXT
);
292 dwrq
->length
= strlen(priv
->nodename
);
293 memcpy(extra
, priv
->nodename
, dwrq
->length
);
294 extra
[dwrq
->length
] = '\0';
296 dwrq
->flags
= 1; /* active */
298 lbs_deb_leave(LBS_DEB_WEXT
);
302 #ifdef CONFIG_LIBERTAS_MESH
303 static int mesh_get_nick(struct net_device
*dev
, struct iw_request_info
*info
,
304 struct iw_point
*dwrq
, char *extra
)
306 struct lbs_private
*priv
= dev
->ml_priv
;
308 lbs_deb_enter(LBS_DEB_WEXT
);
310 /* Use nickname to indicate that mesh is on */
312 if (lbs_mesh_connected(priv
)) {
313 strncpy(extra
, "Mesh", 12);
315 dwrq
->length
= strlen(extra
);
323 lbs_deb_leave(LBS_DEB_WEXT
);
328 static int lbs_set_rts(struct net_device
*dev
, struct iw_request_info
*info
,
329 struct iw_param
*vwrq
, char *extra
)
332 struct lbs_private
*priv
= dev
->ml_priv
;
333 u32 val
= vwrq
->value
;
335 lbs_deb_enter(LBS_DEB_WEXT
);
338 val
= MRVDRV_RTS_MAX_VALUE
;
340 if (val
> MRVDRV_RTS_MAX_VALUE
) /* min rts value is 0 */
343 ret
= lbs_set_snmp_mib(priv
, SNMP_MIB_OID_RTS_THRESHOLD
, (u16
) val
);
345 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
349 static int lbs_get_rts(struct net_device
*dev
, struct iw_request_info
*info
,
350 struct iw_param
*vwrq
, char *extra
)
352 struct lbs_private
*priv
= dev
->ml_priv
;
356 lbs_deb_enter(LBS_DEB_WEXT
);
358 ret
= lbs_get_snmp_mib(priv
, SNMP_MIB_OID_RTS_THRESHOLD
, &val
);
363 vwrq
->disabled
= val
> MRVDRV_RTS_MAX_VALUE
; /* min rts value is 0 */
367 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
371 static int lbs_set_frag(struct net_device
*dev
, struct iw_request_info
*info
,
372 struct iw_param
*vwrq
, char *extra
)
374 struct lbs_private
*priv
= dev
->ml_priv
;
376 u32 val
= vwrq
->value
;
378 lbs_deb_enter(LBS_DEB_WEXT
);
381 val
= MRVDRV_FRAG_MAX_VALUE
;
383 if (val
< MRVDRV_FRAG_MIN_VALUE
|| val
> MRVDRV_FRAG_MAX_VALUE
)
386 ret
= lbs_set_snmp_mib(priv
, SNMP_MIB_OID_FRAG_THRESHOLD
, (u16
) val
);
388 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
392 static int lbs_get_frag(struct net_device
*dev
, struct iw_request_info
*info
,
393 struct iw_param
*vwrq
, char *extra
)
395 struct lbs_private
*priv
= dev
->ml_priv
;
399 lbs_deb_enter(LBS_DEB_WEXT
);
401 ret
= lbs_get_snmp_mib(priv
, SNMP_MIB_OID_FRAG_THRESHOLD
, &val
);
406 vwrq
->disabled
= ((val
< MRVDRV_FRAG_MIN_VALUE
)
407 || (val
> MRVDRV_FRAG_MAX_VALUE
));
411 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
415 static int lbs_get_mode(struct net_device
*dev
,
416 struct iw_request_info
*info
, u32
* uwrq
, char *extra
)
418 struct lbs_private
*priv
= dev
->ml_priv
;
420 lbs_deb_enter(LBS_DEB_WEXT
);
424 lbs_deb_leave(LBS_DEB_WEXT
);
428 #ifdef CONFIG_LIBERTAS_MESH
429 static int mesh_wlan_get_mode(struct net_device
*dev
,
430 struct iw_request_info
*info
, u32
* uwrq
,
433 lbs_deb_enter(LBS_DEB_WEXT
);
435 *uwrq
= IW_MODE_REPEAT
;
437 lbs_deb_leave(LBS_DEB_WEXT
);
442 static int lbs_get_txpow(struct net_device
*dev
,
443 struct iw_request_info
*info
,
444 struct iw_param
*vwrq
, char *extra
)
446 struct lbs_private
*priv
= dev
->ml_priv
;
450 lbs_deb_enter(LBS_DEB_WEXT
);
452 if (!priv
->radio_on
) {
453 lbs_deb_wext("tx power off\n");
459 ret
= lbs_get_tx_power(priv
, &curlevel
, NULL
, NULL
);
463 lbs_deb_wext("tx power level %d dbm\n", curlevel
);
464 priv
->txpower_cur
= curlevel
;
466 vwrq
->value
= curlevel
;
469 vwrq
->flags
= IW_TXPOW_DBM
;
472 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
476 static int lbs_set_retry(struct net_device
*dev
, struct iw_request_info
*info
,
477 struct iw_param
*vwrq
, char *extra
)
479 struct lbs_private
*priv
= dev
->ml_priv
;
481 u16 slimit
= 0, llimit
= 0;
483 lbs_deb_enter(LBS_DEB_WEXT
);
485 if ((vwrq
->flags
& IW_RETRY_TYPE
) != IW_RETRY_LIMIT
)
488 /* The MAC has a 4-bit Total_Tx_Count register
489 Total_Tx_Count = 1 + Tx_Retry_Count */
490 #define TX_RETRY_MIN 0
491 #define TX_RETRY_MAX 14
492 if (vwrq
->value
< TX_RETRY_MIN
|| vwrq
->value
> TX_RETRY_MAX
)
495 /* Add 1 to convert retry count to try count */
496 if (vwrq
->flags
& IW_RETRY_SHORT
)
497 slimit
= (u16
) (vwrq
->value
+ 1);
498 else if (vwrq
->flags
& IW_RETRY_LONG
)
499 llimit
= (u16
) (vwrq
->value
+ 1);
501 slimit
= llimit
= (u16
) (vwrq
->value
+ 1); /* set both */
504 ret
= lbs_set_snmp_mib(priv
, SNMP_MIB_OID_LONG_RETRY_LIMIT
,
511 /* txretrycount follows the short retry limit */
512 priv
->txretrycount
= slimit
;
513 ret
= lbs_set_snmp_mib(priv
, SNMP_MIB_OID_SHORT_RETRY_LIMIT
,
520 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
524 static int lbs_get_retry(struct net_device
*dev
, struct iw_request_info
*info
,
525 struct iw_param
*vwrq
, char *extra
)
527 struct lbs_private
*priv
= dev
->ml_priv
;
531 lbs_deb_enter(LBS_DEB_WEXT
);
535 if (vwrq
->flags
& IW_RETRY_LONG
) {
536 ret
= lbs_get_snmp_mib(priv
, SNMP_MIB_OID_LONG_RETRY_LIMIT
, &val
);
540 /* Subtract 1 to convert try count to retry count */
541 vwrq
->value
= val
- 1;
542 vwrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
544 ret
= lbs_get_snmp_mib(priv
, SNMP_MIB_OID_SHORT_RETRY_LIMIT
, &val
);
548 /* txretry count follows the short retry limit */
549 priv
->txretrycount
= val
;
550 /* Subtract 1 to convert try count to retry count */
551 vwrq
->value
= val
- 1;
552 vwrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_SHORT
;
556 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
560 static inline void sort_channels(struct iw_freq
*freq
, int num
)
565 for (i
= 0; i
< num
; i
++)
566 for (j
= i
+ 1; j
< num
; j
++)
567 if (freq
[i
].i
> freq
[j
].i
) {
571 freq
[i
].i
= freq
[j
].i
;
572 freq
[i
].m
= freq
[j
].m
;
582 Infra G(12) A(8) B(4) G(12)
583 Adhoc A+B(12) A(8) B(4) B(4)
591 * @brief Get Range Info
593 * @param dev A pointer to net_device structure
594 * @param info A pointer to iw_request_info structure
595 * @param vwrq A pointer to iw_param structure
596 * @param extra A pointer to extra data buf
597 * @return 0 --success, otherwise fail
599 static int lbs_get_range(struct net_device
*dev
, struct iw_request_info
*info
,
600 struct iw_point
*dwrq
, char *extra
)
603 struct lbs_private
*priv
= dev
->ml_priv
;
604 struct iw_range
*range
= (struct iw_range
*)extra
;
605 struct chan_freq_power
*cfp
;
606 u8 rates
[MAX_RATES
+ 1];
608 lbs_deb_enter(LBS_DEB_WEXT
);
610 dwrq
->length
= sizeof(struct iw_range
);
611 memset(range
, 0, sizeof(struct iw_range
));
616 memset(rates
, 0, sizeof(rates
));
617 copy_active_data_rates(priv
, rates
);
618 range
->num_bitrates
= strnlen(rates
, IW_MAX_BITRATES
);
619 for (i
= 0; i
< range
->num_bitrates
; i
++)
620 range
->bitrate
[i
] = rates
[i
] * 500000;
621 range
->num_bitrates
= i
;
622 lbs_deb_wext("IW_MAX_BITRATES %d, num_bitrates %d\n", IW_MAX_BITRATES
,
623 range
->num_bitrates
);
625 range
->num_frequency
= 0;
627 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
629 for (j
= 0; (range
->num_frequency
< IW_MAX_FREQUENCIES
)
630 && (j
< ARRAY_SIZE(priv
->region_channel
)); j
++) {
631 cfp
= priv
->region_channel
[j
].CFP
;
632 for (i
= 0; (range
->num_frequency
< IW_MAX_FREQUENCIES
)
633 && priv
->region_channel
[j
].valid
635 && (i
< priv
->region_channel
[j
].nrcfp
); i
++) {
636 range
->freq
[range
->num_frequency
].i
=
638 range
->freq
[range
->num_frequency
].m
=
639 (long)cfp
->freq
* 100000;
640 range
->freq
[range
->num_frequency
].e
= 1;
642 range
->num_frequency
++;
646 lbs_deb_wext("IW_MAX_FREQUENCIES %d, num_frequency %d\n",
647 IW_MAX_FREQUENCIES
, range
->num_frequency
);
649 range
->num_channels
= range
->num_frequency
;
651 sort_channels(&range
->freq
[0], range
->num_frequency
);
654 * Set an indication of the max TCP throughput in bit/s that we can
655 * expect using this interface
658 range
->throughput
= 5000 * 1000;
660 range
->throughput
= 1500 * 1000;
662 range
->min_rts
= MRVDRV_RTS_MIN_VALUE
;
663 range
->max_rts
= MRVDRV_RTS_MAX_VALUE
;
664 range
->min_frag
= MRVDRV_FRAG_MIN_VALUE
;
665 range
->max_frag
= MRVDRV_FRAG_MAX_VALUE
;
667 range
->encoding_size
[0] = 5;
668 range
->encoding_size
[1] = 13;
669 range
->num_encoding_sizes
= 2;
670 range
->max_encoding_tokens
= 4;
673 * Right now we support only "iwconfig ethX power on|off"
675 range
->pm_capa
= IW_POWER_ON
;
678 * Minimum version we recommend
680 range
->we_version_source
= 15;
683 * Version we are compiled with
685 range
->we_version_compiled
= WIRELESS_EXT
;
687 range
->retry_capa
= IW_RETRY_LIMIT
;
688 range
->retry_flags
= IW_RETRY_LIMIT
| IW_RETRY_MAX
;
690 range
->min_retry
= TX_RETRY_MIN
;
691 range
->max_retry
= TX_RETRY_MAX
;
694 * Set the qual, level and noise range values
696 range
->max_qual
.qual
= 100;
697 range
->max_qual
.level
= 0;
698 range
->max_qual
.noise
= 0;
699 range
->max_qual
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
701 range
->avg_qual
.qual
= 70;
702 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
703 range
->avg_qual
.level
= 0;
704 range
->avg_qual
.noise
= 0;
705 range
->avg_qual
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
707 range
->sensitivity
= 0;
709 /* Setup the supported power level ranges */
710 memset(range
->txpower
, 0, sizeof(range
->txpower
));
711 range
->txpower_capa
= IW_TXPOW_DBM
| IW_TXPOW_RANGE
;
712 range
->txpower
[0] = priv
->txpower_min
;
713 range
->txpower
[1] = priv
->txpower_max
;
714 range
->num_txpower
= 2;
716 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
717 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
718 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
719 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
721 if (priv
->fwcapinfo
& FW_CAPINFO_WPA
) {
722 range
->enc_capa
= IW_ENC_CAPA_WPA
724 | IW_ENC_CAPA_CIPHER_TKIP
725 | IW_ENC_CAPA_CIPHER_CCMP
;
728 lbs_deb_leave(LBS_DEB_WEXT
);
732 static int lbs_set_power(struct net_device
*dev
, struct iw_request_info
*info
,
733 struct iw_param
*vwrq
, char *extra
)
735 struct lbs_private
*priv
= dev
->ml_priv
;
738 lbs_deb_enter(LBS_DEB_WEXT
);
740 if (!(priv
->fwcapinfo
& FW_CAPINFO_PS
)) {
747 /* PS is currently supported only in Infrastructure mode
748 * Remove this check if it is to be supported in IBSS mode also
751 if (vwrq
->disabled
) {
752 priv
->psmode
= LBS802_11POWERMODECAM
;
753 if (priv
->psstate
!= PS_STATE_FULL_POWER
) {
754 lbs_ps_wakeup(priv
, CMD_OPTION_WAITFORRSP
);
760 if ((vwrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
762 "setting power timeout is not supported\n");
764 } else if ((vwrq
->flags
& IW_POWER_TYPE
) == IW_POWER_PERIOD
) {
765 vwrq
->value
= vwrq
->value
/ 1000;
766 if (!priv
->enter_deep_sleep
) {
767 lbs_pr_err("deep sleep feature is not implemented "
768 "for this interface driver\n");
772 if (priv
->connect_status
== LBS_CONNECTED
) {
773 if ((priv
->is_auto_deep_sleep_enabled
) &&
774 (vwrq
->value
== -1000)) {
775 lbs_exit_auto_deep_sleep(priv
);
778 lbs_pr_err("can't use deep sleep cmd in "
779 "connected state\n");
784 if ((vwrq
->value
< 0) && (vwrq
->value
!= -1000)) {
785 lbs_pr_err("unknown option\n");
789 if (vwrq
->value
> 0) {
790 if (!priv
->is_auto_deep_sleep_enabled
) {
791 priv
->is_activity_detected
= 0;
792 priv
->auto_deep_sleep_timeout
= vwrq
->value
;
793 lbs_enter_auto_deep_sleep(priv
);
795 priv
->auto_deep_sleep_timeout
= vwrq
->value
;
796 lbs_deb_debugfs("auto deep sleep: "
797 "already enabled\n");
801 if (priv
->is_auto_deep_sleep_enabled
) {
802 lbs_exit_auto_deep_sleep(priv
);
803 /* Try to exit deep sleep if auto */
804 /*deep sleep disabled */
805 ret
= lbs_set_deep_sleep(priv
, 0);
807 if (vwrq
->value
== 0)
808 ret
= lbs_set_deep_sleep(priv
, 1);
809 else if (vwrq
->value
== -1000)
810 ret
= lbs_set_deep_sleep(priv
, 0);
815 if (priv
->psmode
!= LBS802_11POWERMODECAM
) {
819 priv
->psmode
= LBS802_11POWERMODEMAX_PSP
;
821 if (priv
->connect_status
== LBS_CONNECTED
) {
822 lbs_ps_sleep(priv
, CMD_OPTION_WAITFORRSP
);
825 lbs_deb_leave(LBS_DEB_WEXT
);
830 static int lbs_get_power(struct net_device
*dev
, struct iw_request_info
*info
,
831 struct iw_param
*vwrq
, char *extra
)
833 struct lbs_private
*priv
= dev
->ml_priv
;
835 lbs_deb_enter(LBS_DEB_WEXT
);
839 vwrq
->disabled
= priv
->psmode
== LBS802_11POWERMODECAM
840 || priv
->connect_status
== LBS_DISCONNECTED
;
842 lbs_deb_leave(LBS_DEB_WEXT
);
846 static struct iw_statistics
*lbs_get_wireless_stats(struct net_device
*dev
)
856 struct lbs_private
*priv
= dev
->ml_priv
;
860 int ret
, stats_valid
= 0;
863 struct cmd_ds_802_11_get_log log
;
865 lbs_deb_enter(LBS_DEB_WEXT
);
867 priv
->wstats
.status
= priv
->mode
;
869 /* If we're not associated, all quality values are meaningless */
870 if ((priv
->connect_status
!= LBS_CONNECTED
) &&
871 !lbs_mesh_connected(priv
))
874 /* Quality by RSSI */
875 priv
->wstats
.qual
.level
=
876 CAL_RSSI(priv
->SNR
[TYPE_BEACON
][TYPE_NOAVG
],
877 priv
->NF
[TYPE_BEACON
][TYPE_NOAVG
]);
879 if (priv
->NF
[TYPE_BEACON
][TYPE_NOAVG
] == 0) {
880 priv
->wstats
.qual
.noise
= MRVDRV_NF_DEFAULT_SCAN_VALUE
;
882 priv
->wstats
.qual
.noise
=
883 CAL_NF(priv
->NF
[TYPE_BEACON
][TYPE_NOAVG
]);
886 lbs_deb_wext("signal level %#x\n", priv
->wstats
.qual
.level
);
887 lbs_deb_wext("noise %#x\n", priv
->wstats
.qual
.noise
);
889 rssi
= priv
->wstats
.qual
.level
- priv
->wstats
.qual
.noise
;
891 rssi_qual
= rssi
* POOR
/ 10;
893 rssi_qual
= (rssi
- 15) * (FAIR
- POOR
) / 5 + POOR
;
895 rssi_qual
= (rssi
- 20) * (GOOD
- FAIR
) / 5 + FAIR
;
897 rssi_qual
= (rssi
- 30) * (VERY_GOOD
- GOOD
) /
900 rssi_qual
= (rssi
- 40) * (PERFECT
- VERY_GOOD
) /
904 /* Quality by TX errors */
905 priv
->wstats
.discard
.retries
= dev
->stats
.tx_errors
;
907 memset(&log
, 0, sizeof(log
));
908 log
.hdr
.size
= cpu_to_le16(sizeof(log
));
909 ret
= lbs_cmd_with_response(priv
, CMD_802_11_GET_LOG
, &log
);
913 tx_retries
= le32_to_cpu(log
.retry
);
916 tx_qual
= (90 - tx_retries
) * POOR
/ 15;
917 else if (tx_retries
> 70)
918 tx_qual
= (75 - tx_retries
) * (FAIR
- POOR
) / 5 + POOR
;
919 else if (tx_retries
> 65)
920 tx_qual
= (70 - tx_retries
) * (GOOD
- FAIR
) / 5 + FAIR
;
921 else if (tx_retries
> 50)
922 tx_qual
= (65 - tx_retries
) * (VERY_GOOD
- GOOD
) /
925 tx_qual
= (50 - tx_retries
) *
926 (PERFECT
- VERY_GOOD
) / 50 + VERY_GOOD
;
927 quality
= min(quality
, tx_qual
);
929 priv
->wstats
.discard
.code
= le32_to_cpu(log
.wepundecryptable
);
930 priv
->wstats
.discard
.retries
= tx_retries
;
931 priv
->wstats
.discard
.misc
= le32_to_cpu(log
.ackfailure
);
933 /* Calculate quality */
934 priv
->wstats
.qual
.qual
= min_t(u8
, quality
, 100);
935 priv
->wstats
.qual
.updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
938 /* update stats asynchronously for future calls */
939 ret
= lbs_prepare_and_send_command(priv
, CMD_802_11_RSSI
, 0,
942 lbs_pr_err("RSSI command failed\n");
945 priv
->wstats
.miss
.beacon
= 0;
946 priv
->wstats
.discard
.retries
= 0;
947 priv
->wstats
.qual
.qual
= 0;
948 priv
->wstats
.qual
.level
= 0;
949 priv
->wstats
.qual
.noise
= 0;
950 priv
->wstats
.qual
.updated
= IW_QUAL_ALL_UPDATED
;
951 priv
->wstats
.qual
.updated
|= IW_QUAL_NOISE_INVALID
|
952 IW_QUAL_QUAL_INVALID
| IW_QUAL_LEVEL_INVALID
;
955 lbs_deb_leave(LBS_DEB_WEXT
);
956 return &priv
->wstats
;
961 static int lbs_set_freq(struct net_device
*dev
, struct iw_request_info
*info
,
962 struct iw_freq
*fwrq
, char *extra
)
965 struct lbs_private
*priv
= dev
->ml_priv
;
966 struct chan_freq_power
*cfp
;
967 struct assoc_request
* assoc_req
;
969 lbs_deb_enter(LBS_DEB_WEXT
);
971 mutex_lock(&priv
->lock
);
972 assoc_req
= lbs_get_association_request(priv
);
978 /* If setting by frequency, convert to a channel */
980 long f
= fwrq
->m
/ 100000;
982 cfp
= find_cfp_by_band_and_freq(priv
, 0, f
);
984 lbs_deb_wext("invalid freq %ld\n", f
);
989 fwrq
->m
= (int) cfp
->channel
;
992 /* Setting by channel number */
993 if (fwrq
->m
> 1000 || fwrq
->e
> 0) {
997 cfp
= lbs_find_cfp_by_band_and_channel(priv
, 0, fwrq
->m
);
1002 assoc_req
->channel
= fwrq
->m
;
1007 set_bit(ASSOC_FLAG_CHANNEL
, &assoc_req
->flags
);
1008 lbs_postpone_association_work(priv
);
1010 lbs_cancel_association_work(priv
);
1012 mutex_unlock(&priv
->lock
);
1014 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1018 #ifdef CONFIG_LIBERTAS_MESH
1019 static int lbs_mesh_set_freq(struct net_device
*dev
,
1020 struct iw_request_info
*info
,
1021 struct iw_freq
*fwrq
, char *extra
)
1023 struct lbs_private
*priv
= dev
->ml_priv
;
1024 struct chan_freq_power
*cfp
;
1027 lbs_deb_enter(LBS_DEB_WEXT
);
1029 /* If setting by frequency, convert to a channel */
1031 long f
= fwrq
->m
/ 100000;
1033 cfp
= find_cfp_by_band_and_freq(priv
, 0, f
);
1035 lbs_deb_wext("invalid freq %ld\n", f
);
1040 fwrq
->m
= (int) cfp
->channel
;
1043 /* Setting by channel number */
1044 if (fwrq
->m
> 1000 || fwrq
->e
> 0) {
1048 cfp
= lbs_find_cfp_by_band_and_channel(priv
, 0, fwrq
->m
);
1053 if (fwrq
->m
!= priv
->channel
) {
1054 lbs_deb_wext("mesh channel change forces eth disconnect\n");
1055 if (priv
->mode
== IW_MODE_INFRA
)
1056 lbs_cmd_80211_deauthenticate(priv
,
1057 priv
->curbssparams
.bssid
,
1058 WLAN_REASON_DEAUTH_LEAVING
);
1059 else if (priv
->mode
== IW_MODE_ADHOC
)
1060 lbs_adhoc_stop(priv
);
1062 lbs_mesh_config(priv
, CMD_ACT_MESH_CONFIG_START
, fwrq
->m
);
1063 lbs_update_channel(priv
);
1067 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1072 static int lbs_set_rate(struct net_device
*dev
, struct iw_request_info
*info
,
1073 struct iw_param
*vwrq
, char *extra
)
1075 struct lbs_private
*priv
= dev
->ml_priv
;
1078 u8 rates
[MAX_RATES
+ 1];
1080 lbs_deb_enter(LBS_DEB_WEXT
);
1082 lbs_deb_wext("vwrq->value %d\n", vwrq
->value
);
1083 lbs_deb_wext("vwrq->fixed %d\n", vwrq
->fixed
);
1085 if (vwrq
->fixed
&& vwrq
->value
== -1)
1089 priv
->enablehwauto
= !vwrq
->fixed
;
1091 if (vwrq
->value
== -1)
1094 if (vwrq
->value
% 100000)
1097 new_rate
= vwrq
->value
/ 500000;
1098 priv
->cur_rate
= new_rate
;
1099 /* the rest is only needed for lbs_set_data_rate() */
1100 memset(rates
, 0, sizeof(rates
));
1101 copy_active_data_rates(priv
, rates
);
1102 if (!memchr(rates
, new_rate
, sizeof(rates
))) {
1103 lbs_pr_alert("fixed data rate 0x%X out of range\n",
1107 if (priv
->fwrelease
< 0x09000000) {
1108 ret
= lbs_set_power_adapt_cfg(priv
, 0,
1109 POW_ADAPT_DEFAULT_P0
,
1110 POW_ADAPT_DEFAULT_P1
,
1111 POW_ADAPT_DEFAULT_P2
);
1115 ret
= lbs_set_tpc_cfg(priv
, 0, TPC_DEFAULT_P0
, TPC_DEFAULT_P1
,
1121 /* Try the newer command first (Firmware Spec 5.1 and above) */
1122 ret
= lbs_cmd_802_11_rate_adapt_rateset(priv
, CMD_ACT_SET
);
1124 /* Fallback to older version */
1126 ret
= lbs_set_data_rate(priv
, new_rate
);
1129 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1133 static int lbs_get_rate(struct net_device
*dev
, struct iw_request_info
*info
,
1134 struct iw_param
*vwrq
, char *extra
)
1136 struct lbs_private
*priv
= dev
->ml_priv
;
1138 lbs_deb_enter(LBS_DEB_WEXT
);
1140 if (priv
->connect_status
== LBS_CONNECTED
) {
1141 vwrq
->value
= priv
->cur_rate
* 500000;
1143 if (priv
->enablehwauto
)
1153 lbs_deb_leave(LBS_DEB_WEXT
);
1157 static int lbs_set_mode(struct net_device
*dev
,
1158 struct iw_request_info
*info
, u32
* uwrq
, char *extra
)
1161 struct lbs_private
*priv
= dev
->ml_priv
;
1162 struct assoc_request
* assoc_req
;
1164 lbs_deb_enter(LBS_DEB_WEXT
);
1166 if ( (*uwrq
!= IW_MODE_ADHOC
)
1167 && (*uwrq
!= IW_MODE_INFRA
)
1168 && (*uwrq
!= IW_MODE_AUTO
)) {
1169 lbs_deb_wext("Invalid mode: 0x%x\n", *uwrq
);
1174 mutex_lock(&priv
->lock
);
1175 assoc_req
= lbs_get_association_request(priv
);
1178 lbs_cancel_association_work(priv
);
1180 assoc_req
->mode
= *uwrq
;
1181 set_bit(ASSOC_FLAG_MODE
, &assoc_req
->flags
);
1182 lbs_postpone_association_work(priv
);
1183 lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq
);
1185 mutex_unlock(&priv
->lock
);
1188 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1194 * @brief Get Encryption key
1196 * @param dev A pointer to net_device structure
1197 * @param info A pointer to iw_request_info structure
1198 * @param vwrq A pointer to iw_param structure
1199 * @param extra A pointer to extra data buf
1200 * @return 0 --success, otherwise fail
1202 static int lbs_get_encode(struct net_device
*dev
,
1203 struct iw_request_info
*info
,
1204 struct iw_point
*dwrq
, u8
* extra
)
1206 struct lbs_private
*priv
= dev
->ml_priv
;
1207 int index
= (dwrq
->flags
& IW_ENCODE_INDEX
) - 1;
1209 lbs_deb_enter(LBS_DEB_WEXT
);
1211 lbs_deb_wext("flags 0x%x, index %d, length %d, wep_tx_keyidx %d\n",
1212 dwrq
->flags
, index
, dwrq
->length
, priv
->wep_tx_keyidx
);
1216 /* Authentication method */
1217 switch (priv
->secinfo
.auth_mode
) {
1218 case IW_AUTH_ALG_OPEN_SYSTEM
:
1219 dwrq
->flags
= IW_ENCODE_OPEN
;
1222 case IW_AUTH_ALG_SHARED_KEY
:
1223 case IW_AUTH_ALG_LEAP
:
1224 dwrq
->flags
= IW_ENCODE_RESTRICTED
;
1227 dwrq
->flags
= IW_ENCODE_DISABLED
| IW_ENCODE_OPEN
;
1231 memset(extra
, 0, 16);
1233 mutex_lock(&priv
->lock
);
1235 /* Default to returning current transmit key */
1237 index
= priv
->wep_tx_keyidx
;
1239 if ((priv
->wep_keys
[index
].len
) && priv
->secinfo
.wep_enabled
) {
1240 memcpy(extra
, priv
->wep_keys
[index
].key
,
1241 priv
->wep_keys
[index
].len
);
1242 dwrq
->length
= priv
->wep_keys
[index
].len
;
1244 dwrq
->flags
|= (index
+ 1);
1245 /* Return WEP enabled */
1246 dwrq
->flags
&= ~IW_ENCODE_DISABLED
;
1247 } else if ((priv
->secinfo
.WPAenabled
)
1248 || (priv
->secinfo
.WPA2enabled
)) {
1249 /* return WPA enabled */
1250 dwrq
->flags
&= ~IW_ENCODE_DISABLED
;
1251 dwrq
->flags
|= IW_ENCODE_NOKEY
;
1253 dwrq
->flags
|= IW_ENCODE_DISABLED
;
1256 mutex_unlock(&priv
->lock
);
1258 lbs_deb_wext("key: %02x:%02x:%02x:%02x:%02x:%02x, keylen %d\n",
1259 extra
[0], extra
[1], extra
[2],
1260 extra
[3], extra
[4], extra
[5], dwrq
->length
);
1262 lbs_deb_wext("return flags 0x%x\n", dwrq
->flags
);
1264 lbs_deb_leave(LBS_DEB_WEXT
);
1269 * @brief Set Encryption key (internal)
1271 * @param priv A pointer to private card structure
1272 * @param key_material A pointer to key material
1273 * @param key_length length of key material
1274 * @param index key index to set
1275 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1276 * @return 0 --success, otherwise fail
1278 static int lbs_set_wep_key(struct assoc_request
*assoc_req
,
1279 const char *key_material
,
1285 struct enc_key
*pkey
;
1287 lbs_deb_enter(LBS_DEB_WEXT
);
1289 /* Paranoid validation of key index */
1295 /* validate max key length */
1296 if (key_length
> KEY_LEN_WEP_104
) {
1301 pkey
= &assoc_req
->wep_keys
[index
];
1303 if (key_length
> 0) {
1304 memset(pkey
, 0, sizeof(struct enc_key
));
1305 pkey
->type
= KEY_TYPE_ID_WEP
;
1307 /* Standardize the key length */
1308 pkey
->len
= (key_length
> KEY_LEN_WEP_40
) ?
1309 KEY_LEN_WEP_104
: KEY_LEN_WEP_40
;
1310 memcpy(pkey
->key
, key_material
, key_length
);
1314 /* Ensure the chosen key is valid */
1316 lbs_deb_wext("key not set, so cannot enable it\n");
1320 assoc_req
->wep_tx_keyidx
= index
;
1323 assoc_req
->secinfo
.wep_enabled
= 1;
1326 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1330 static int validate_key_index(u16 def_index
, u16 raw_index
,
1331 u16
*out_index
, u16
*is_default
)
1333 if (!out_index
|| !is_default
)
1336 /* Verify index if present, otherwise use default TX key index */
1337 if (raw_index
> 0) {
1340 *out_index
= raw_index
- 1;
1342 *out_index
= def_index
;
1348 static void disable_wep(struct assoc_request
*assoc_req
)
1352 lbs_deb_enter(LBS_DEB_WEXT
);
1354 /* Set Open System auth mode */
1355 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1357 /* Clear WEP keys and mark WEP as disabled */
1358 assoc_req
->secinfo
.wep_enabled
= 0;
1359 for (i
= 0; i
< 4; i
++)
1360 assoc_req
->wep_keys
[i
].len
= 0;
1362 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1363 set_bit(ASSOC_FLAG_WEP_KEYS
, &assoc_req
->flags
);
1365 lbs_deb_leave(LBS_DEB_WEXT
);
1368 static void disable_wpa(struct assoc_request
*assoc_req
)
1370 lbs_deb_enter(LBS_DEB_WEXT
);
1372 memset(&assoc_req
->wpa_mcast_key
, 0, sizeof (struct enc_key
));
1373 assoc_req
->wpa_mcast_key
.flags
= KEY_INFO_WPA_MCAST
;
1374 set_bit(ASSOC_FLAG_WPA_MCAST_KEY
, &assoc_req
->flags
);
1376 memset(&assoc_req
->wpa_unicast_key
, 0, sizeof (struct enc_key
));
1377 assoc_req
->wpa_unicast_key
.flags
= KEY_INFO_WPA_UNICAST
;
1378 set_bit(ASSOC_FLAG_WPA_UCAST_KEY
, &assoc_req
->flags
);
1380 assoc_req
->secinfo
.WPAenabled
= 0;
1381 assoc_req
->secinfo
.WPA2enabled
= 0;
1382 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1384 lbs_deb_leave(LBS_DEB_WEXT
);
1388 * @brief Set Encryption key
1390 * @param dev A pointer to net_device structure
1391 * @param info A pointer to iw_request_info structure
1392 * @param vwrq A pointer to iw_param structure
1393 * @param extra A pointer to extra data buf
1394 * @return 0 --success, otherwise fail
1396 static int lbs_set_encode(struct net_device
*dev
,
1397 struct iw_request_info
*info
,
1398 struct iw_point
*dwrq
, char *extra
)
1401 struct lbs_private
*priv
= dev
->ml_priv
;
1402 struct assoc_request
* assoc_req
;
1403 u16 is_default
= 0, index
= 0, set_tx_key
= 0;
1405 lbs_deb_enter(LBS_DEB_WEXT
);
1407 mutex_lock(&priv
->lock
);
1408 assoc_req
= lbs_get_association_request(priv
);
1414 if (dwrq
->flags
& IW_ENCODE_DISABLED
) {
1415 disable_wep (assoc_req
);
1416 disable_wpa (assoc_req
);
1420 ret
= validate_key_index(assoc_req
->wep_tx_keyidx
,
1421 (dwrq
->flags
& IW_ENCODE_INDEX
),
1422 &index
, &is_default
);
1428 /* If WEP isn't enabled, or if there is no key data but a valid
1429 * index, set the TX key.
1431 if (!assoc_req
->secinfo
.wep_enabled
|| (dwrq
->length
== 0 && !is_default
))
1434 ret
= lbs_set_wep_key(assoc_req
, extra
, dwrq
->length
, index
, set_tx_key
);
1439 set_bit(ASSOC_FLAG_WEP_KEYS
, &assoc_req
->flags
);
1441 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX
, &assoc_req
->flags
);
1443 if (dwrq
->flags
& IW_ENCODE_RESTRICTED
) {
1444 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_SHARED_KEY
;
1445 } else if (dwrq
->flags
& IW_ENCODE_OPEN
) {
1446 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1451 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1452 lbs_postpone_association_work(priv
);
1454 lbs_cancel_association_work(priv
);
1456 mutex_unlock(&priv
->lock
);
1458 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1463 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
1465 * @param dev A pointer to net_device structure
1466 * @param info A pointer to iw_request_info structure
1467 * @param vwrq A pointer to iw_param structure
1468 * @param extra A pointer to extra data buf
1469 * @return 0 on success, otherwise failure
1471 static int lbs_get_encodeext(struct net_device
*dev
,
1472 struct iw_request_info
*info
,
1473 struct iw_point
*dwrq
,
1477 struct lbs_private
*priv
= dev
->ml_priv
;
1478 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1479 int index
, max_key_len
;
1481 lbs_deb_enter(LBS_DEB_WEXT
);
1483 max_key_len
= dwrq
->length
- sizeof(*ext
);
1484 if (max_key_len
< 0)
1487 index
= dwrq
->flags
& IW_ENCODE_INDEX
;
1489 if (index
< 1 || index
> 4)
1493 index
= priv
->wep_tx_keyidx
;
1496 if (!(ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) &&
1497 ext
->alg
!= IW_ENCODE_ALG_WEP
) {
1498 if (index
!= 0 || priv
->mode
!= IW_MODE_INFRA
)
1502 dwrq
->flags
= index
+ 1;
1503 memset(ext
, 0, sizeof(*ext
));
1505 if ( !priv
->secinfo
.wep_enabled
1506 && !priv
->secinfo
.WPAenabled
1507 && !priv
->secinfo
.WPA2enabled
) {
1508 ext
->alg
= IW_ENCODE_ALG_NONE
;
1510 dwrq
->flags
|= IW_ENCODE_DISABLED
;
1514 if ( priv
->secinfo
.wep_enabled
1515 && !priv
->secinfo
.WPAenabled
1516 && !priv
->secinfo
.WPA2enabled
) {
1518 ext
->alg
= IW_ENCODE_ALG_WEP
;
1519 ext
->key_len
= priv
->wep_keys
[index
].len
;
1520 key
= &priv
->wep_keys
[index
].key
[0];
1521 } else if ( !priv
->secinfo
.wep_enabled
1522 && (priv
->secinfo
.WPAenabled
||
1523 priv
->secinfo
.WPA2enabled
)) {
1525 struct enc_key
* pkey
= NULL
;
1527 if ( priv
->wpa_mcast_key
.len
1528 && (priv
->wpa_mcast_key
.flags
& KEY_INFO_WPA_ENABLED
))
1529 pkey
= &priv
->wpa_mcast_key
;
1530 else if ( priv
->wpa_unicast_key
.len
1531 && (priv
->wpa_unicast_key
.flags
& KEY_INFO_WPA_ENABLED
))
1532 pkey
= &priv
->wpa_unicast_key
;
1535 if (pkey
->type
== KEY_TYPE_ID_AES
) {
1536 ext
->alg
= IW_ENCODE_ALG_CCMP
;
1538 ext
->alg
= IW_ENCODE_ALG_TKIP
;
1540 ext
->key_len
= pkey
->len
;
1541 key
= &pkey
->key
[0];
1543 ext
->alg
= IW_ENCODE_ALG_TKIP
;
1550 if (ext
->key_len
> max_key_len
) {
1556 memcpy(ext
->key
, key
, ext
->key_len
);
1558 dwrq
->flags
|= IW_ENCODE_NOKEY
;
1559 dwrq
->flags
|= IW_ENCODE_ENABLED
;
1564 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1569 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
1571 * @param dev A pointer to net_device structure
1572 * @param info A pointer to iw_request_info structure
1573 * @param vwrq A pointer to iw_param structure
1574 * @param extra A pointer to extra data buf
1575 * @return 0 --success, otherwise fail
1577 static int lbs_set_encodeext(struct net_device
*dev
,
1578 struct iw_request_info
*info
,
1579 struct iw_point
*dwrq
,
1583 struct lbs_private
*priv
= dev
->ml_priv
;
1584 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1586 struct assoc_request
* assoc_req
;
1588 lbs_deb_enter(LBS_DEB_WEXT
);
1590 mutex_lock(&priv
->lock
);
1591 assoc_req
= lbs_get_association_request(priv
);
1597 if ((alg
== IW_ENCODE_ALG_NONE
) || (dwrq
->flags
& IW_ENCODE_DISABLED
)) {
1598 disable_wep (assoc_req
);
1599 disable_wpa (assoc_req
);
1600 } else if (alg
== IW_ENCODE_ALG_WEP
) {
1601 u16 is_default
= 0, index
, set_tx_key
= 0;
1603 ret
= validate_key_index(assoc_req
->wep_tx_keyidx
,
1604 (dwrq
->flags
& IW_ENCODE_INDEX
),
1605 &index
, &is_default
);
1609 /* If WEP isn't enabled, or if there is no key data but a valid
1610 * index, or if the set-TX-key flag was passed, set the TX key.
1612 if ( !assoc_req
->secinfo
.wep_enabled
1613 || (dwrq
->length
== 0 && !is_default
)
1614 || (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
))
1617 /* Copy key to driver */
1618 ret
= lbs_set_wep_key(assoc_req
, ext
->key
, ext
->key_len
, index
,
1623 if (dwrq
->flags
& IW_ENCODE_RESTRICTED
) {
1624 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_SHARED_KEY
;
1625 } else if (dwrq
->flags
& IW_ENCODE_OPEN
) {
1626 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1629 /* Mark the various WEP bits as modified */
1630 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1632 set_bit(ASSOC_FLAG_WEP_KEYS
, &assoc_req
->flags
);
1634 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX
, &assoc_req
->flags
);
1635 } else if ((alg
== IW_ENCODE_ALG_TKIP
) || (alg
== IW_ENCODE_ALG_CCMP
)) {
1636 struct enc_key
* pkey
;
1638 /* validate key length */
1639 if (((alg
== IW_ENCODE_ALG_TKIP
)
1640 && (ext
->key_len
!= KEY_LEN_WPA_TKIP
))
1641 || ((alg
== IW_ENCODE_ALG_CCMP
)
1642 && (ext
->key_len
!= KEY_LEN_WPA_AES
))) {
1643 lbs_deb_wext("invalid size %d for key of alg "
1651 if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) {
1652 pkey
= &assoc_req
->wpa_mcast_key
;
1653 set_bit(ASSOC_FLAG_WPA_MCAST_KEY
, &assoc_req
->flags
);
1655 pkey
= &assoc_req
->wpa_unicast_key
;
1656 set_bit(ASSOC_FLAG_WPA_UCAST_KEY
, &assoc_req
->flags
);
1659 memset(pkey
, 0, sizeof (struct enc_key
));
1660 memcpy(pkey
->key
, ext
->key
, ext
->key_len
);
1661 pkey
->len
= ext
->key_len
;
1663 pkey
->flags
|= KEY_INFO_WPA_ENABLED
;
1665 /* Do this after zeroing key structure */
1666 if (ext
->ext_flags
& IW_ENCODE_EXT_GROUP_KEY
) {
1667 pkey
->flags
|= KEY_INFO_WPA_MCAST
;
1669 pkey
->flags
|= KEY_INFO_WPA_UNICAST
;
1672 if (alg
== IW_ENCODE_ALG_TKIP
) {
1673 pkey
->type
= KEY_TYPE_ID_TKIP
;
1674 } else if (alg
== IW_ENCODE_ALG_CCMP
) {
1675 pkey
->type
= KEY_TYPE_ID_AES
;
1678 /* If WPA isn't enabled yet, do that now */
1679 if ( assoc_req
->secinfo
.WPAenabled
== 0
1680 && assoc_req
->secinfo
.WPA2enabled
== 0) {
1681 assoc_req
->secinfo
.WPAenabled
= 1;
1682 assoc_req
->secinfo
.WPA2enabled
= 1;
1683 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1686 /* Only disable wep if necessary: can't waste time here. */
1687 if (priv
->mac_control
& CMD_ACT_MAC_WEP_ENABLE
)
1688 disable_wep(assoc_req
);
1693 /* 802.1x and WPA rekeying must happen as quickly as possible,
1694 * especially during the 4-way handshake; thus if in
1695 * infrastructure mode, and either (a) 802.1x is enabled or
1696 * (b) WPA is being used, set the key right away.
1698 if (assoc_req
->mode
== IW_MODE_INFRA
&&
1699 ((assoc_req
->secinfo
.key_mgmt
& IW_AUTH_KEY_MGMT_802_1X
) ||
1700 (assoc_req
->secinfo
.key_mgmt
& IW_AUTH_KEY_MGMT_PSK
) ||
1701 assoc_req
->secinfo
.WPAenabled
||
1702 assoc_req
->secinfo
.WPA2enabled
)) {
1703 lbs_do_association_work(priv
);
1705 lbs_postpone_association_work(priv
);
1707 lbs_cancel_association_work(priv
);
1709 mutex_unlock(&priv
->lock
);
1711 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1716 static int lbs_set_genie(struct net_device
*dev
,
1717 struct iw_request_info
*info
,
1718 struct iw_point
*dwrq
,
1721 struct lbs_private
*priv
= dev
->ml_priv
;
1723 struct assoc_request
* assoc_req
;
1725 lbs_deb_enter(LBS_DEB_WEXT
);
1727 mutex_lock(&priv
->lock
);
1728 assoc_req
= lbs_get_association_request(priv
);
1734 if (dwrq
->length
> MAX_WPA_IE_LEN
||
1735 (dwrq
->length
&& extra
== NULL
)) {
1741 memcpy(&assoc_req
->wpa_ie
[0], extra
, dwrq
->length
);
1742 assoc_req
->wpa_ie_len
= dwrq
->length
;
1744 memset(&assoc_req
->wpa_ie
[0], 0, sizeof(priv
->wpa_ie
));
1745 assoc_req
->wpa_ie_len
= 0;
1750 set_bit(ASSOC_FLAG_WPA_IE
, &assoc_req
->flags
);
1751 lbs_postpone_association_work(priv
);
1753 lbs_cancel_association_work(priv
);
1755 mutex_unlock(&priv
->lock
);
1757 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1761 static int lbs_get_genie(struct net_device
*dev
,
1762 struct iw_request_info
*info
,
1763 struct iw_point
*dwrq
,
1767 struct lbs_private
*priv
= dev
->ml_priv
;
1769 lbs_deb_enter(LBS_DEB_WEXT
);
1771 if (priv
->wpa_ie_len
== 0) {
1776 if (dwrq
->length
< priv
->wpa_ie_len
) {
1781 dwrq
->length
= priv
->wpa_ie_len
;
1782 memcpy(extra
, &priv
->wpa_ie
[0], priv
->wpa_ie_len
);
1785 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1790 static int lbs_set_auth(struct net_device
*dev
,
1791 struct iw_request_info
*info
,
1792 struct iw_param
*dwrq
,
1795 struct lbs_private
*priv
= dev
->ml_priv
;
1796 struct assoc_request
* assoc_req
;
1800 lbs_deb_enter(LBS_DEB_WEXT
);
1802 mutex_lock(&priv
->lock
);
1803 assoc_req
= lbs_get_association_request(priv
);
1809 switch (dwrq
->flags
& IW_AUTH_INDEX
) {
1810 case IW_AUTH_PRIVACY_INVOKED
:
1811 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1812 case IW_AUTH_TKIP_COUNTERMEASURES
:
1813 case IW_AUTH_CIPHER_PAIRWISE
:
1814 case IW_AUTH_CIPHER_GROUP
:
1815 case IW_AUTH_DROP_UNENCRYPTED
:
1817 * libertas does not use these parameters
1821 case IW_AUTH_KEY_MGMT
:
1822 assoc_req
->secinfo
.key_mgmt
= dwrq
->value
;
1826 case IW_AUTH_WPA_VERSION
:
1827 if (dwrq
->value
& IW_AUTH_WPA_VERSION_DISABLED
) {
1828 assoc_req
->secinfo
.WPAenabled
= 0;
1829 assoc_req
->secinfo
.WPA2enabled
= 0;
1830 disable_wpa (assoc_req
);
1832 if (dwrq
->value
& IW_AUTH_WPA_VERSION_WPA
) {
1833 assoc_req
->secinfo
.WPAenabled
= 1;
1834 assoc_req
->secinfo
.wep_enabled
= 0;
1835 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1837 if (dwrq
->value
& IW_AUTH_WPA_VERSION_WPA2
) {
1838 assoc_req
->secinfo
.WPA2enabled
= 1;
1839 assoc_req
->secinfo
.wep_enabled
= 0;
1840 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1845 case IW_AUTH_80211_AUTH_ALG
:
1846 if (dwrq
->value
& IW_AUTH_ALG_SHARED_KEY
) {
1847 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_SHARED_KEY
;
1848 } else if (dwrq
->value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
1849 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1850 } else if (dwrq
->value
& IW_AUTH_ALG_LEAP
) {
1851 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_LEAP
;
1858 case IW_AUTH_WPA_ENABLED
:
1860 if (!assoc_req
->secinfo
.WPAenabled
&&
1861 !assoc_req
->secinfo
.WPA2enabled
) {
1862 assoc_req
->secinfo
.WPAenabled
= 1;
1863 assoc_req
->secinfo
.WPA2enabled
= 1;
1864 assoc_req
->secinfo
.wep_enabled
= 0;
1865 assoc_req
->secinfo
.auth_mode
= IW_AUTH_ALG_OPEN_SYSTEM
;
1868 assoc_req
->secinfo
.WPAenabled
= 0;
1869 assoc_req
->secinfo
.WPA2enabled
= 0;
1870 disable_wpa (assoc_req
);
1883 set_bit(ASSOC_FLAG_SECINFO
, &assoc_req
->flags
);
1884 lbs_postpone_association_work(priv
);
1885 } else if (ret
!= -EOPNOTSUPP
) {
1886 lbs_cancel_association_work(priv
);
1888 mutex_unlock(&priv
->lock
);
1890 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1894 static int lbs_get_auth(struct net_device
*dev
,
1895 struct iw_request_info
*info
,
1896 struct iw_param
*dwrq
,
1900 struct lbs_private
*priv
= dev
->ml_priv
;
1902 lbs_deb_enter(LBS_DEB_WEXT
);
1904 switch (dwrq
->flags
& IW_AUTH_INDEX
) {
1905 case IW_AUTH_KEY_MGMT
:
1906 dwrq
->value
= priv
->secinfo
.key_mgmt
;
1909 case IW_AUTH_WPA_VERSION
:
1911 if (priv
->secinfo
.WPAenabled
)
1912 dwrq
->value
|= IW_AUTH_WPA_VERSION_WPA
;
1913 if (priv
->secinfo
.WPA2enabled
)
1914 dwrq
->value
|= IW_AUTH_WPA_VERSION_WPA2
;
1916 dwrq
->value
|= IW_AUTH_WPA_VERSION_DISABLED
;
1919 case IW_AUTH_80211_AUTH_ALG
:
1920 dwrq
->value
= priv
->secinfo
.auth_mode
;
1923 case IW_AUTH_WPA_ENABLED
:
1924 if (priv
->secinfo
.WPAenabled
&& priv
->secinfo
.WPA2enabled
)
1932 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
1937 static int lbs_set_txpow(struct net_device
*dev
, struct iw_request_info
*info
,
1938 struct iw_param
*vwrq
, char *extra
)
1941 struct lbs_private
*priv
= dev
->ml_priv
;
1942 s16 dbm
= (s16
) vwrq
->value
;
1944 lbs_deb_enter(LBS_DEB_WEXT
);
1946 if (vwrq
->disabled
) {
1947 lbs_set_radio(priv
, RADIO_PREAMBLE_AUTO
, 0);
1951 if (vwrq
->fixed
== 0) {
1952 /* User requests automatic tx power control, however there are
1953 * many auto tx settings. For now use firmware defaults until
1954 * we come up with a good way to expose these to the user. */
1955 if (priv
->fwrelease
< 0x09000000) {
1956 ret
= lbs_set_power_adapt_cfg(priv
, 1,
1957 POW_ADAPT_DEFAULT_P0
,
1958 POW_ADAPT_DEFAULT_P1
,
1959 POW_ADAPT_DEFAULT_P2
);
1963 ret
= lbs_set_tpc_cfg(priv
, 0, TPC_DEFAULT_P0
, TPC_DEFAULT_P1
,
1967 dbm
= priv
->txpower_max
;
1969 /* Userspace check in iwrange if it should use dBm or mW,
1970 * therefore this should never happen... Jean II */
1971 if ((vwrq
->flags
& IW_TXPOW_TYPE
) != IW_TXPOW_DBM
) {
1976 /* Validate requested power level against firmware allowed
1978 if (priv
->txpower_min
&& (dbm
< priv
->txpower_min
)) {
1983 if (priv
->txpower_max
&& (dbm
> priv
->txpower_max
)) {
1987 if (priv
->fwrelease
< 0x09000000) {
1988 ret
= lbs_set_power_adapt_cfg(priv
, 0,
1989 POW_ADAPT_DEFAULT_P0
,
1990 POW_ADAPT_DEFAULT_P1
,
1991 POW_ADAPT_DEFAULT_P2
);
1995 ret
= lbs_set_tpc_cfg(priv
, 0, TPC_DEFAULT_P0
, TPC_DEFAULT_P1
,
2001 /* If the radio was off, turn it on */
2002 if (!priv
->radio_on
) {
2003 ret
= lbs_set_radio(priv
, RADIO_PREAMBLE_AUTO
, 1);
2008 lbs_deb_wext("txpower set %d dBm\n", dbm
);
2010 ret
= lbs_set_tx_power(priv
, dbm
);
2013 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
2017 static int lbs_get_essid(struct net_device
*dev
, struct iw_request_info
*info
,
2018 struct iw_point
*dwrq
, char *extra
)
2020 struct lbs_private
*priv
= dev
->ml_priv
;
2022 lbs_deb_enter(LBS_DEB_WEXT
);
2025 * Note : if dwrq->flags != 0, we should get the relevant SSID from
2030 * Get the current SSID
2032 if (priv
->connect_status
== LBS_CONNECTED
) {
2033 memcpy(extra
, priv
->curbssparams
.ssid
,
2034 priv
->curbssparams
.ssid_len
);
2036 memset(extra
, 0, 32);
2039 * If none, we may want to get the one that was set
2042 dwrq
->length
= priv
->curbssparams
.ssid_len
;
2044 dwrq
->flags
= 1; /* active */
2046 lbs_deb_leave(LBS_DEB_WEXT
);
2050 static int lbs_set_essid(struct net_device
*dev
, struct iw_request_info
*info
,
2051 struct iw_point
*dwrq
, char *extra
)
2053 struct lbs_private
*priv
= dev
->ml_priv
;
2055 u8 ssid
[IEEE80211_MAX_SSID_LEN
];
2057 struct assoc_request
* assoc_req
;
2058 int in_ssid_len
= dwrq
->length
;
2059 DECLARE_SSID_BUF(ssid_buf
);
2061 lbs_deb_enter(LBS_DEB_WEXT
);
2063 if (!priv
->radio_on
) {
2068 /* Check the size of the string */
2069 if (in_ssid_len
> IEEE80211_MAX_SSID_LEN
) {
2074 memset(&ssid
, 0, sizeof(ssid
));
2076 if (!dwrq
->flags
|| !in_ssid_len
) {
2077 /* "any" SSID requested; leave SSID blank */
2079 /* Specific SSID requested */
2080 memcpy(&ssid
, extra
, in_ssid_len
);
2081 ssid_len
= in_ssid_len
;
2085 lbs_deb_wext("requested any SSID\n");
2087 lbs_deb_wext("requested SSID '%s'\n",
2088 print_ssid(ssid_buf
, ssid
, ssid_len
));
2092 mutex_lock(&priv
->lock
);
2094 /* Get or create the current association request */
2095 assoc_req
= lbs_get_association_request(priv
);
2099 /* Copy the SSID to the association request */
2100 memcpy(&assoc_req
->ssid
, &ssid
, IEEE80211_MAX_SSID_LEN
);
2101 assoc_req
->ssid_len
= ssid_len
;
2102 set_bit(ASSOC_FLAG_SSID
, &assoc_req
->flags
);
2103 lbs_postpone_association_work(priv
);
2107 /* Cancel the association request if there was an error */
2109 lbs_cancel_association_work(priv
);
2112 mutex_unlock(&priv
->lock
);
2114 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
2118 #ifdef CONFIG_LIBERTAS_MESH
2119 static int lbs_mesh_get_essid(struct net_device
*dev
,
2120 struct iw_request_info
*info
,
2121 struct iw_point
*dwrq
, char *extra
)
2123 struct lbs_private
*priv
= dev
->ml_priv
;
2125 lbs_deb_enter(LBS_DEB_WEXT
);
2127 memcpy(extra
, priv
->mesh_ssid
, priv
->mesh_ssid_len
);
2129 dwrq
->length
= priv
->mesh_ssid_len
;
2131 dwrq
->flags
= 1; /* active */
2133 lbs_deb_leave(LBS_DEB_WEXT
);
2137 static int lbs_mesh_set_essid(struct net_device
*dev
,
2138 struct iw_request_info
*info
,
2139 struct iw_point
*dwrq
, char *extra
)
2141 struct lbs_private
*priv
= dev
->ml_priv
;
2144 lbs_deb_enter(LBS_DEB_WEXT
);
2146 if (!priv
->radio_on
) {
2151 /* Check the size of the string */
2152 if (dwrq
->length
> IEEE80211_MAX_SSID_LEN
) {
2157 if (!dwrq
->flags
|| !dwrq
->length
) {
2161 /* Specific SSID requested */
2162 memcpy(priv
->mesh_ssid
, extra
, dwrq
->length
);
2163 priv
->mesh_ssid_len
= dwrq
->length
;
2166 lbs_mesh_config(priv
, CMD_ACT_MESH_CONFIG_START
,
2169 lbs_deb_leave_args(LBS_DEB_WEXT
, "ret %d", ret
);
2175 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2177 * @param dev A pointer to net_device structure
2178 * @param info A pointer to iw_request_info structure
2179 * @param awrq A pointer to iw_param structure
2180 * @param extra A pointer to extra data buf
2181 * @return 0 --success, otherwise fail
2183 static int lbs_set_wap(struct net_device
*dev
, struct iw_request_info
*info
,
2184 struct sockaddr
*awrq
, char *extra
)
2186 struct lbs_private
*priv
= dev
->ml_priv
;
2187 struct assoc_request
* assoc_req
;
2190 lbs_deb_enter(LBS_DEB_WEXT
);
2192 if (!priv
->radio_on
)
2195 if (awrq
->sa_family
!= ARPHRD_ETHER
)
2198 lbs_deb_wext("ASSOC: WAP: sa_data %pM\n", awrq
->sa_data
);
2200 mutex_lock(&priv
->lock
);
2202 /* Get or create the current association request */
2203 assoc_req
= lbs_get_association_request(priv
);
2205 lbs_cancel_association_work(priv
);
2208 /* Copy the BSSID to the association request */
2209 memcpy(&assoc_req
->bssid
, awrq
->sa_data
, ETH_ALEN
);
2210 set_bit(ASSOC_FLAG_BSSID
, &assoc_req
->flags
);
2211 lbs_postpone_association_work(priv
);
2214 mutex_unlock(&priv
->lock
);
2220 * iwconfig settable callbacks
2222 static const iw_handler lbs_handler
[] = {
2223 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
2224 (iw_handler
) lbs_get_name
, /* SIOCGIWNAME */
2225 (iw_handler
) NULL
, /* SIOCSIWNWID */
2226 (iw_handler
) NULL
, /* SIOCGIWNWID */
2227 (iw_handler
) lbs_set_freq
, /* SIOCSIWFREQ */
2228 (iw_handler
) lbs_get_freq
, /* SIOCGIWFREQ */
2229 (iw_handler
) lbs_set_mode
, /* SIOCSIWMODE */
2230 (iw_handler
) lbs_get_mode
, /* SIOCGIWMODE */
2231 (iw_handler
) NULL
, /* SIOCSIWSENS */
2232 (iw_handler
) NULL
, /* SIOCGIWSENS */
2233 (iw_handler
) NULL
, /* SIOCSIWRANGE */
2234 (iw_handler
) lbs_get_range
, /* SIOCGIWRANGE */
2235 (iw_handler
) NULL
, /* SIOCSIWPRIV */
2236 (iw_handler
) NULL
, /* SIOCGIWPRIV */
2237 (iw_handler
) NULL
, /* SIOCSIWSTATS */
2238 (iw_handler
) NULL
, /* SIOCGIWSTATS */
2239 iw_handler_set_spy
, /* SIOCSIWSPY */
2240 iw_handler_get_spy
, /* SIOCGIWSPY */
2241 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
2242 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
2243 (iw_handler
) lbs_set_wap
, /* SIOCSIWAP */
2244 (iw_handler
) lbs_get_wap
, /* SIOCGIWAP */
2245 (iw_handler
) NULL
, /* SIOCSIWMLME */
2246 (iw_handler
) NULL
, /* SIOCGIWAPLIST - deprecated */
2247 (iw_handler
) lbs_set_scan
, /* SIOCSIWSCAN */
2248 (iw_handler
) lbs_get_scan
, /* SIOCGIWSCAN */
2249 (iw_handler
) lbs_set_essid
, /* SIOCSIWESSID */
2250 (iw_handler
) lbs_get_essid
, /* SIOCGIWESSID */
2251 (iw_handler
) lbs_set_nick
, /* SIOCSIWNICKN */
2252 (iw_handler
) lbs_get_nick
, /* SIOCGIWNICKN */
2253 (iw_handler
) NULL
, /* -- hole -- */
2254 (iw_handler
) NULL
, /* -- hole -- */
2255 (iw_handler
) lbs_set_rate
, /* SIOCSIWRATE */
2256 (iw_handler
) lbs_get_rate
, /* SIOCGIWRATE */
2257 (iw_handler
) lbs_set_rts
, /* SIOCSIWRTS */
2258 (iw_handler
) lbs_get_rts
, /* SIOCGIWRTS */
2259 (iw_handler
) lbs_set_frag
, /* SIOCSIWFRAG */
2260 (iw_handler
) lbs_get_frag
, /* SIOCGIWFRAG */
2261 (iw_handler
) lbs_set_txpow
, /* SIOCSIWTXPOW */
2262 (iw_handler
) lbs_get_txpow
, /* SIOCGIWTXPOW */
2263 (iw_handler
) lbs_set_retry
, /* SIOCSIWRETRY */
2264 (iw_handler
) lbs_get_retry
, /* SIOCGIWRETRY */
2265 (iw_handler
) lbs_set_encode
, /* SIOCSIWENCODE */
2266 (iw_handler
) lbs_get_encode
, /* SIOCGIWENCODE */
2267 (iw_handler
) lbs_set_power
, /* SIOCSIWPOWER */
2268 (iw_handler
) lbs_get_power
, /* SIOCGIWPOWER */
2269 (iw_handler
) NULL
, /* -- hole -- */
2270 (iw_handler
) NULL
, /* -- hole -- */
2271 (iw_handler
) lbs_set_genie
, /* SIOCSIWGENIE */
2272 (iw_handler
) lbs_get_genie
, /* SIOCGIWGENIE */
2273 (iw_handler
) lbs_set_auth
, /* SIOCSIWAUTH */
2274 (iw_handler
) lbs_get_auth
, /* SIOCGIWAUTH */
2275 (iw_handler
) lbs_set_encodeext
,/* SIOCSIWENCODEEXT */
2276 (iw_handler
) lbs_get_encodeext
,/* SIOCGIWENCODEEXT */
2277 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
2279 struct iw_handler_def lbs_handler_def
= {
2280 .num_standard
= ARRAY_SIZE(lbs_handler
),
2281 .standard
= (iw_handler
*) lbs_handler
,
2282 .get_wireless_stats
= lbs_get_wireless_stats
,
2285 #ifdef CONFIG_LIBERTAS_MESH
2286 static const iw_handler mesh_wlan_handler
[] = {
2287 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
2288 (iw_handler
) lbs_get_name
, /* SIOCGIWNAME */
2289 (iw_handler
) NULL
, /* SIOCSIWNWID */
2290 (iw_handler
) NULL
, /* SIOCGIWNWID */
2291 (iw_handler
) lbs_mesh_set_freq
, /* SIOCSIWFREQ */
2292 (iw_handler
) lbs_get_freq
, /* SIOCGIWFREQ */
2293 (iw_handler
) NULL
, /* SIOCSIWMODE */
2294 (iw_handler
) mesh_wlan_get_mode
, /* SIOCGIWMODE */
2295 (iw_handler
) NULL
, /* SIOCSIWSENS */
2296 (iw_handler
) NULL
, /* SIOCGIWSENS */
2297 (iw_handler
) NULL
, /* SIOCSIWRANGE */
2298 (iw_handler
) lbs_get_range
, /* SIOCGIWRANGE */
2299 (iw_handler
) NULL
, /* SIOCSIWPRIV */
2300 (iw_handler
) NULL
, /* SIOCGIWPRIV */
2301 (iw_handler
) NULL
, /* SIOCSIWSTATS */
2302 (iw_handler
) NULL
, /* SIOCGIWSTATS */
2303 iw_handler_set_spy
, /* SIOCSIWSPY */
2304 iw_handler_get_spy
, /* SIOCGIWSPY */
2305 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
2306 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
2307 (iw_handler
) NULL
, /* SIOCSIWAP */
2308 (iw_handler
) NULL
, /* SIOCGIWAP */
2309 (iw_handler
) NULL
, /* SIOCSIWMLME */
2310 (iw_handler
) NULL
, /* SIOCGIWAPLIST - deprecated */
2311 (iw_handler
) lbs_set_scan
, /* SIOCSIWSCAN */
2312 (iw_handler
) lbs_get_scan
, /* SIOCGIWSCAN */
2313 (iw_handler
) lbs_mesh_set_essid
,/* SIOCSIWESSID */
2314 (iw_handler
) lbs_mesh_get_essid
,/* SIOCGIWESSID */
2315 (iw_handler
) NULL
, /* SIOCSIWNICKN */
2316 (iw_handler
) mesh_get_nick
, /* SIOCGIWNICKN */
2317 (iw_handler
) NULL
, /* -- hole -- */
2318 (iw_handler
) NULL
, /* -- hole -- */
2319 (iw_handler
) lbs_set_rate
, /* SIOCSIWRATE */
2320 (iw_handler
) lbs_get_rate
, /* SIOCGIWRATE */
2321 (iw_handler
) lbs_set_rts
, /* SIOCSIWRTS */
2322 (iw_handler
) lbs_get_rts
, /* SIOCGIWRTS */
2323 (iw_handler
) lbs_set_frag
, /* SIOCSIWFRAG */
2324 (iw_handler
) lbs_get_frag
, /* SIOCGIWFRAG */
2325 (iw_handler
) lbs_set_txpow
, /* SIOCSIWTXPOW */
2326 (iw_handler
) lbs_get_txpow
, /* SIOCGIWTXPOW */
2327 (iw_handler
) lbs_set_retry
, /* SIOCSIWRETRY */
2328 (iw_handler
) lbs_get_retry
, /* SIOCGIWRETRY */
2329 (iw_handler
) lbs_set_encode
, /* SIOCSIWENCODE */
2330 (iw_handler
) lbs_get_encode
, /* SIOCGIWENCODE */
2331 (iw_handler
) lbs_set_power
, /* SIOCSIWPOWER */
2332 (iw_handler
) lbs_get_power
, /* SIOCGIWPOWER */
2333 (iw_handler
) NULL
, /* -- hole -- */
2334 (iw_handler
) NULL
, /* -- hole -- */
2335 (iw_handler
) lbs_set_genie
, /* SIOCSIWGENIE */
2336 (iw_handler
) lbs_get_genie
, /* SIOCGIWGENIE */
2337 (iw_handler
) lbs_set_auth
, /* SIOCSIWAUTH */
2338 (iw_handler
) lbs_get_auth
, /* SIOCGIWAUTH */
2339 (iw_handler
) lbs_set_encodeext
,/* SIOCSIWENCODEEXT */
2340 (iw_handler
) lbs_get_encodeext
,/* SIOCGIWENCODEEXT */
2341 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
2344 struct iw_handler_def mesh_handler_def
= {
2345 .num_standard
= ARRAY_SIZE(mesh_wlan_handler
),
2346 .standard
= (iw_handler
*) mesh_wlan_handler
,
2347 .get_wireless_stats
= lbs_get_wireless_stats
,