aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex
diff options
context:
space:
mode:
authorAvinash Patil <patila@marvell.com>2015-01-28 05:24:19 -0500
committerKalle Valo <kvalo@codeaurora.org>2015-01-29 03:21:58 -0500
commitb654ca182a2f54c3e3ce682420045f7dd79c8187 (patch)
tree7e751418c83ebe8687e1a15ee35be3a48e7ca78b /drivers/net/wireless/mwifiex
parentb0d4c5ec9730f7544772f50f84dc0dc730b1d551 (diff)
mwifiex: refactor start_ap handler
Refactor mwifiex_cfg80211_start_ap by creating separate function to set AP channel and another for configuring other AP parameters and starting AP. Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Qingshui Gao <gaoqs@marvell.com> Signed-off-by: Cathy Luo <cluo@marvell.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c68
-rw-r--r--drivers/net/wireless/mwifiex/main.h4
-rw-r--r--drivers/net/wireless/mwifiex/uap_cmd.c65
3 files changed, 77 insertions, 60 deletions
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index ceeaeac45007..2e0834ca1cc0 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1677,7 +1677,6 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
1677{ 1677{
1678 struct mwifiex_uap_bss_param *bss_cfg; 1678 struct mwifiex_uap_bss_param *bss_cfg;
1679 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); 1679 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
1680 u8 config_bands = 0;
1681 1680
1682 if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_UAP) 1681 if (GET_BSS_ROLE(priv) != MWIFIEX_BSS_ROLE_UAP)
1683 return -1; 1682 return -1;
@@ -1697,6 +1696,11 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
1697 memcpy(bss_cfg->ssid.ssid, params->ssid, params->ssid_len); 1696 memcpy(bss_cfg->ssid.ssid, params->ssid, params->ssid_len);
1698 bss_cfg->ssid.ssid_len = params->ssid_len; 1697 bss_cfg->ssid.ssid_len = params->ssid_len;
1699 } 1698 }
1699 if (params->inactivity_timeout > 0) {
1700 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */
1701 bss_cfg->sta_ao_timer = 10 * params->inactivity_timeout;
1702 bss_cfg->ps_sta_ao_timer = 10 * params->inactivity_timeout;
1703 }
1700 1704
1701 switch (params->hidden_ssid) { 1705 switch (params->hidden_ssid) {
1702 case NL80211_HIDDEN_SSID_NOT_IN_USE: 1706 case NL80211_HIDDEN_SSID_NOT_IN_USE:
@@ -1712,31 +1716,7 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
1712 return -EINVAL; 1716 return -EINVAL;
1713 } 1717 }
1714 1718
1715 bss_cfg->channel = ieee80211_frequency_to_channel( 1719 mwifiex_uap_set_channel(bss_cfg, params->chandef);
1716 params->chandef.chan->center_freq);
1717
1718 /* Set appropriate bands */
1719 if (params->chandef.chan->band == IEEE80211_BAND_2GHZ) {
1720 bss_cfg->band_cfg = BAND_CONFIG_BG;
1721 config_bands = BAND_B | BAND_G;
1722
1723 if (params->chandef.width > NL80211_CHAN_WIDTH_20_NOHT)
1724 config_bands |= BAND_GN;
1725 } else {
1726 bss_cfg->band_cfg = BAND_CONFIG_A;
1727 config_bands = BAND_A;
1728
1729 if (params->chandef.width > NL80211_CHAN_WIDTH_20_NOHT)
1730 config_bands |= BAND_AN;
1731
1732 if (params->chandef.width > NL80211_CHAN_WIDTH_40)
1733 config_bands |= BAND_AAC;
1734 }
1735
1736 if (!((config_bands | priv->adapter->fw_bands) &
1737 ~priv->adapter->fw_bands))
1738 priv->adapter->config_bands = config_bands;
1739
1740 mwifiex_set_uap_rates(bss_cfg, params); 1720 mwifiex_set_uap_rates(bss_cfg, params);
1741 1721
1742 if (mwifiex_set_secure_params(priv, bss_cfg, params)) { 1722 if (mwifiex_set_secure_params(priv, bss_cfg, params)) {
@@ -1760,23 +1740,8 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
1760 1740
1761 mwifiex_set_wmm_params(priv, bss_cfg, params); 1741 mwifiex_set_wmm_params(priv, bss_cfg, params);
1762 1742
1763 if (params->inactivity_timeout > 0) { 1743 if (mwifiex_config_start_uap(priv, bss_cfg)) {
1764 /* sta_ao_timer/ps_sta_ao_timer is in unit of 100ms */ 1744 wiphy_err(wiphy, "Failed to start AP\n");
1765 bss_cfg->sta_ao_timer = 10 * params->inactivity_timeout;
1766 bss_cfg->ps_sta_ao_timer = 10 * params->inactivity_timeout;
1767 }
1768
1769 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_STOP,
1770 HostCmd_ACT_GEN_SET, 0, NULL, true)) {
1771 wiphy_err(wiphy, "Failed to stop the BSS\n");
1772 kfree(bss_cfg);
1773 return -1;
1774 }
1775
1776 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_SYS_CONFIG,
1777 HostCmd_ACT_GEN_SET,
1778 UAP_BSS_PARAMS_I, bss_cfg, false)) {
1779 wiphy_err(wiphy, "Failed to set the SSID\n");
1780 kfree(bss_cfg); 1745 kfree(bss_cfg);
1781 return -1; 1746 return -1;
1782 } 1747 }
@@ -1786,23 +1751,6 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
1786 1751
1787 memcpy(&priv->bss_cfg, bss_cfg, sizeof(priv->bss_cfg)); 1752 memcpy(&priv->bss_cfg, bss_cfg, sizeof(priv->bss_cfg));
1788 kfree(bss_cfg); 1753 kfree(bss_cfg);
1789
1790 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_START,
1791 HostCmd_ACT_GEN_SET, 0, NULL, false)) {
1792 wiphy_err(wiphy, "Failed to start the BSS\n");
1793 return -1;
1794 }
1795
1796 if (priv->sec_info.wep_enabled)
1797 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1798 else
1799 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1800
1801 if (mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
1802 HostCmd_ACT_GEN_SET, 0,
1803 &priv->curr_pkt_filter, true))
1804 return -1;
1805
1806 return 0; 1754 return 0;
1807} 1755}
1808 1756
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 673252a32cd9..0c75eff23e8b 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -1321,6 +1321,10 @@ int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1321 struct cfg80211_beacon_data *data); 1321 struct cfg80211_beacon_data *data);
1322int mwifiex_del_mgmt_ies(struct mwifiex_private *priv); 1322int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
1323u8 *mwifiex_11d_code_2_region(u8 code); 1323u8 *mwifiex_11d_code_2_region(u8 code);
1324void mwifiex_uap_set_channel(struct mwifiex_uap_bss_param *bss_cfg,
1325 struct cfg80211_chan_def chandef);
1326int mwifiex_config_start_uap(struct mwifiex_private *priv,
1327 struct mwifiex_uap_bss_param *bss_cfg);
1324void mwifiex_uap_del_sta_data(struct mwifiex_private *priv, 1328void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
1325 struct mwifiex_sta_node *node); 1329 struct mwifiex_sta_node *node);
1326 1330
diff --git a/drivers/net/wireless/mwifiex/uap_cmd.c b/drivers/net/wireless/mwifiex/uap_cmd.c
index 0f347fdefa0a..baf53145207e 100644
--- a/drivers/net/wireless/mwifiex/uap_cmd.c
+++ b/drivers/net/wireless/mwifiex/uap_cmd.c
@@ -769,3 +769,68 @@ int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, u16 cmd_no,
769 769
770 return 0; 770 return 0;
771} 771}
772
773void mwifiex_uap_set_channel(struct mwifiex_uap_bss_param *bss_cfg,
774 struct cfg80211_chan_def chandef)
775{
776 u8 config_bands = 0;
777
778 bss_cfg->channel = ieee80211_frequency_to_channel(
779 chandef.chan->center_freq);
780
781 /* Set appropriate bands */
782 if (chandef.chan->band == IEEE80211_BAND_2GHZ) {
783 bss_cfg->band_cfg = BAND_CONFIG_BG;
784 config_bands = BAND_B | BAND_G;
785
786 if (chandef.width > NL80211_CHAN_WIDTH_20_NOHT)
787 config_bands |= BAND_GN;
788 } else {
789 bss_cfg->band_cfg = BAND_CONFIG_A;
790 config_bands = BAND_A;
791
792 if (chandef.width > NL80211_CHAN_WIDTH_20_NOHT)
793 config_bands |= BAND_AN;
794
795 if (chandef.width > NL80211_CHAN_WIDTH_40)
796 config_bands |= BAND_AAC;
797 }
798}
799
800int mwifiex_config_start_uap(struct mwifiex_private *priv,
801 struct mwifiex_uap_bss_param *bss_cfg)
802{
803 if (mwifiex_del_mgmt_ies(priv))
804 dev_err(priv->adapter->dev, "Failed to delete mgmt IEs!\n");
805
806 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_STOP,
807 HostCmd_ACT_GEN_SET, 0, NULL, true)) {
808 dev_err(priv->adapter->dev, "Failed to stop the BSS\n");
809 return -1;
810 }
811
812 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_SYS_CONFIG,
813 HostCmd_ACT_GEN_SET,
814 UAP_BSS_PARAMS_I, bss_cfg, false)) {
815 dev_err(priv->adapter->dev, "Failed to set the SSID\n");
816 return -1;
817 }
818
819 if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_BSS_START,
820 HostCmd_ACT_GEN_SET, 0, NULL, false)) {
821 dev_err(priv->adapter->dev, "Failed to start the BSS\n");
822 return -1;
823 }
824
825 if (priv->sec_info.wep_enabled)
826 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
827 else
828 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
829
830 if (mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
831 HostCmd_ACT_GEN_SET, 0,
832 &priv->curr_pkt_filter, true))
833 return -1;
834
835 return 0;
836}