aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2012-07-13 23:09:30 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-07-17 15:11:32 -0400
commit1f45b39ececbdfb13a7bf4d2f644d2e89a8b415f (patch)
treef57153b22125afc542f0ecc053a7df285e4aac4a /drivers/net/wireless/mwifiex
parent530275e52b00e04018fb20e83377e0572944ea97 (diff)
mwifiex: remove redundant code in set channel path
1) Recently we removed set_channel cfg80211 handler. Also, cfg80211 blocks ibss connection requests if ibss network is already started /joined. Hence the code to restart ibss network in new channel (mwifiex_drv_change_adhoc_chan() function) becomes redundant. 2) mwifiex_bss_set_channel() function is redundant. It does some error checking and calculate adhoc start band and adhoc channel. Cfg80211 already takes care of error checking and provides correct channel information to the driver. Adhoc start band is already calculated in mwifiex_set_rf_channel() function. Other associated code is also removed in this patch. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c15
-rw-r--r--drivers/net/wireless/mwifiex/fw.h10
-rw-r--r--drivers/net/wireless/mwifiex/main.h4
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmd.c38
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmdresp.c31
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c163
6 files changed, 2 insertions, 259 deletions
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index e27b3168862c..7276a3449e17 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -349,7 +349,6 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
349 struct ieee80211_channel *chan, 349 struct ieee80211_channel *chan,
350 enum nl80211_channel_type channel_type) 350 enum nl80211_channel_type channel_type)
351{ 351{
352 struct mwifiex_chan_freq_power cfp;
353 u32 config_bands = 0; 352 u32 config_bands = 0;
354 struct wiphy *wiphy = priv->wdev->wiphy; 353 struct wiphy *wiphy = priv->wdev->wiphy;
355 struct mwifiex_adapter *adapter = priv->adapter; 354 struct mwifiex_adapter *adapter = priv->adapter;
@@ -389,24 +388,14 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
389 mwifiex_cfg80211_channel_type_to_sec_chan_offset 388 mwifiex_cfg80211_channel_type_to_sec_chan_offset
390 (channel_type); 389 (channel_type);
391 adapter->channel_type = channel_type; 390 adapter->channel_type = channel_type;
391 priv->adhoc_channel =
392 ieee80211_frequency_to_channel(chan->center_freq);
392 393
393 mwifiex_send_domain_info_cmd_fw(wiphy); 394 mwifiex_send_domain_info_cmd_fw(wiphy);
394 } 395 }
395 396
396 wiphy_dbg(wiphy, "info: setting band %d, chan offset %d, mode %d\n", 397 wiphy_dbg(wiphy, "info: setting band %d, chan offset %d, mode %d\n",
397 config_bands, adapter->sec_chan_offset, priv->bss_mode); 398 config_bands, adapter->sec_chan_offset, priv->bss_mode);
398 if (!chan)
399 return 0;
400
401 memset(&cfp, 0, sizeof(cfp));
402 cfp.freq = chan->center_freq;
403 cfp.channel = ieee80211_frequency_to_channel(chan->center_freq);
404
405 if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
406 if (mwifiex_bss_set_channel(priv, &cfp))
407 return -EFAULT;
408 return mwifiex_drv_change_adhoc_chan(priv, cfp.channel);
409 }
410 399
411 return 0; 400 return 0;
412} 401}
diff --git a/drivers/net/wireless/mwifiex/fw.h b/drivers/net/wireless/mwifiex/fw.h
index 14e985d01dee..e831b440a24a 100644
--- a/drivers/net/wireless/mwifiex/fw.h
+++ b/drivers/net/wireless/mwifiex/fw.h
@@ -225,7 +225,6 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
225#define HostCmd_CMD_BBP_REG_ACCESS 0x001a 225#define HostCmd_CMD_BBP_REG_ACCESS 0x001a
226#define HostCmd_CMD_RF_REG_ACCESS 0x001b 226#define HostCmd_CMD_RF_REG_ACCESS 0x001b
227#define HostCmd_CMD_PMIC_REG_ACCESS 0x00ad 227#define HostCmd_CMD_PMIC_REG_ACCESS 0x00ad
228#define HostCmd_CMD_802_11_RF_CHANNEL 0x001d
229#define HostCmd_CMD_RF_TX_PWR 0x001e 228#define HostCmd_CMD_RF_TX_PWR 0x001e
230#define HostCmd_CMD_RF_ANTENNA 0x0020 229#define HostCmd_CMD_RF_ANTENNA 0x0020
231#define HostCmd_CMD_802_11_DEAUTHENTICATE 0x0024 230#define HostCmd_CMD_802_11_DEAUTHENTICATE 0x0024
@@ -1292,14 +1291,6 @@ struct host_cmd_tlv_channel_band {
1292 u8 channel; 1291 u8 channel;
1293} __packed; 1292} __packed;
1294 1293
1295struct host_cmd_ds_802_11_rf_channel {
1296 __le16 action;
1297 __le16 current_channel;
1298 __le16 rf_type;
1299 __le16 reserved;
1300 u8 reserved_1[32];
1301} __packed;
1302
1303struct host_cmd_ds_version_ext { 1294struct host_cmd_ds_version_ext {
1304 u8 version_str_sel; 1295 u8 version_str_sel;
1305 char version_str[128]; 1296 char version_str[128];
@@ -1384,7 +1375,6 @@ struct host_cmd_ds_command {
1384 struct host_cmd_ds_802_11_rssi_info rssi_info; 1375 struct host_cmd_ds_802_11_rssi_info rssi_info;
1385 struct host_cmd_ds_802_11_rssi_info_rsp rssi_info_rsp; 1376 struct host_cmd_ds_802_11_rssi_info_rsp rssi_info_rsp;
1386 struct host_cmd_ds_802_11_snmp_mib smib; 1377 struct host_cmd_ds_802_11_snmp_mib smib;
1387 struct host_cmd_ds_802_11_rf_channel rf_channel;
1388 struct host_cmd_ds_tx_rate_query tx_rate; 1378 struct host_cmd_ds_tx_rate_query tx_rate;
1389 struct host_cmd_ds_tx_rate_cfg tx_rate_cfg; 1379 struct host_cmd_ds_tx_rate_cfg tx_rate_cfg;
1390 struct host_cmd_ds_txpwr_cfg txp_cfg; 1380 struct host_cmd_ds_txpwr_cfg txp_cfg;
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 774880d5cb56..b710649ccf15 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -953,8 +953,6 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
953 const struct mwifiex_user_scan_cfg *user_scan_in); 953 const struct mwifiex_user_scan_cfg *user_scan_in);
954int mwifiex_set_radio(struct mwifiex_private *priv, u8 option); 954int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
955 955
956int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel);
957
958int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key, 956int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
959 int key_len, u8 key_index, const u8 *mac_addr, 957 int key_len, u8 key_index, const u8 *mac_addr,
960 int disable); 958 int disable);
@@ -993,8 +991,6 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
993 991
994int mwifiex_main_process(struct mwifiex_adapter *); 992int mwifiex_main_process(struct mwifiex_adapter *);
995 993
996int mwifiex_bss_set_channel(struct mwifiex_private *,
997 struct mwifiex_chan_freq_power *cfp);
998int mwifiex_get_bss_info(struct mwifiex_private *, 994int mwifiex_get_bss_info(struct mwifiex_private *,
999 struct mwifiex_bss_info *); 995 struct mwifiex_bss_info *);
1000int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, 996int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index 75eaa6f877fa..93b06cd4e176 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -745,40 +745,6 @@ static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv,
745} 745}
746 746
747/* 747/*
748 * This function prepares command to set/get RF channel.
749 *
750 * Preparation includes -
751 * - Setting command ID, action and proper size
752 * - Setting RF type and current RF channel (for SET only)
753 * - Ensuring correct endian-ness
754 */
755static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv,
756 struct host_cmd_ds_command *cmd,
757 u16 cmd_action, u16 *channel)
758{
759 struct host_cmd_ds_802_11_rf_channel *rf_chan =
760 &cmd->params.rf_channel;
761 uint16_t rf_type = le16_to_cpu(rf_chan->rf_type);
762
763 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_CHANNEL);
764 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rf_channel)
765 + S_DS_GEN);
766
767 if (cmd_action == HostCmd_ACT_GEN_SET) {
768 if ((priv->adapter->adhoc_start_band & BAND_A) ||
769 (priv->adapter->adhoc_start_band & BAND_AN))
770 rf_chan->rf_type =
771 cpu_to_le16(HostCmd_SCAN_RADIO_TYPE_A);
772
773 rf_type = le16_to_cpu(rf_chan->rf_type);
774 SET_SECONDARYCHAN(rf_type, priv->adapter->sec_chan_offset);
775 rf_chan->current_channel = cpu_to_le16(*channel);
776 }
777 rf_chan->action = cpu_to_le16(cmd_action);
778 return 0;
779}
780
781/*
782 * This function prepares command to set/get IBSS coalescing status. 748 * This function prepares command to set/get IBSS coalescing status.
783 * 749 *
784 * Preparation includes - 750 * Preparation includes -
@@ -1175,10 +1141,6 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1175 S_DS_GEN); 1141 S_DS_GEN);
1176 ret = 0; 1142 ret = 0;
1177 break; 1143 break;
1178 case HostCmd_CMD_802_11_RF_CHANNEL:
1179 ret = mwifiex_cmd_802_11_rf_channel(priv, cmd_ptr, cmd_action,
1180 data_buf);
1181 break;
1182 case HostCmd_CMD_FUNC_INIT: 1144 case HostCmd_CMD_FUNC_INIT:
1183 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET) 1145 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
1184 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY; 1146 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY;
diff --git a/drivers/net/wireless/mwifiex/sta_cmdresp.c b/drivers/net/wireless/mwifiex/sta_cmdresp.c
index 71c9b5b92e6d..43ede5e58851 100644
--- a/drivers/net/wireless/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/mwifiex/sta_cmdresp.c
@@ -656,34 +656,6 @@ static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
656} 656}
657 657
658/* 658/*
659 * This function handles the command response of get RF channel.
660 *
661 * Handling includes changing the header fields into CPU format
662 * and saving the new channel in driver.
663 */
664static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv,
665 struct host_cmd_ds_command *resp,
666 u16 *data_buf)
667{
668 struct host_cmd_ds_802_11_rf_channel *rf_channel =
669 &resp->params.rf_channel;
670 u16 new_channel = le16_to_cpu(rf_channel->current_channel);
671
672 if (priv->curr_bss_params.bss_descriptor.channel != new_channel) {
673 dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n",
674 priv->curr_bss_params.bss_descriptor.channel,
675 new_channel);
676 /* Update the channel again */
677 priv->curr_bss_params.bss_descriptor.channel = new_channel;
678 }
679
680 if (data_buf)
681 *data_buf = new_channel;
682
683 return 0;
684}
685
686/*
687 * This function handles the command response of get extended version. 659 * This function handles the command response of get extended version.
688 * 660 *
689 * Handling includes forming the extended version string and sending it 661 * Handling includes forming the extended version string and sending it
@@ -935,9 +907,6 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
935 case HostCmd_CMD_802_11_TX_RATE_QUERY: 907 case HostCmd_CMD_802_11_TX_RATE_QUERY:
936 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp); 908 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
937 break; 909 break;
938 case HostCmd_CMD_802_11_RF_CHANNEL:
939 ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf);
940 break;
941 case HostCmd_CMD_VERSION_EXT: 910 case HostCmd_CMD_VERSION_EXT:
942 ret = mwifiex_ret_ver_ext(priv, resp, data_buf); 911 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
943 break; 912 break;
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index f2fd2423214f..6dff01650242 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -497,169 +497,6 @@ int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
497EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); 497EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
498 498
499/* 499/*
500 * IOCTL request handler to set/get active channel.
501 *
502 * This function performs validity checking on channel/frequency
503 * compatibility and returns failure if not valid.
504 */
505int mwifiex_bss_set_channel(struct mwifiex_private *priv,
506 struct mwifiex_chan_freq_power *chan)
507{
508 struct mwifiex_adapter *adapter = priv->adapter;
509 struct mwifiex_chan_freq_power *cfp = NULL;
510
511 if (!chan)
512 return -1;
513
514 if (!chan->channel && !chan->freq)
515 return -1;
516 if (adapter->adhoc_start_band & BAND_AN)
517 adapter->adhoc_start_band = BAND_G | BAND_B | BAND_GN;
518 else if (adapter->adhoc_start_band & BAND_A)
519 adapter->adhoc_start_band = BAND_G | BAND_B;
520 if (chan->channel) {
521 if (chan->channel <= MAX_CHANNEL_BAND_BG)
522 cfp = mwifiex_get_cfp(priv, 0, (u16) chan->channel, 0);
523 if (!cfp) {
524 cfp = mwifiex_get_cfp(priv, BAND_A,
525 (u16) chan->channel, 0);
526 if (cfp) {
527 if (adapter->adhoc_11n_enabled)
528 adapter->adhoc_start_band = BAND_A
529 | BAND_AN;
530 else
531 adapter->adhoc_start_band = BAND_A;
532 }
533 }
534 } else {
535 if (chan->freq <= MAX_FREQUENCY_BAND_BG)
536 cfp = mwifiex_get_cfp(priv, 0, 0, chan->freq);
537 if (!cfp) {
538 cfp = mwifiex_get_cfp(priv, BAND_A, 0, chan->freq);
539 if (cfp) {
540 if (adapter->adhoc_11n_enabled)
541 adapter->adhoc_start_band = BAND_A
542 | BAND_AN;
543 else
544 adapter->adhoc_start_band = BAND_A;
545 }
546 }
547 }
548 if (!cfp || !cfp->channel) {
549 dev_err(adapter->dev, "invalid channel/freq\n");
550 return -1;
551 }
552 priv->adhoc_channel = (u8) cfp->channel;
553 chan->channel = cfp->channel;
554 chan->freq = cfp->freq;
555
556 return 0;
557}
558
559/*
560 * IOCTL request handler to set/get Ad-Hoc channel.
561 *
562 * This function prepares the correct firmware command and
563 * issues it to set or get the ad-hoc channel.
564 */
565static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
566 u16 action, u16 *channel)
567{
568 if (action == HostCmd_ACT_GEN_GET) {
569 if (!priv->media_connected) {
570 *channel = priv->adhoc_channel;
571 return 0;
572 }
573 } else {
574 priv->adhoc_channel = (u8) *channel;
575 }
576
577 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
578 action, 0, channel);
579}
580
581/*
582 * IOCTL request handler to change Ad-Hoc channel.
583 *
584 * This function allocates the IOCTL request buffer, fills it
585 * with requisite parameters and calls the IOCTL handler.
586 *
587 * The function follows the following steps to perform the change -
588 * - Get current IBSS information
589 * - Get current channel
590 * - If no change is required, return
591 * - If not connected, change channel and return
592 * - If connected,
593 * - Disconnect
594 * - Change channel
595 * - Perform specific SSID scan with same SSID
596 * - Start/Join the IBSS
597 */
598int
599mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel)
600{
601 int ret;
602 struct mwifiex_bss_info bss_info;
603 struct mwifiex_ssid_bssid ssid_bssid;
604 u16 curr_chan = 0;
605 struct cfg80211_bss *bss = NULL;
606 struct ieee80211_channel *chan;
607 enum ieee80211_band band;
608
609 memset(&bss_info, 0, sizeof(bss_info));
610
611 /* Get BSS information */
612 if (mwifiex_get_bss_info(priv, &bss_info))
613 return -1;
614
615 /* Get current channel */
616 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
617 &curr_chan);
618
619 if (curr_chan == channel) {
620 ret = 0;
621 goto done;
622 }
623 dev_dbg(priv->adapter->dev, "cmd: updating channel from %d to %d\n",
624 curr_chan, channel);
625
626 if (!bss_info.media_connected) {
627 ret = 0;
628 goto done;
629 }
630
631 /* Do disonnect */
632 memset(&ssid_bssid, 0, ETH_ALEN);
633 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
634
635 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
636 &channel);
637
638 /* Do specific SSID scanning */
639 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
640 ret = -1;
641 goto done;
642 }
643
644 band = mwifiex_band_to_radio_type(priv->curr_bss_params.band);
645 chan = __ieee80211_get_channel(priv->wdev->wiphy,
646 ieee80211_channel_to_frequency(channel,
647 band));
648
649 /* Find the BSS we want using available scan results */
650 bss = cfg80211_get_bss(priv->wdev->wiphy, chan, bss_info.bssid,
651 bss_info.ssid.ssid, bss_info.ssid.ssid_len,
652 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
653 if (!bss)
654 wiphy_warn(priv->wdev->wiphy, "assoc: bss %pM not in scan results\n",
655 bss_info.bssid);
656
657 ret = mwifiex_bss_start(priv, bss, &bss_info.ssid);
658done:
659 return ret;
660}
661
662/*
663 * IOCTL request handler to get rate. 500 * IOCTL request handler to get rate.
664 * 501 *
665 * This function prepares the correct firmware command and 502 * This function prepares the correct firmware command and