2 * This file contains ioctl functions
4 #include <linux/ctype.h>
5 #include <linux/delay.h>
7 #include <linux/if_arp.h>
8 #include <linux/wireless.h>
9 #include <linux/bitops.h>
11 #include <net/ieee80211.h>
12 #include <net/iw_handler.h>
26 * @brief Convert mw value to dbm value
28 * @param mw the value of mw
29 * @return the value of dbm
31 static int mw_to_dbm(int mw)
72 * @brief Find the channel frequency power info with specific channel
74 * @param adapter A pointer to wlan_adapter structure
75 * @param band it can be BAND_A, BAND_G or BAND_B
76 * @param channel the channel for looking
77 * @return A pointer to struct chan_freq_power structure or NULL if not find.
79 struct chan_freq_power *libertas_find_cfp_by_band_and_channel(wlan_adapter * adapter,
82 struct chan_freq_power *cfp = NULL;
83 struct region_channel *rc;
84 int count = sizeof(adapter->region_channel) /
85 sizeof(adapter->region_channel[0]);
88 for (j = 0; !cfp && (j < count); j++) {
89 rc = &adapter->region_channel[j];
91 if (adapter->enable11d)
92 rc = &adapter->universal_channel[j];
93 if (!rc->valid || !rc->CFP)
97 for (i = 0; i < rc->nrcfp; i++) {
98 if (rc->CFP[i].channel == channel) {
106 lbs_pr_debug(1, "libertas_find_cfp_by_band_and_channel(): cannot find "
107 "cfp by band %d & channel %d\n", band, channel);
113 * @brief Find the channel frequency power info with specific frequency
115 * @param adapter A pointer to wlan_adapter structure
116 * @param band it can be BAND_A, BAND_G or BAND_B
117 * @param freq the frequency for looking
118 * @return A pointer to struct chan_freq_power structure or NULL if not find.
120 static struct chan_freq_power *find_cfp_by_band_and_freq(wlan_adapter * adapter,
123 struct chan_freq_power *cfp = NULL;
124 struct region_channel *rc;
125 int count = sizeof(adapter->region_channel) /
126 sizeof(adapter->region_channel[0]);
129 for (j = 0; !cfp && (j < count); j++) {
130 rc = &adapter->region_channel[j];
132 if (adapter->enable11d)
133 rc = &adapter->universal_channel[j];
134 if (!rc->valid || !rc->CFP)
136 if (rc->band != band)
138 for (i = 0; i < rc->nrcfp; i++) {
139 if (rc->CFP[i].freq == freq) {
147 lbs_pr_debug(1, "find_cfp_by_band_and_freql(): cannot find cfp by "
148 "band %d & freq %d\n", band, freq);
153 static int updatecurrentchannel(wlan_private * priv)
158 ** the channel in f/w could be out of sync, get the current channel
160 ret = libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel,
161 cmd_opt_802_11_rf_channel_get,
162 cmd_option_waitforrsp, 0, NULL);
164 lbs_pr_debug(1, "Current channel = %d\n",
165 priv->adapter->curbssparams.channel);
170 static int setcurrentchannel(wlan_private * priv, int channel)
172 lbs_pr_debug(1, "Set channel = %d\n", channel);
175 ** Current channel is not set to adhocchannel requested, set channel
177 return (libertas_prepare_and_send_command(priv, cmd_802_11_rf_channel,
178 cmd_opt_802_11_rf_channel_set,
179 cmd_option_waitforrsp, 0, &channel));
182 static int changeadhocchannel(wlan_private * priv, int channel)
185 wlan_adapter *adapter = priv->adapter;
187 adapter->adhocchannel = channel;
189 updatecurrentchannel(priv);
191 if (adapter->curbssparams.channel == adapter->adhocchannel) {
192 /* adhocchannel is set to the current channel already */
197 lbs_pr_debug(1, "Updating channel from %d to %d\n",
198 adapter->curbssparams.channel, adapter->adhocchannel);
200 setcurrentchannel(priv, adapter->adhocchannel);
202 updatecurrentchannel(priv);
204 if (adapter->curbssparams.channel != adapter->adhocchannel) {
205 lbs_pr_debug(1, "failed to updated channel to %d, channel = %d\n",
206 adapter->adhocchannel, adapter->curbssparams.channel);
211 if (adapter->connect_status == libertas_connected) {
213 struct WLAN_802_11_SSID curadhocssid;
215 lbs_pr_debug(1, "channel Changed while in an IBSS\n");
217 /* Copy the current ssid */
218 memcpy(&curadhocssid, &adapter->curbssparams.ssid,
219 sizeof(struct WLAN_802_11_SSID));
221 /* Exit Adhoc mode */
222 lbs_pr_debug(1, "In changeadhocchannel(): Sending Adhoc Stop\n");
223 ret = libertas_stop_adhoc_network(priv);
229 /* Scan for the network, do not save previous results. Stale
230 * scan data will cause us to join a non-existant adhoc network
232 libertas_send_specific_SSID_scan(priv, &curadhocssid, 0);
234 // find out the BSSID that matches the current SSID
235 i = libertas_find_SSID_in_list(adapter, &curadhocssid, NULL,
239 lbs_pr_debug(1, "SSID found at %d in List,"
241 libertas_join_adhoc_network(priv, &adapter->scantable[i]);
243 // else send START command
244 lbs_pr_debug(1, "SSID not found in list, "
245 "so creating adhoc with ssid = %s\n",
247 libertas_start_adhoc_network(priv, &curadhocssid);
248 } // end of else (START command)
256 * @brief Set Radio On/OFF
258 * @param priv A pointer to wlan_private structure
259 * @option Radio Option
260 * @return 0 --success, otherwise fail
262 int wlan_radio_ioctl(wlan_private * priv, u8 option)
265 wlan_adapter *adapter = priv->adapter;
269 if (adapter->radioon != option) {
270 lbs_pr_debug(1, "Switching %s the Radio\n", option ? "On" : "Off");
271 adapter->radioon = option;
273 ret = libertas_prepare_and_send_command(priv,
274 cmd_802_11_radio_control,
276 cmd_option_waitforrsp, 0, NULL);
286 * @param dest A pointer to Dest Buf
287 * @param src A pointer to Src Buf
288 * @param len The len of Src Buf
289 * @return Number of rates copyed
291 static inline int copyrates(u8 * dest, int pos, u8 * src, int len)
295 for (i = 0; i < len && src[i]; i++, pos++) {
296 if (pos >= sizeof(u8) * WLAN_SUPPORTED_RATES)
305 * @brief Get active data rates
307 * @param adapter A pointer to wlan_adapter structure
308 * @param rate The buf to return the active rates
309 * @return The number of rates
311 static int get_active_data_rates(wlan_adapter * adapter,
318 if (adapter->connect_status != libertas_connected) {
319 if (adapter->inframode == wlan802_11infrastructure) {
321 lbs_pr_debug(1, "Infra\n");
322 k = copyrates(rates, k, libertas_supported_rates,
323 sizeof(libertas_supported_rates));
326 lbs_pr_debug(1, "Adhoc G\n");
327 k = copyrates(rates, k, libertas_adhoc_rates_g,
328 sizeof(libertas_adhoc_rates_g));
331 k = copyrates(rates, 0, adapter->curbssparams.datarates,
332 adapter->curbssparams.numofrates);
340 static int wlan_get_name(struct net_device *dev, struct iw_request_info *info,
341 char *cwrq, char *extra)
344 char comm[6] = { "COMM-" };
345 char mrvl[6] = { "MRVL-" };
352 cp = strstr(libertas_driver_version, comm);
353 if (cp == libertas_driver_version) //skip leading "COMM-"
354 cp = libertas_driver_version + strlen(comm);
356 cp = libertas_driver_version;
360 while (cnt < 16 && (*cp != '-')) {
361 *cwrq++ = toupper(*cp++);
371 static int wlan_get_freq(struct net_device *dev, struct iw_request_info *info,
372 struct iw_freq *fwrq, char *extra)
374 wlan_private *priv = dev->priv;
375 wlan_adapter *adapter = priv->adapter;
376 struct chan_freq_power *cfp;
380 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0,
381 adapter->curbssparams.channel);
384 if (adapter->curbssparams.channel)
385 lbs_pr_debug(1, "Invalid channel=%d\n",
386 adapter->curbssparams.channel);
390 fwrq->m = (long)cfp->freq * 100000;
393 lbs_pr_debug(1, "freq=%u\n", fwrq->m);
399 static int wlan_get_wap(struct net_device *dev, struct iw_request_info *info,
400 struct sockaddr *awrq, char *extra)
402 wlan_private *priv = dev->priv;
403 wlan_adapter *adapter = priv->adapter;
407 if (adapter->connect_status == libertas_connected) {
408 memcpy(awrq->sa_data, adapter->curbssparams.bssid, ETH_ALEN);
410 memset(awrq->sa_data, 0, ETH_ALEN);
412 awrq->sa_family = ARPHRD_ETHER;
418 static int wlan_set_nick(struct net_device *dev, struct iw_request_info *info,
419 struct iw_point *dwrq, char *extra)
421 wlan_private *priv = dev->priv;
422 wlan_adapter *adapter = priv->adapter;
427 * Check the size of the string
430 if (dwrq->length > 16) {
434 mutex_lock(&adapter->lock);
435 memset(adapter->nodename, 0, sizeof(adapter->nodename));
436 memcpy(adapter->nodename, extra, dwrq->length);
437 mutex_unlock(&adapter->lock);
443 static int wlan_get_nick(struct net_device *dev, struct iw_request_info *info,
444 struct iw_point *dwrq, char *extra)
446 wlan_private *priv = dev->priv;
447 wlan_adapter *adapter = priv->adapter;
452 * Get the Nick Name saved
455 mutex_lock(&adapter->lock);
456 strncpy(extra, adapter->nodename, 16);
457 mutex_unlock(&adapter->lock);
462 * If none, we may want to get the one that was set
468 dwrq->length = strlen(extra) + 1;
474 static int wlan_set_rts(struct net_device *dev, struct iw_request_info *info,
475 struct iw_param *vwrq, char *extra)
478 wlan_private *priv = dev->priv;
479 wlan_adapter *adapter = priv->adapter;
480 int rthr = vwrq->value;
484 if (vwrq->disabled) {
485 adapter->rtsthsd = rthr = MRVDRV_RTS_MAX_VALUE;
487 if (rthr < MRVDRV_RTS_MIN_VALUE || rthr > MRVDRV_RTS_MAX_VALUE)
489 adapter->rtsthsd = rthr;
492 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
493 cmd_act_set, cmd_option_waitforrsp,
494 OID_802_11_RTS_THRESHOLD, &rthr);
500 static int wlan_get_rts(struct net_device *dev, struct iw_request_info *info,
501 struct iw_param *vwrq, char *extra)
504 wlan_private *priv = dev->priv;
505 wlan_adapter *adapter = priv->adapter;
509 adapter->rtsthsd = 0;
510 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
511 cmd_act_get, cmd_option_waitforrsp,
512 OID_802_11_RTS_THRESHOLD, NULL);
518 vwrq->value = adapter->rtsthsd;
519 vwrq->disabled = ((vwrq->value < MRVDRV_RTS_MIN_VALUE)
520 || (vwrq->value > MRVDRV_RTS_MAX_VALUE));
527 static int wlan_set_frag(struct net_device *dev, struct iw_request_info *info,
528 struct iw_param *vwrq, char *extra)
531 int fthr = vwrq->value;
532 wlan_private *priv = dev->priv;
533 wlan_adapter *adapter = priv->adapter;
537 if (vwrq->disabled) {
538 adapter->fragthsd = fthr = MRVDRV_FRAG_MAX_VALUE;
540 if (fthr < MRVDRV_FRAG_MIN_VALUE
541 || fthr > MRVDRV_FRAG_MAX_VALUE)
543 adapter->fragthsd = fthr;
546 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
547 cmd_act_set, cmd_option_waitforrsp,
548 OID_802_11_FRAGMENTATION_THRESHOLD, &fthr);
553 static int wlan_get_frag(struct net_device *dev, struct iw_request_info *info,
554 struct iw_param *vwrq, char *extra)
557 wlan_private *priv = dev->priv;
558 wlan_adapter *adapter = priv->adapter;
562 adapter->fragthsd = 0;
563 ret = libertas_prepare_and_send_command(priv,
565 cmd_act_get, cmd_option_waitforrsp,
566 OID_802_11_FRAGMENTATION_THRESHOLD, NULL);
572 vwrq->value = adapter->fragthsd;
573 vwrq->disabled = ((vwrq->value < MRVDRV_FRAG_MIN_VALUE)
574 || (vwrq->value > MRVDRV_FRAG_MAX_VALUE));
581 static int wlan_get_mode(struct net_device *dev,
582 struct iw_request_info *info, u32 * uwrq, char *extra)
584 wlan_private *priv = dev->priv;
585 wlan_adapter *adapter = priv->adapter;
589 switch (adapter->inframode) {
591 *uwrq = IW_MODE_ADHOC;
594 case wlan802_11infrastructure:
595 *uwrq = IW_MODE_INFRA;
599 case wlan802_11autounknown:
600 *uwrq = IW_MODE_AUTO;
608 static int wlan_get_txpow(struct net_device *dev,
609 struct iw_request_info *info,
610 struct iw_param *vwrq, char *extra)
613 wlan_private *priv = dev->priv;
614 wlan_adapter *adapter = priv->adapter;
618 ret = libertas_prepare_and_send_command(priv,
619 cmd_802_11_rf_tx_power,
620 cmd_act_tx_power_opt_get,
621 cmd_option_waitforrsp, 0, NULL);
628 lbs_pr_debug(1, "TXPOWER GET %d dbm.\n", adapter->txpowerlevel);
629 vwrq->value = adapter->txpowerlevel;
631 if (adapter->radioon) {
633 vwrq->flags = IW_TXPOW_DBM;
642 static int wlan_set_retry(struct net_device *dev, struct iw_request_info *info,
643 struct iw_param *vwrq, char *extra)
646 wlan_private *priv = dev->priv;
647 wlan_adapter *adapter = priv->adapter;
651 if (vwrq->flags == IW_RETRY_LIMIT) {
652 /* The MAC has a 4-bit Total_Tx_Count register
653 Total_Tx_Count = 1 + Tx_Retry_Count */
654 #define TX_RETRY_MIN 0
655 #define TX_RETRY_MAX 14
656 if (vwrq->value < TX_RETRY_MIN || vwrq->value > TX_RETRY_MAX)
659 /* Adding 1 to convert retry count to try count */
660 adapter->txretrycount = vwrq->value + 1;
662 ret = libertas_prepare_and_send_command(priv, cmd_802_11_snmp_mib,
664 cmd_option_waitforrsp,
665 OID_802_11_TX_RETRYCOUNT, NULL);
679 static int wlan_get_retry(struct net_device *dev, struct iw_request_info *info,
680 struct iw_param *vwrq, char *extra)
682 wlan_private *priv = dev->priv;
683 wlan_adapter *adapter = priv->adapter;
687 adapter->txretrycount = 0;
688 ret = libertas_prepare_and_send_command(priv,
690 cmd_act_get, cmd_option_waitforrsp,
691 OID_802_11_TX_RETRYCOUNT, NULL);
698 vwrq->flags = IW_RETRY_LIMIT;
699 /* Subtract 1 to convert try count to retry count */
700 vwrq->value = adapter->txretrycount - 1;
707 static inline void sort_channels(struct iw_freq *freq, int num)
712 for (i = 0; i < num; i++)
713 for (j = i + 1; j < num; j++)
714 if (freq[i].i > freq[j].i) {
718 freq[i].i = freq[j].i;
719 freq[i].m = freq[j].m;
729 Infra G(12) A(8) B(4) G(12)
730 Adhoc A+B(12) A(8) B(4) B(4)
738 * @brief Get Range Info
740 * @param dev A pointer to net_device structure
741 * @param info A pointer to iw_request_info structure
742 * @param vwrq A pointer to iw_param structure
743 * @param extra A pointer to extra data buf
744 * @return 0 --success, otherwise fail
746 static int wlan_get_range(struct net_device *dev, struct iw_request_info *info,
747 struct iw_point *dwrq, char *extra)
750 wlan_private *priv = dev->priv;
751 wlan_adapter *adapter = priv->adapter;
752 struct iw_range *range = (struct iw_range *)extra;
753 struct chan_freq_power *cfp;
754 u8 rates[WLAN_SUPPORTED_RATES];
760 dwrq->length = sizeof(struct iw_range);
761 memset(range, 0, sizeof(struct iw_range));
766 memset(rates, 0, sizeof(rates));
767 range->num_bitrates = get_active_data_rates(adapter, rates);
769 for (i = 0; i < min_t(__u8, range->num_bitrates, IW_MAX_BITRATES) && rates[i];
771 range->bitrate[i] = (rates[i] & 0x7f) * 500000;
773 range->num_bitrates = i;
774 lbs_pr_debug(1, "IW_MAX_BITRATES=%d num_bitrates=%d\n", IW_MAX_BITRATES,
775 range->num_bitrates);
777 range->num_frequency = 0;
778 if (priv->adapter->enable11d &&
779 adapter->connect_status == libertas_connected) {
783 struct parsed_region_chan_11d *parsed_region_chan =
784 &adapter->parsed_region_chan;
786 if (parsed_region_chan == NULL) {
787 lbs_pr_debug(1, "11D:parsed_region_chan is NULL\n");
791 band = parsed_region_chan->band;
792 lbs_pr_debug(1, "band=%d NoOfChan=%d\n", band,
793 parsed_region_chan->nr_chan);
795 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
796 && (i < parsed_region_chan->nr_chan); i++) {
797 chan_no = parsed_region_chan->chanpwr[i].chan;
798 lbs_pr_debug(1, "chan_no=%d\n", chan_no);
799 range->freq[range->num_frequency].i = (long)chan_no;
800 range->freq[range->num_frequency].m =
801 (long)libertas_chan_2_freq(chan_no, band) * 100000;
802 range->freq[range->num_frequency].e = 1;
803 range->num_frequency++;
808 for (j = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
809 && (j < sizeof(adapter->region_channel)
810 / sizeof(adapter->region_channel[0])); j++) {
811 cfp = adapter->region_channel[j].CFP;
812 for (i = 0; (range->num_frequency < IW_MAX_FREQUENCIES)
813 && adapter->region_channel[j].valid
815 && (i < adapter->region_channel[j].nrcfp); i++) {
816 range->freq[range->num_frequency].i =
818 range->freq[range->num_frequency].m =
819 (long)cfp->freq * 100000;
820 range->freq[range->num_frequency].e = 1;
822 range->num_frequency++;
827 lbs_pr_debug(1, "IW_MAX_FREQUENCIES=%d num_frequency=%d\n",
828 IW_MAX_FREQUENCIES, range->num_frequency);
830 range->num_channels = range->num_frequency;
832 sort_channels(&range->freq[0], range->num_frequency);
835 * Set an indication of the max TCP throughput in bit/s that we can
836 * expect using this interface
839 range->throughput = 5000 * 1000;
841 range->throughput = 1500 * 1000;
843 range->min_rts = MRVDRV_RTS_MIN_VALUE;
844 range->max_rts = MRVDRV_RTS_MAX_VALUE;
845 range->min_frag = MRVDRV_FRAG_MIN_VALUE;
846 range->max_frag = MRVDRV_FRAG_MAX_VALUE;
848 range->encoding_size[0] = 5;
849 range->encoding_size[1] = 13;
850 range->num_encoding_sizes = 2;
851 range->max_encoding_tokens = 4;
853 range->min_pmp = 1000000;
854 range->max_pmp = 120000000;
855 range->min_pmt = 1000;
856 range->max_pmt = 1000000;
857 range->pmp_flags = IW_POWER_PERIOD;
858 range->pmt_flags = IW_POWER_TIMEOUT;
859 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT | IW_POWER_ALL_R;
862 * Minimum version we recommend
864 range->we_version_source = 15;
867 * Version we are compiled with
869 range->we_version_compiled = WIRELESS_EXT;
871 range->retry_capa = IW_RETRY_LIMIT;
872 range->retry_flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
874 range->min_retry = TX_RETRY_MIN;
875 range->max_retry = TX_RETRY_MAX;
878 * Set the qual, level and noise range values
880 range->max_qual.qual = 100;
881 range->max_qual.level = 0;
882 range->max_qual.noise = 0;
883 range->max_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
885 range->avg_qual.qual = 70;
886 /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
887 range->avg_qual.level = 0;
888 range->avg_qual.noise = 0;
889 range->avg_qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
891 range->sensitivity = 0;
894 * Setup the supported power level ranges
896 memset(range->txpower, 0, sizeof(range->txpower));
897 range->txpower[0] = 5;
898 range->txpower[1] = 7;
899 range->txpower[2] = 9;
900 range->txpower[3] = 11;
901 range->txpower[4] = 13;
902 range->txpower[5] = 15;
903 range->txpower[6] = 17;
904 range->txpower[7] = 19;
906 range->num_txpower = 8;
907 range->txpower_capa = IW_TXPOW_DBM;
908 range->txpower_capa |= IW_TXPOW_RANGE;
910 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
911 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
912 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
913 range->event_capa[1] = IW_EVENT_CAPA_K_1;
915 if (adapter->fwcapinfo & FW_CAPINFO_WPA) {
916 range->enc_capa = IW_ENC_CAPA_WPA
918 | IW_ENC_CAPA_CIPHER_TKIP
919 | IW_ENC_CAPA_CIPHER_CCMP;
926 static int wlan_set_power(struct net_device *dev, struct iw_request_info *info,
927 struct iw_param *vwrq, char *extra)
929 wlan_private *priv = dev->priv;
930 wlan_adapter *adapter = priv->adapter;
934 /* PS is currently supported only in Infrastructure mode
935 * Remove this check if it is to be supported in IBSS mode also
938 if (vwrq->disabled) {
939 adapter->psmode = wlan802_11powermodecam;
940 if (adapter->psstate != PS_STATE_FULL_POWER) {
941 libertas_ps_wakeup(priv, cmd_option_waitforrsp);
947 if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
949 "Setting power timeout command is not supported\n");
951 } else if ((vwrq->flags & IW_POWER_TYPE) == IW_POWER_PERIOD) {
952 lbs_pr_debug(1, "Setting power period command is not supported\n");
956 if (adapter->psmode != wlan802_11powermodecam) {
960 adapter->psmode = wlan802_11powermodemax_psp;
962 if (adapter->connect_status == libertas_connected) {
963 libertas_ps_sleep(priv, cmd_option_waitforrsp);
970 static int wlan_get_power(struct net_device *dev, struct iw_request_info *info,
971 struct iw_param *vwrq, char *extra)
973 wlan_private *priv = dev->priv;
974 wlan_adapter *adapter = priv->adapter;
979 mode = adapter->psmode;
981 if ((vwrq->disabled = (mode == wlan802_11powermodecam))
982 || adapter->connect_status == libertas_disconnected) {
994 * iwpriv settable callbacks
997 static const iw_handler wlan_private_handler[] = {
998 NULL, /* SIOCIWFIRSTPRIV */
1001 static const struct iw_priv_args wlan_private_args[] = {
1003 * { cmd, set_args, get_args, name }
1007 IW_PRIV_TYPE_CHAR | 8,
1008 IW_PRIV_TYPE_CHAR | 8,
1013 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1014 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1018 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1019 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1023 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1024 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1028 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1029 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1033 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1034 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1038 WLAN_SUBCMD_SET_PRESCAN,
1039 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1040 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1043 WLAN_SETONEINT_GETONEINT,
1044 IW_PRIV_TYPE_INT | 1,
1045 IW_PRIV_TYPE_INT | 1,
1048 WLAN_BEACON_INTERVAL,
1049 IW_PRIV_TYPE_INT | 1,
1050 IW_PRIV_TYPE_INT | 1,
1054 IW_PRIV_TYPE_INT | 1,
1055 IW_PRIV_TYPE_INT | 1,
1059 IW_PRIV_TYPE_INT | 1,
1060 IW_PRIV_TYPE_INT | 1,
1063 WLAN_NULLPKTINTERVAL,
1064 IW_PRIV_TYPE_INT | 1,
1065 IW_PRIV_TYPE_INT | 1,
1067 /* Using iwpriv sub-command feature */
1069 WLAN_SETONEINT_GETNONE, /* IOCTL: 24 */
1070 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1075 WLAN_SUBCMD_SETRXANTENNA,
1076 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1080 WLAN_SUBCMD_SETTXANTENNA,
1081 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1086 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1091 WLANSETENCRYPTIONMODE,
1092 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1098 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1102 WLAN_SET_LISTEN_INTERVAL,
1103 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1107 WLAN_SET_MULTIPLE_DTIM,
1108 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1112 WLAN_SET_ATIM_WINDOW,
1113 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1118 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1123 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1133 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1138 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1142 WLAN_SUBCMD_MESH_SET_TTL,
1143 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1147 WLAN_SETNONE_GETONEINT,
1149 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1154 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1157 WLAN_GET_LISTEN_INTERVAL,
1159 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1162 WLAN_GET_MULTIPLE_DTIM,
1164 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1169 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1174 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1179 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1184 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1192 WLAN_SUBCMD_FWT_CLEANUP,
1194 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1197 WLAN_SUBCMD_FWT_TIME,
1199 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1202 WLAN_SUBCMD_MESH_GET_TTL,
1204 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1207 WLAN_SETNONE_GETTWELVE_CHAR,
1209 IW_PRIV_TYPE_CHAR | 12,
1212 WLAN_SUBCMD_GETRXANTENNA,
1214 IW_PRIV_TYPE_CHAR | 12,
1217 WLAN_SUBCMD_GETTXANTENNA,
1219 IW_PRIV_TYPE_CHAR | 12,
1224 IW_PRIV_TYPE_CHAR | 12,
1227 WLAN_SETNONE_GETNONE,
1262 WLAN_SUBCMD_FWT_RESET,
1267 WLAN_SUBCMD_BT_RESET,
1272 WLAN_SET128CHAR_GET128CHAR,
1273 IW_PRIV_TYPE_CHAR | 128,
1274 IW_PRIV_TYPE_CHAR | 128,
1279 IW_PRIV_TYPE_CHAR | 128,
1280 IW_PRIV_TYPE_CHAR | 128,
1284 IW_PRIV_TYPE_CHAR | 128,
1285 IW_PRIV_TYPE_CHAR | 128,
1288 WLAN_SUBCMD_BT_LIST,
1289 IW_PRIV_TYPE_CHAR | 128,
1290 IW_PRIV_TYPE_CHAR | 128,
1292 /* FWT Management */
1294 WLAN_SUBCMD_FWT_ADD,
1295 IW_PRIV_TYPE_CHAR | 128,
1296 IW_PRIV_TYPE_CHAR | 128,
1299 WLAN_SUBCMD_FWT_DEL,
1300 IW_PRIV_TYPE_CHAR | 128,
1301 IW_PRIV_TYPE_CHAR | 128,
1304 WLAN_SUBCMD_FWT_LOOKUP,
1305 IW_PRIV_TYPE_CHAR | 128,
1306 IW_PRIV_TYPE_CHAR | 128,
1309 WLAN_SUBCMD_FWT_LIST_NEIGHBOR,
1310 IW_PRIV_TYPE_CHAR | 128,
1311 IW_PRIV_TYPE_CHAR | 128,
1314 WLAN_SUBCMD_FWT_LIST,
1315 IW_PRIV_TYPE_CHAR | 128,
1316 IW_PRIV_TYPE_CHAR | 128,
1319 WLAN_SUBCMD_FWT_LIST_ROUTE,
1320 IW_PRIV_TYPE_CHAR | 128,
1321 IW_PRIV_TYPE_CHAR | 128,
1325 IW_PRIV_TYPE_CHAR | 128,
1326 IW_PRIV_TYPE_CHAR | 128,
1329 WLAN_GET_ADHOC_STATUS,
1330 IW_PRIV_TYPE_CHAR | 128,
1331 IW_PRIV_TYPE_CHAR | 128,
1334 WLAN_SETNONE_GETWORDCHAR,
1336 IW_PRIV_TYPE_CHAR | 128,
1340 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 24,
1346 IW_PRIV_TYPE_CHAR | GETLOG_BUFSIZE,
1349 WLAN_SET_GET_SIXTEEN_INT,
1350 IW_PRIV_TYPE_INT | 16,
1351 IW_PRIV_TYPE_INT | 16,
1355 IW_PRIV_TYPE_INT | 16,
1356 IW_PRIV_TYPE_INT | 16,
1360 IW_PRIV_TYPE_INT | 16,
1361 IW_PRIV_TYPE_INT | 16,
1365 IW_PRIV_TYPE_INT | 16,
1366 IW_PRIV_TYPE_INT | 16,
1370 IW_PRIV_TYPE_INT | 16,
1371 IW_PRIV_TYPE_INT | 16,
1375 IW_PRIV_TYPE_INT | 16,
1376 IW_PRIV_TYPE_INT | 16,
1380 IW_PRIV_TYPE_INT | 16,
1381 IW_PRIV_TYPE_INT | 16,
1385 IW_PRIV_TYPE_INT | 16,
1386 IW_PRIV_TYPE_INT | 16,
1389 WLAN_INACTIVITY_TIMEOUT,
1390 IW_PRIV_TYPE_INT | 16,
1391 IW_PRIV_TYPE_INT | 16,
1395 IW_PRIV_TYPE_INT | 16,
1396 IW_PRIV_TYPE_INT | 16,
1400 IW_PRIV_TYPE_INT | 16,
1401 IW_PRIV_TYPE_INT | 16,
1405 IW_PRIV_TYPE_INT | 16,
1406 IW_PRIV_TYPE_INT | 16,
1410 static struct iw_statistics *wlan_get_wireless_stats(struct net_device *dev)
1420 wlan_private *priv = dev->priv;
1421 wlan_adapter *adapter = priv->adapter;
1425 int stats_valid = 0;
1431 priv->wstats.status = adapter->inframode;
1433 /* If we're not associated, all quality values are meaningless */
1434 if (adapter->connect_status != libertas_connected)
1437 /* Quality by RSSI */
1438 priv->wstats.qual.level =
1439 CAL_RSSI(adapter->SNR[TYPE_BEACON][TYPE_NOAVG],
1440 adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1442 if (adapter->NF[TYPE_BEACON][TYPE_NOAVG] == 0) {
1443 priv->wstats.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE;
1445 priv->wstats.qual.noise =
1446 CAL_NF(adapter->NF[TYPE_BEACON][TYPE_NOAVG]);
1449 lbs_pr_debug(1, "Signal Level = %#x\n", priv->wstats.qual.level);
1450 lbs_pr_debug(1, "Noise = %#x\n", priv->wstats.qual.noise);
1452 rssi = priv->wstats.qual.level - priv->wstats.qual.noise;
1454 rssi_qual = rssi * POOR / 10;
1456 rssi_qual = (rssi - 15) * (FAIR - POOR) / 5 + POOR;
1458 rssi_qual = (rssi - 20) * (GOOD - FAIR) / 5 + FAIR;
1460 rssi_qual = (rssi - 30) * (VERY_GOOD - GOOD) /
1463 rssi_qual = (rssi - 40) * (PERFECT - VERY_GOOD) /
1465 quality = rssi_qual;
1467 /* Quality by TX errors */
1468 priv->wstats.discard.retries = priv->stats.tx_errors;
1470 tx_retries = adapter->logmsg.retry;
1472 if (tx_retries > 75)
1473 tx_qual = (90 - tx_retries) * POOR / 15;
1474 else if (tx_retries > 70)
1475 tx_qual = (75 - tx_retries) * (FAIR - POOR) / 5 + POOR;
1476 else if (tx_retries > 65)
1477 tx_qual = (70 - tx_retries) * (GOOD - FAIR) / 5 + FAIR;
1478 else if (tx_retries > 50)
1479 tx_qual = (65 - tx_retries) * (VERY_GOOD - GOOD) /
1482 tx_qual = (50 - tx_retries) *
1483 (PERFECT - VERY_GOOD) / 50 + VERY_GOOD;
1484 quality = min(quality, tx_qual);
1486 priv->wstats.discard.code = adapter->logmsg.wepundecryptable;
1487 priv->wstats.discard.fragment = adapter->logmsg.fcserror;
1488 priv->wstats.discard.retries = tx_retries;
1489 priv->wstats.discard.misc = adapter->logmsg.ackfailure;
1491 /* Calculate quality */
1492 priv->wstats.qual.qual = max(quality, (u32)100);
1493 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
1496 /* update stats asynchronously for future calls */
1497 libertas_prepare_and_send_command(priv, cmd_802_11_rssi, 0,
1499 libertas_prepare_and_send_command(priv, cmd_802_11_get_log, 0,
1503 priv->wstats.miss.beacon = 0;
1504 priv->wstats.discard.retries = 0;
1505 priv->wstats.qual.qual = 0;
1506 priv->wstats.qual.level = 0;
1507 priv->wstats.qual.noise = 0;
1508 priv->wstats.qual.updated = IW_QUAL_ALL_UPDATED;
1509 priv->wstats.qual.updated |= IW_QUAL_NOISE_INVALID |
1510 IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID;
1514 return &priv->wstats;
1519 static int wlan_set_freq(struct net_device *dev, struct iw_request_info *info,
1520 struct iw_freq *fwrq, char *extra)
1523 wlan_private *priv = dev->priv;
1524 wlan_adapter *adapter = priv->adapter;
1525 int rc = -EINPROGRESS; /* Call commit handler */
1526 struct chan_freq_power *cfp;
1531 * If setting by frequency, convert to a channel
1535 long f = fwrq->m / 100000;
1538 cfp = find_cfp_by_band_and_freq(adapter, 0, f);
1540 lbs_pr_debug(1, "Invalid freq=%ld\n", f);
1544 c = (int)cfp->channel;
1554 * Setting by channel number
1556 if (fwrq->m > 1000 || fwrq->e > 0) {
1559 int channel = fwrq->m;
1561 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, channel);
1565 if (adapter->inframode == wlan802_11ibss) {
1566 rc = changeadhocchannel(priv, channel);
1567 /* If station is WEP enabled, send the
1568 * command to set WEP in firmware
1570 if (adapter->secinfo.WEPstatus ==
1571 wlan802_11WEPenabled) {
1572 lbs_pr_debug(1, "set_freq: WEP enabled\n");
1573 ret = libertas_prepare_and_send_command(priv,
1576 cmd_option_waitforrsp,
1585 adapter->currentpacketfilter |=
1586 cmd_act_mac_wep_enable;
1588 libertas_set_mac_packet_filter(priv);
1601 * @brief use index to get the data rate
1603 * @param index The index of data rate
1604 * @return data rate or 0
1606 u32 libertas_index_to_data_rate(u8 index)
1608 if (index >= sizeof(libertas_wlan_data_rates))
1611 return libertas_wlan_data_rates[index];
1615 * @brief use rate to get the index
1617 * @param rate data rate
1618 * @return index or 0
1620 u8 libertas_data_rate_to_index(u32 rate)
1625 if ((ptr = memchr(libertas_wlan_data_rates, (u8) rate,
1626 sizeof(libertas_wlan_data_rates))))
1627 return (ptr - libertas_wlan_data_rates);
1632 static int wlan_set_rate(struct net_device *dev, struct iw_request_info *info,
1633 struct iw_param *vwrq, char *extra)
1635 wlan_private *priv = dev->priv;
1636 wlan_adapter *adapter = priv->adapter;
1640 u8 rates[WLAN_SUPPORTED_RATES];
1645 lbs_pr_debug(1, "Vwrq->value = %d\n", vwrq->value);
1647 if (vwrq->value == -1) {
1648 action = cmd_act_set_tx_auto; // Auto
1649 adapter->is_datarate_auto = 1;
1650 adapter->datarate = 0;
1652 if (vwrq->value % 100000) {
1656 data_rate = vwrq->value / 500000;
1658 memset(rates, 0, sizeof(rates));
1659 get_active_data_rates(adapter, rates);
1662 lbs_pr_debug(1, "Rate=0x%X Wanted=0x%X\n", *rate,
1664 if ((*rate & 0x7f) == (data_rate & 0x7f))
1669 lbs_pr_alert( "The fixed data rate 0x%X is out "
1670 "of range.\n", data_rate);
1674 adapter->datarate = data_rate;
1675 action = cmd_act_set_tx_fix_rate;
1676 adapter->is_datarate_auto = 0;
1679 ret = libertas_prepare_and_send_command(priv, cmd_802_11_data_rate,
1680 action, cmd_option_waitforrsp, 0, NULL);
1686 static int wlan_get_rate(struct net_device *dev, struct iw_request_info *info,
1687 struct iw_param *vwrq, char *extra)
1689 wlan_private *priv = dev->priv;
1690 wlan_adapter *adapter = priv->adapter;
1694 if (adapter->is_datarate_auto) {
1700 vwrq->value = adapter->datarate * 500000;
1706 static int wlan_set_mode(struct net_device *dev,
1707 struct iw_request_info *info, u32 * uwrq, char *extra)
1710 wlan_private *priv = dev->priv;
1711 wlan_adapter *adapter = priv->adapter;
1712 struct assoc_request * assoc_req;
1713 enum WLAN_802_11_NETWORK_INFRASTRUCTURE new_mode;
1719 lbs_pr_debug(1, "Wanted mode is ad-hoc: current datarate=%#x\n",
1721 new_mode = wlan802_11ibss;
1722 adapter->adhocchannel = DEFAULT_AD_HOC_CHANNEL;
1726 lbs_pr_debug(1, "Wanted mode is Infrastructure\n");
1727 new_mode = wlan802_11infrastructure;
1731 lbs_pr_debug(1, "Wanted mode is Auto\n");
1732 new_mode = wlan802_11autounknown;
1736 lbs_pr_debug(1, "Wanted mode is Unknown: 0x%x\n", *uwrq);
1740 mutex_lock(&adapter->lock);
1741 assoc_req = wlan_get_association_request(adapter);
1745 assoc_req->mode = new_mode;
1749 set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
1750 wlan_postpone_association_work(priv);
1752 wlan_cancel_association_work(priv);
1754 mutex_unlock(&adapter->lock);
1762 * @brief Get Encryption key
1764 * @param dev A pointer to net_device structure
1765 * @param info A pointer to iw_request_info structure
1766 * @param vwrq A pointer to iw_param structure
1767 * @param extra A pointer to extra data buf
1768 * @return 0 --success, otherwise fail
1770 static int wlan_get_encode(struct net_device *dev,
1771 struct iw_request_info *info,
1772 struct iw_point *dwrq, u8 * extra)
1774 wlan_private *priv = dev->priv;
1775 wlan_adapter *adapter = priv->adapter;
1776 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1780 lbs_pr_debug(1, "flags=0x%x index=%d length=%d wep_tx_keyidx=%d\n",
1781 dwrq->flags, index, dwrq->length, adapter->wep_tx_keyidx);
1785 /* Authentication method */
1786 switch (adapter->secinfo.authmode) {
1787 case wlan802_11authmodeopen:
1788 dwrq->flags = IW_ENCODE_OPEN;
1791 case wlan802_11authmodeshared:
1792 case wlan802_11authmodenetworkEAP:
1793 dwrq->flags = IW_ENCODE_RESTRICTED;
1796 dwrq->flags = IW_ENCODE_DISABLED | IW_ENCODE_OPEN;
1800 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled)
1801 || adapter->secinfo.WPAenabled || adapter->secinfo.WPA2enabled) {
1802 dwrq->flags &= ~IW_ENCODE_DISABLED;
1804 dwrq->flags |= IW_ENCODE_DISABLED;
1807 memset(extra, 0, 16);
1809 mutex_lock(&adapter->lock);
1811 /* Default to returning current transmit key */
1813 index = adapter->wep_tx_keyidx;
1815 if ((adapter->wep_keys[index].len) &&
1816 (adapter->secinfo.WEPstatus == wlan802_11WEPenabled)) {
1817 memcpy(extra, adapter->wep_keys[index].key,
1818 adapter->wep_keys[index].len);
1819 dwrq->length = adapter->wep_keys[index].len;
1821 dwrq->flags |= (index + 1);
1822 /* Return WEP enabled */
1823 dwrq->flags &= ~IW_ENCODE_DISABLED;
1824 } else if ((adapter->secinfo.WPAenabled)
1825 || (adapter->secinfo.WPA2enabled)) {
1826 /* return WPA enabled */
1827 dwrq->flags &= ~IW_ENCODE_DISABLED;
1829 dwrq->flags |= IW_ENCODE_DISABLED;
1832 mutex_unlock(&adapter->lock);
1834 dwrq->flags |= IW_ENCODE_NOKEY;
1836 lbs_pr_debug(1, "key:%02x:%02x:%02x:%02x:%02x:%02x keylen=%d\n",
1837 extra[0], extra[1], extra[2],
1838 extra[3], extra[4], extra[5], dwrq->length);
1840 lbs_pr_debug(1, "Return flags=0x%x\n", dwrq->flags);
1847 * @brief Set Encryption key (internal)
1849 * @param priv A pointer to private card structure
1850 * @param key_material A pointer to key material
1851 * @param key_length length of key material
1852 * @param index key index to set
1853 * @param set_tx_key Force set TX key (1 = yes, 0 = no)
1854 * @return 0 --success, otherwise fail
1856 static int wlan_set_wep_key(struct assoc_request *assoc_req,
1857 const char *key_material,
1862 struct WLAN_802_11_KEY *pkey;
1866 /* Paranoid validation of key index */
1872 /* validate max key length */
1873 if (key_length > KEY_LEN_WEP_104) {
1878 pkey = &assoc_req->wep_keys[index];
1880 if (key_length > 0) {
1881 memset(pkey, 0, sizeof(struct WLAN_802_11_KEY));
1882 pkey->type = KEY_TYPE_ID_WEP;
1884 /* Standardize the key length */
1885 pkey->len = (key_length > KEY_LEN_WEP_40) ?
1886 KEY_LEN_WEP_104 : KEY_LEN_WEP_40;
1887 memcpy(pkey->key, key_material, key_length);
1891 /* Ensure the chosen key is valid */
1893 lbs_pr_debug(1, "key not set, so cannot enable it\n");
1897 assoc_req->wep_tx_keyidx = index;
1900 assoc_req->secinfo.WEPstatus = wlan802_11WEPenabled;
1906 static int validate_key_index(u16 def_index, u16 raw_index,
1907 u16 *out_index, u16 *is_default)
1909 if (!out_index || !is_default)
1912 /* Verify index if present, otherwise use default TX key index */
1913 if (raw_index > 0) {
1916 *out_index = raw_index - 1;
1918 *out_index = def_index;
1924 static void disable_wep(struct assoc_request *assoc_req)
1928 /* Set Open System auth mode */
1929 assoc_req->secinfo.authmode = wlan802_11authmodeopen;
1931 /* Clear WEP keys and mark WEP as disabled */
1932 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
1933 for (i = 0; i < 4; i++)
1934 assoc_req->wep_keys[i].len = 0;
1936 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
1937 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1941 * @brief Set Encryption key
1943 * @param dev A pointer to net_device structure
1944 * @param info A pointer to iw_request_info structure
1945 * @param vwrq A pointer to iw_param structure
1946 * @param extra A pointer to extra data buf
1947 * @return 0 --success, otherwise fail
1949 static int wlan_set_encode(struct net_device *dev,
1950 struct iw_request_info *info,
1951 struct iw_point *dwrq, char *extra)
1954 wlan_private *priv = dev->priv;
1955 wlan_adapter *adapter = priv->adapter;
1956 struct assoc_request * assoc_req;
1957 u16 is_default = 0, index = 0, set_tx_key = 0;
1961 mutex_lock(&adapter->lock);
1962 assoc_req = wlan_get_association_request(adapter);
1968 if (dwrq->flags & IW_ENCODE_DISABLED) {
1969 disable_wep (assoc_req);
1973 ret = validate_key_index(assoc_req->wep_tx_keyidx,
1974 (dwrq->flags & IW_ENCODE_INDEX),
1975 &index, &is_default);
1981 /* If WEP isn't enabled, or if there is no key data but a valid
1982 * index, set the TX key.
1984 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled)
1985 || (dwrq->length == 0 && !is_default))
1988 ret = wlan_set_wep_key(assoc_req, extra, dwrq->length, index, set_tx_key);
1993 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
1995 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
1997 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
1998 assoc_req->secinfo.authmode = wlan802_11authmodeshared;
1999 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2000 assoc_req->secinfo.authmode = wlan802_11authmodeopen;
2005 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2006 wlan_postpone_association_work(priv);
2008 wlan_cancel_association_work(priv);
2010 mutex_unlock(&adapter->lock);
2017 * @brief Get Extended Encryption key (WPA/802.1x and WEP)
2019 * @param dev A pointer to net_device structure
2020 * @param info A pointer to iw_request_info structure
2021 * @param vwrq A pointer to iw_param structure
2022 * @param extra A pointer to extra data buf
2023 * @return 0 on success, otherwise failure
2025 static int wlan_get_encodeext(struct net_device *dev,
2026 struct iw_request_info *info,
2027 struct iw_point *dwrq,
2031 wlan_private *priv = dev->priv;
2032 wlan_adapter *adapter = priv->adapter;
2033 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2034 int index, max_key_len;
2038 max_key_len = dwrq->length - sizeof(*ext);
2039 if (max_key_len < 0)
2042 index = dwrq->flags & IW_ENCODE_INDEX;
2044 if (index < 1 || index > 4)
2048 index = adapter->wep_tx_keyidx;
2051 if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
2052 ext->alg != IW_ENCODE_ALG_WEP) {
2053 if (index != 0 || adapter->inframode != wlan802_11infrastructure)
2057 dwrq->flags = index + 1;
2058 memset(ext, 0, sizeof(*ext));
2060 if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled)
2061 && !adapter->secinfo.WPAenabled && !adapter->secinfo.WPA2enabled) {
2062 ext->alg = IW_ENCODE_ALG_NONE;
2064 dwrq->flags |= IW_ENCODE_DISABLED;
2068 if ((adapter->secinfo.WEPstatus == wlan802_11WEPenabled)
2069 && !adapter->secinfo.WPAenabled
2070 && !adapter->secinfo.WPA2enabled) {
2071 ext->alg = IW_ENCODE_ALG_WEP;
2072 ext->key_len = adapter->wep_keys[index].len;
2073 key = &adapter->wep_keys[index].key[0];
2074 } else if ((adapter->secinfo.WEPstatus == wlan802_11WEPdisabled) &&
2075 (adapter->secinfo.WPAenabled ||
2076 adapter->secinfo.WPA2enabled)) {
2078 ext->alg = IW_ENCODE_ALG_TKIP;
2084 if (ext->key_len > max_key_len) {
2090 memcpy(ext->key, key, ext->key_len);
2092 dwrq->flags |= IW_ENCODE_NOKEY;
2093 dwrq->flags |= IW_ENCODE_ENABLED;
2103 * @brief Set Encryption key Extended (WPA/802.1x and WEP)
2105 * @param dev A pointer to net_device structure
2106 * @param info A pointer to iw_request_info structure
2107 * @param vwrq A pointer to iw_param structure
2108 * @param extra A pointer to extra data buf
2109 * @return 0 --success, otherwise fail
2111 static int wlan_set_encodeext(struct net_device *dev,
2112 struct iw_request_info *info,
2113 struct iw_point *dwrq,
2117 wlan_private *priv = dev->priv;
2118 wlan_adapter *adapter = priv->adapter;
2119 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
2121 struct assoc_request * assoc_req;
2125 mutex_lock(&adapter->lock);
2126 assoc_req = wlan_get_association_request(adapter);
2132 if ((alg == IW_ENCODE_ALG_NONE) || (dwrq->flags & IW_ENCODE_DISABLED)) {
2133 disable_wep (assoc_req);
2134 } else if (alg == IW_ENCODE_ALG_WEP) {
2135 u16 is_default = 0, index, set_tx_key = 0;
2137 ret = validate_key_index(assoc_req->wep_tx_keyidx,
2138 (dwrq->flags & IW_ENCODE_INDEX),
2139 &index, &is_default);
2143 /* If WEP isn't enabled, or if there is no key data but a valid
2144 * index, or if the set-TX-key flag was passed, set the TX key.
2146 if ((assoc_req->secinfo.WEPstatus != wlan802_11WEPenabled)
2147 || (dwrq->length == 0 && !is_default)
2148 || (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY))
2151 /* Copy key to driver */
2152 ret = wlan_set_wep_key (assoc_req, ext->key, ext->key_len, index,
2157 if (dwrq->flags & IW_ENCODE_RESTRICTED) {
2158 assoc_req->secinfo.authmode =
2159 wlan802_11authmodeshared;
2160 } else if (dwrq->flags & IW_ENCODE_OPEN) {
2161 assoc_req->secinfo.authmode =
2162 wlan802_11authmodeopen;
2165 /* Mark the various WEP bits as modified */
2166 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2168 set_bit(ASSOC_FLAG_WEP_KEYS, &assoc_req->flags);
2170 set_bit(ASSOC_FLAG_WEP_TX_KEYIDX, &assoc_req->flags);
2172 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
2173 struct WLAN_802_11_KEY * pkey;
2175 /* validate key length */
2176 if (((alg == IW_ENCODE_ALG_TKIP)
2177 && (ext->key_len != KEY_LEN_WPA_TKIP))
2178 || ((alg == IW_ENCODE_ALG_CCMP)
2179 && (ext->key_len != KEY_LEN_WPA_AES))) {
2180 lbs_pr_debug(1, "Invalid size %d for key of alg"
2188 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
2189 pkey = &assoc_req->wpa_mcast_key;
2191 pkey = &assoc_req->wpa_unicast_key;
2193 memset(pkey, 0, sizeof (struct WLAN_802_11_KEY));
2194 memcpy(pkey->key, ext->key, ext->key_len);
2195 pkey->len = ext->key_len;
2196 pkey->flags = KEY_INFO_WPA_ENABLED;
2198 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
2199 pkey->flags |= KEY_INFO_WPA_MCAST;
2200 set_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags);
2202 pkey->flags |= KEY_INFO_WPA_UNICAST;
2203 set_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags);
2206 if (alg == IW_ENCODE_ALG_TKIP)
2207 pkey->type = KEY_TYPE_ID_TKIP;
2208 else if (alg == IW_ENCODE_ALG_CCMP)
2209 pkey->type = KEY_TYPE_ID_AES;
2211 /* If WPA isn't enabled yet, do that now */
2212 if ( assoc_req->secinfo.WPAenabled == 0
2213 && assoc_req->secinfo.WPA2enabled == 0) {
2214 assoc_req->secinfo.WPAenabled = 1;
2215 assoc_req->secinfo.WPA2enabled = 1;
2216 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2219 disable_wep (assoc_req);
2224 wlan_postpone_association_work(priv);
2226 wlan_cancel_association_work(priv);
2228 mutex_unlock(&adapter->lock);
2235 static int wlan_set_genie(struct net_device *dev,
2236 struct iw_request_info *info,
2237 struct iw_point *dwrq,
2240 wlan_private *priv = dev->priv;
2241 wlan_adapter *adapter = priv->adapter;
2243 struct assoc_request * assoc_req;
2247 mutex_lock(&adapter->lock);
2248 assoc_req = wlan_get_association_request(adapter);
2254 if (dwrq->length > MAX_WPA_IE_LEN ||
2255 (dwrq->length && extra == NULL)) {
2261 memcpy(&assoc_req->wpa_ie[0], extra, dwrq->length);
2262 assoc_req->wpa_ie_len = dwrq->length;
2264 memset(&assoc_req->wpa_ie[0], 0, sizeof(adapter->wpa_ie));
2265 assoc_req->wpa_ie_len = 0;
2270 set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
2271 wlan_postpone_association_work(priv);
2273 wlan_cancel_association_work(priv);
2275 mutex_unlock(&adapter->lock);
2281 static int wlan_get_genie(struct net_device *dev,
2282 struct iw_request_info *info,
2283 struct iw_point *dwrq,
2286 wlan_private *priv = dev->priv;
2287 wlan_adapter *adapter = priv->adapter;
2291 if (adapter->wpa_ie_len == 0) {
2297 if (dwrq->length < adapter->wpa_ie_len) {
2302 dwrq->length = adapter->wpa_ie_len;
2303 memcpy(extra, &adapter->wpa_ie[0], adapter->wpa_ie_len);
2310 static int wlan_set_auth(struct net_device *dev,
2311 struct iw_request_info *info,
2312 struct iw_param *dwrq,
2315 wlan_private *priv = dev->priv;
2316 wlan_adapter *adapter = priv->adapter;
2317 struct assoc_request * assoc_req;
2323 mutex_lock(&adapter->lock);
2324 assoc_req = wlan_get_association_request(adapter);
2330 switch (dwrq->flags & IW_AUTH_INDEX) {
2331 case IW_AUTH_TKIP_COUNTERMEASURES:
2332 case IW_AUTH_CIPHER_PAIRWISE:
2333 case IW_AUTH_CIPHER_GROUP:
2334 case IW_AUTH_KEY_MGMT:
2336 * libertas does not use these parameters
2340 case IW_AUTH_WPA_VERSION:
2341 if (dwrq->value & IW_AUTH_WPA_VERSION_DISABLED) {
2342 assoc_req->secinfo.WPAenabled = 0;
2343 assoc_req->secinfo.WPA2enabled = 0;
2345 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA) {
2346 assoc_req->secinfo.WPAenabled = 1;
2347 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
2348 assoc_req->secinfo.authmode =
2349 wlan802_11authmodeopen;
2351 if (dwrq->value & IW_AUTH_WPA_VERSION_WPA2) {
2352 assoc_req->secinfo.WPA2enabled = 1;
2353 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
2354 assoc_req->secinfo.authmode =
2355 wlan802_11authmodeopen;
2360 case IW_AUTH_DROP_UNENCRYPTED:
2362 adapter->currentpacketfilter |=
2363 cmd_act_mac_strict_protection_enable;
2365 adapter->currentpacketfilter &=
2366 ~cmd_act_mac_strict_protection_enable;
2371 case IW_AUTH_80211_AUTH_ALG:
2372 if (dwrq->value & IW_AUTH_ALG_SHARED_KEY) {
2373 assoc_req->secinfo.authmode =
2374 wlan802_11authmodeshared;
2375 } else if (dwrq->value & IW_AUTH_ALG_OPEN_SYSTEM) {
2376 assoc_req->secinfo.authmode =
2377 wlan802_11authmodeopen;
2378 } else if (dwrq->value & IW_AUTH_ALG_LEAP) {
2379 assoc_req->secinfo.authmode =
2380 wlan802_11authmodenetworkEAP;
2387 case IW_AUTH_WPA_ENABLED:
2389 if (!assoc_req->secinfo.WPAenabled &&
2390 !assoc_req->secinfo.WPA2enabled) {
2391 assoc_req->secinfo.WPAenabled = 1;
2392 assoc_req->secinfo.WPA2enabled = 1;
2393 assoc_req->secinfo.WEPstatus = wlan802_11WEPdisabled;
2394 assoc_req->secinfo.authmode =
2395 wlan802_11authmodeopen;
2398 assoc_req->secinfo.WPAenabled = 0;
2399 assoc_req->secinfo.WPA2enabled = 0;
2412 set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
2413 wlan_postpone_association_work(priv);
2414 } else if (ret != -EOPNOTSUPP) {
2415 wlan_cancel_association_work(priv);
2417 mutex_unlock(&adapter->lock);
2423 static int wlan_get_auth(struct net_device *dev,
2424 struct iw_request_info *info,
2425 struct iw_param *dwrq,
2428 wlan_private *priv = dev->priv;
2429 wlan_adapter *adapter = priv->adapter;
2433 switch (dwrq->flags & IW_AUTH_INDEX) {
2434 case IW_AUTH_WPA_VERSION:
2436 if (adapter->secinfo.WPAenabled)
2437 dwrq->value |= IW_AUTH_WPA_VERSION_WPA;
2438 if (adapter->secinfo.WPA2enabled)
2439 dwrq->value |= IW_AUTH_WPA_VERSION_WPA2;
2441 dwrq->value |= IW_AUTH_WPA_VERSION_DISABLED;
2444 case IW_AUTH_DROP_UNENCRYPTED:
2446 if (adapter->currentpacketfilter &
2447 cmd_act_mac_strict_protection_enable)
2451 case IW_AUTH_80211_AUTH_ALG:
2452 switch (adapter->secinfo.authmode) {
2453 case wlan802_11authmodeshared:
2454 dwrq->value = IW_AUTH_ALG_SHARED_KEY;
2456 case wlan802_11authmodeopen:
2457 dwrq->value = IW_AUTH_ALG_OPEN_SYSTEM;
2459 case wlan802_11authmodenetworkEAP:
2460 dwrq->value = IW_AUTH_ALG_LEAP;
2467 case IW_AUTH_WPA_ENABLED:
2468 if (adapter->secinfo.WPAenabled && adapter->secinfo.WPA2enabled)
2482 static int wlan_set_txpow(struct net_device *dev, struct iw_request_info *info,
2483 struct iw_param *vwrq, char *extra)
2486 wlan_private *priv = dev->priv;
2487 wlan_adapter *adapter = priv->adapter;
2493 if (vwrq->disabled) {
2494 wlan_radio_ioctl(priv, RADIO_OFF);
2498 adapter->preamble = cmd_type_auto_preamble;
2500 wlan_radio_ioctl(priv, RADIO_ON);
2502 if ((vwrq->flags & IW_TXPOW_TYPE) == IW_TXPOW_MWATT) {
2503 dbm = (u16) mw_to_dbm(vwrq->value);
2505 dbm = (u16) vwrq->value;
2507 /* auto tx power control */
2509 if (vwrq->fixed == 0)
2512 lbs_pr_debug(1, "<1>TXPOWER SET %d dbm.\n", dbm);
2514 ret = libertas_prepare_and_send_command(priv,
2515 cmd_802_11_rf_tx_power,
2516 cmd_act_tx_power_opt_set_low,
2517 cmd_option_waitforrsp, 0, (void *)&dbm);
2523 static int wlan_get_essid(struct net_device *dev, struct iw_request_info *info,
2524 struct iw_point *dwrq, char *extra)
2526 wlan_private *priv = dev->priv;
2527 wlan_adapter *adapter = priv->adapter;
2531 * Note : if dwrq->flags != 0, we should get the relevant SSID from
2536 * Get the current SSID
2538 if (adapter->connect_status == libertas_connected) {
2539 memcpy(extra, adapter->curbssparams.ssid.ssid,
2540 adapter->curbssparams.ssid.ssidlength);
2541 extra[adapter->curbssparams.ssid.ssidlength] = '\0';
2543 memset(extra, 0, 32);
2544 extra[adapter->curbssparams.ssid.ssidlength] = '\0';
2547 * If none, we may want to get the one that was set
2550 /* To make the driver backward compatible with WPA supplicant v0.2.4 */
2551 if (dwrq->length == 32) /* check with WPA supplicant buffer size */
2552 dwrq->length = min_t(size_t, adapter->curbssparams.ssid.ssidlength,
2555 dwrq->length = adapter->curbssparams.ssid.ssidlength + 1;
2557 dwrq->flags = 1; /* active */
2563 static int wlan_set_essid(struct net_device *dev, struct iw_request_info *info,
2564 struct iw_point *dwrq, char *extra)
2566 wlan_private *priv = dev->priv;
2567 wlan_adapter *adapter = priv->adapter;
2569 struct WLAN_802_11_SSID ssid;
2570 struct assoc_request * assoc_req;
2571 int ssid_len = dwrq->length;
2576 * WE-20 and earlier NULL pad the end of the SSID and increment
2577 * SSID length so it can be used like a string. WE-21 and later don't,
2578 * but some userspace tools aren't able to cope with the change.
2580 if ((ssid_len > 0) && (extra[ssid_len - 1] == '\0'))
2583 /* Check the size of the string */
2584 if (ssid_len > IW_ESSID_MAX_SIZE) {
2589 memset(&ssid, 0, sizeof(struct WLAN_802_11_SSID));
2591 if (!dwrq->flags || !ssid_len) {
2592 /* "any" SSID requested; leave SSID blank */
2594 /* Specific SSID requested */
2595 memcpy(&ssid.ssid, extra, ssid_len);
2596 ssid.ssidlength = ssid_len;
2599 lbs_pr_debug(1, "Requested new SSID = %s\n",
2600 (ssid.ssidlength > 0) ? (char *)ssid.ssid : "any");
2603 mutex_lock(&adapter->lock);
2605 /* Get or create the current association request */
2606 assoc_req = wlan_get_association_request(adapter);
2610 /* Copy the SSID to the association request */
2611 memcpy(&assoc_req->ssid, &ssid, sizeof(struct WLAN_802_11_SSID));
2612 set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
2613 wlan_postpone_association_work(priv);
2617 /* Cancel the association request if there was an error */
2619 wlan_cancel_association_work(priv);
2622 mutex_unlock(&adapter->lock);
2629 * @brief Connect to the AP or Ad-hoc Network with specific bssid
2631 * @param dev A pointer to net_device structure
2632 * @param info A pointer to iw_request_info structure
2633 * @param awrq A pointer to iw_param structure
2634 * @param extra A pointer to extra data buf
2635 * @return 0 --success, otherwise fail
2637 static int wlan_set_wap(struct net_device *dev, struct iw_request_info *info,
2638 struct sockaddr *awrq, char *extra)
2640 wlan_private *priv = dev->priv;
2641 wlan_adapter *adapter = priv->adapter;
2642 struct assoc_request * assoc_req;
2647 if (awrq->sa_family != ARPHRD_ETHER)
2650 lbs_pr_debug(1, "ASSOC: WAP: sa_data: " MAC_FMT "\n", MAC_ARG(awrq->sa_data));
2652 mutex_lock(&adapter->lock);
2654 /* Get or create the current association request */
2655 assoc_req = wlan_get_association_request(adapter);
2657 wlan_cancel_association_work(priv);
2660 /* Copy the BSSID to the association request */
2661 memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
2662 set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
2663 wlan_postpone_association_work(priv);
2666 mutex_unlock(&adapter->lock);
2671 void libertas_get_fwversion(wlan_adapter * adapter, char *fwversion, int maxlen)
2679 mutex_lock(&adapter->lock);
2680 ver.l = adapter->fwreleasenumber;
2681 mutex_unlock(&adapter->lock);
2684 sprintf(fwver, "%u.%u.%u", ver.c[2], ver.c[1], ver.c[0]);
2686 sprintf(fwver, "%u.%u.%u.p%u",
2687 ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
2689 snprintf(fwversion, maxlen, fwver);
2694 * iwconfig settable callbacks
2696 static const iw_handler wlan_handler[] = {
2697 (iw_handler) NULL, /* SIOCSIWCOMMIT */
2698 (iw_handler) wlan_get_name, /* SIOCGIWNAME */
2699 (iw_handler) NULL, /* SIOCSIWNWID */
2700 (iw_handler) NULL, /* SIOCGIWNWID */
2701 (iw_handler) wlan_set_freq, /* SIOCSIWFREQ */
2702 (iw_handler) wlan_get_freq, /* SIOCGIWFREQ */
2703 (iw_handler) wlan_set_mode, /* SIOCSIWMODE */
2704 (iw_handler) wlan_get_mode, /* SIOCGIWMODE */
2705 (iw_handler) NULL, /* SIOCSIWSENS */
2706 (iw_handler) NULL, /* SIOCGIWSENS */
2707 (iw_handler) NULL, /* SIOCSIWRANGE */
2708 (iw_handler) wlan_get_range, /* SIOCGIWRANGE */
2709 (iw_handler) NULL, /* SIOCSIWPRIV */
2710 (iw_handler) NULL, /* SIOCGIWPRIV */
2711 (iw_handler) NULL, /* SIOCSIWSTATS */
2712 (iw_handler) NULL, /* SIOCGIWSTATS */
2713 iw_handler_set_spy, /* SIOCSIWSPY */
2714 iw_handler_get_spy, /* SIOCGIWSPY */
2715 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2716 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2717 (iw_handler) wlan_set_wap, /* SIOCSIWAP */
2718 (iw_handler) wlan_get_wap, /* SIOCGIWAP */
2719 (iw_handler) NULL, /* SIOCSIWMLME */
2720 (iw_handler) NULL, /* SIOCGIWAPLIST - deprecated */
2721 (iw_handler) libertas_set_scan, /* SIOCSIWSCAN */
2722 (iw_handler) libertas_get_scan, /* SIOCGIWSCAN */
2723 (iw_handler) wlan_set_essid, /* SIOCSIWESSID */
2724 (iw_handler) wlan_get_essid, /* SIOCGIWESSID */
2725 (iw_handler) wlan_set_nick, /* SIOCSIWNICKN */
2726 (iw_handler) wlan_get_nick, /* SIOCGIWNICKN */
2727 (iw_handler) NULL, /* -- hole -- */
2728 (iw_handler) NULL, /* -- hole -- */
2729 (iw_handler) wlan_set_rate, /* SIOCSIWRATE */
2730 (iw_handler) wlan_get_rate, /* SIOCGIWRATE */
2731 (iw_handler) wlan_set_rts, /* SIOCSIWRTS */
2732 (iw_handler) wlan_get_rts, /* SIOCGIWRTS */
2733 (iw_handler) wlan_set_frag, /* SIOCSIWFRAG */
2734 (iw_handler) wlan_get_frag, /* SIOCGIWFRAG */
2735 (iw_handler) wlan_set_txpow, /* SIOCSIWTXPOW */
2736 (iw_handler) wlan_get_txpow, /* SIOCGIWTXPOW */
2737 (iw_handler) wlan_set_retry, /* SIOCSIWRETRY */
2738 (iw_handler) wlan_get_retry, /* SIOCGIWRETRY */
2739 (iw_handler) wlan_set_encode, /* SIOCSIWENCODE */
2740 (iw_handler) wlan_get_encode, /* SIOCGIWENCODE */
2741 (iw_handler) wlan_set_power, /* SIOCSIWPOWER */
2742 (iw_handler) wlan_get_power, /* SIOCGIWPOWER */
2743 (iw_handler) NULL, /* -- hole -- */
2744 (iw_handler) NULL, /* -- hole -- */
2745 (iw_handler) wlan_set_genie, /* SIOCSIWGENIE */
2746 (iw_handler) wlan_get_genie, /* SIOCGIWGENIE */
2747 (iw_handler) wlan_set_auth, /* SIOCSIWAUTH */
2748 (iw_handler) wlan_get_auth, /* SIOCGIWAUTH */
2749 (iw_handler) wlan_set_encodeext,/* SIOCSIWENCODEEXT */
2750 (iw_handler) wlan_get_encodeext,/* SIOCGIWENCODEEXT */
2751 (iw_handler) NULL, /* SIOCSIWPMKSA */
2754 struct iw_handler_def libertas_handler_def = {
2755 .num_standard = sizeof(wlan_handler) / sizeof(iw_handler),
2756 .num_private = sizeof(wlan_private_handler) / sizeof(iw_handler),
2757 .num_private_args = sizeof(wlan_private_args) /
2758 sizeof(struct iw_priv_args),
2759 .standard = (iw_handler *) wlan_handler,
2760 .private = (iw_handler *) wlan_private_handler,
2761 .private_args = (struct iw_priv_args *)wlan_private_args,
2762 .get_wireless_stats = wlan_get_wireless_stats,