[NEUS7920-218] [9610] wlbt: Check validity of AP channel
authorSrishti Piplani <srishti.p@samsung.com>
Mon, 22 Apr 2019 08:59:11 +0000 (14:29 +0530)
committerKim Gunho <gunho.kim@samsung.com>
Fri, 28 Jun 2019 14:45:18 +0000 (23:45 +0900)
Check validity of AP channel before selecting the
channel for starting the AP, for Wi-Fi Sharing
scenario. Select the channel only if it is non
indoor , non DFS.

Change-Id: Ie81bcf8e561bf89b83416647c8f27860561b0d6f
SCSC-Bug-Id: SSB-51899
Signed-off-by: Srishti Piplani <srishti.p@samsung.com>
drivers/net/wireless/scsc/cfg80211_ops.c
drivers/net/wireless/scsc/dev.c
drivers/net/wireless/scsc/mgt.c
drivers/net/wireless/scsc/mgt.h

index 697c6d6ac0d3842785b5e81e2996c9eff9f02e16..e4771fd4644b843764cc44a3b78de49d9f495dac 100755 (executable)
@@ -2015,7 +2015,9 @@ int slsi_start_ap(struct wiphy *wiphy, struct net_device *dev,
 #ifdef CONFIG_SCSC_WLAN_WIFI_SHARING
        int wifi_sharing_channel_switched = 0;
        struct netdev_vif *ndev_sta_vif;
+       int invalid_channel = 0;
 #endif
+       int skip_indoor_check_for_wifi_sharing = 0;
        u8 *ds_params_ie = NULL;
        struct ieee80211_mgmt  *mgmt;
        u16                    beacon_ie_head_len;
@@ -2049,7 +2051,15 @@ int slsi_start_ap(struct wiphy *wiphy, struct net_device *dev,
                if ((ndev_sta_vif->activated) && (ndev_sta_vif->vif_type == FAPI_VIFTYPE_STATION) &&
                    (ndev_sta_vif->sta.vif_status == SLSI_VIF_STATUS_CONNECTING ||
                     ndev_sta_vif->sta.vif_status == SLSI_VIF_STATUS_CONNECTED)) {
-                       slsi_select_wifi_sharing_ap_channel(wiphy, dev, settings, sdev, &wifi_sharing_channel_switched);
+                       invalid_channel = slsi_select_wifi_sharing_ap_channel(wiphy, dev, settings, sdev,
+                                                                             &wifi_sharing_channel_switched);
+                       skip_indoor_check_for_wifi_sharing = 1;
+                       if (invalid_channel) {
+                               SLSI_NET_ERR(dev, "Rejecting AP start req at host (invalid channel)\n");
+                               SLSI_MUTEX_UNLOCK(ndev_sta_vif->vif_mutex);
+                               r = -EINVAL;
+                               goto exit_with_vif_mutex;
+                       }
                }
                SLSI_MUTEX_UNLOCK(ndev_sta_vif->vif_mutex);
        }
@@ -2071,7 +2081,8 @@ int slsi_start_ap(struct wiphy *wiphy, struct net_device *dev,
                        }
                }
        }
-       if (sdev->band_5g_supported && ((settings->chandef.chan->center_freq / 1000) == 5)) {
+       if (!skip_indoor_check_for_wifi_sharing && sdev->band_5g_supported &&
+           ((settings->chandef.chan->center_freq / 1000) == 5)) {
                channel =  ieee80211_get_channel(sdev->wiphy, settings->chandef.chan->center_freq);
                if (!channel) {
                        SLSI_ERR(sdev, "Invalid frequency %d used to start AP. Channel not found\n",
index d229eed9afd6c4eb4b2adcf7c222e52b4930ad7c..be8837c7f6568a4bb93fda6d52bd96d12ee2ca62 100755 (executable)
@@ -373,7 +373,15 @@ struct slsi_dev *slsi_dev_attach(struct device *dev, struct scsc_mx *core, struc
 #if CONFIG_SCSC_WLAN_MAX_INTERFACES >= 4
        if (slsi_netif_register(sdev, sdev->netdev[SLSI_NET_INDEX_NAN]) != 0) {
                SLSI_ERR(sdev, "failed to register with NAN netdev\n");
+#ifdef CONFIG_SCSC_WLAN_WIFI_SHARING
+#if defined(CONFIG_SCSC_WLAN_MHS_STATIC_INTERFACE) || (defined(ANDROID_VERSION) && ANDROID_VERSION >= 90000)
                goto err_p2px_wlan_registered;
+#else
+               goto err_p2p_registered;
+#endif
+#else
+               goto err_p2p_registered;
+#endif
        }
 #endif
 #endif
index cd361aa7127c678e09077010c8af84a5e2ebed9d..ea1238f5074223318a0b23c5acf5b87247af968c 100755 (executable)
@@ -4817,7 +4817,33 @@ bool slsi_if_valid_wifi_sharing_channel(struct slsi_dev *sdev, int freq)
        return 0;
 }
 
-void slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device *dev,
+int slsi_check_if_non_indoor_channel(struct slsi_dev *sdev, int freq)
+{
+       struct ieee80211_channel  *channel = NULL;
+       u32 chan_flags = 0;
+
+       channel =  ieee80211_get_channel(sdev->wiphy, freq);
+       if (!channel) {
+               SLSI_ERR(sdev, "Invalid frequency %d used to start AP. Channel not found\n", freq);
+               return 0;
+       }
+
+       chan_flags = (IEEE80211_CHAN_INDOOR_ONLY |
+                             IEEE80211_CHAN_DISABLED |
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 10, 13)
+                             IEEE80211_CHAN_PASSIVE_SCAN
+#else
+                             IEEE80211_CHAN_NO_IR
+#endif
+                            );
+
+       if ((channel->flags) & chan_flags)
+               return 0;
+
+       return 1;
+}
+
+int slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device *dev,
                                         struct cfg80211_ap_settings *settings,
                                         struct slsi_dev *sdev, int *wifi_sharing_channel_switched)
 {
@@ -4840,7 +4866,8 @@ void slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device
                if ((((settings->chandef.chan->center_freq) / 1000) == 5) &&
                    !(slsi_check_if_channel_restricted_already(sdev,
                    ieee80211_frequency_to_channel(settings->chandef.chan->center_freq))) &&
-                   slsi_if_valid_wifi_sharing_channel(sdev, settings->chandef.chan->center_freq)) {
+                   slsi_if_valid_wifi_sharing_channel(sdev, settings->chandef.chan->center_freq) &&
+                   slsi_check_if_non_indoor_channel(sdev, settings->chandef.chan->center_freq)) {
                        settings->chandef.chan = ieee80211_get_channel(wiphy, settings->chandef.chan->center_freq);
                        settings->chandef.center_freq1 = settings->chandef.chan->center_freq;
                } else {
@@ -4856,6 +4883,8 @@ void slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device
        else { /* For 5GHz */
                /* For single antenna */
 #ifdef CONFIG_SCSC_WLAN_SINGLE_ANTENNA
+               if (!slsi_check_if_non_indoor_channel(sdev, sta_frequency))
+                       return 1; /*AP cannot start on indoor channel so we will reject request from the host*/
                if ((settings->chandef.chan->center_freq) != (sta_frequency)) {
                        *wifi_sharing_channel_switched = 1;
                        settings->chandef.chan = ieee80211_get_channel(wiphy, sta_frequency);
@@ -4867,7 +4896,8 @@ void slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device
                if (((settings->chandef.chan->center_freq) / 1000) == 5) {
                        if (!(slsi_check_if_channel_restricted_already(sdev,
                              ieee80211_frequency_to_channel(sta_frequency))) &&
-                           slsi_if_valid_wifi_sharing_channel(sdev, sta_frequency)) {
+                           slsi_if_valid_wifi_sharing_channel(sdev, sta_frequency) &&
+                           slsi_check_if_non_indoor_channel(sdev, sta_frequency)) {
                                if ((settings->chandef.chan->center_freq) != (sta_frequency)) {
                                        *wifi_sharing_channel_switched = 1;
                                        settings->chandef.chan = ieee80211_get_channel(wiphy, sta_frequency);
@@ -4882,6 +4912,7 @@ void slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device
        }
 
        SLSI_DBG1(sdev, SLSI_CFG80211, "AP frequency chosen: %d\n", settings->chandef.chan->center_freq);
+       return 0;
 }
 
 int slsi_get_byte_position(int bit)
index d1d2257ae855e502f4eb3c33eda0ae20d84693a2..b18e80974872e42ee47c422df840d36911415a70 100755 (executable)
@@ -482,7 +482,8 @@ void slsi_modify_ies_on_channel_switch(struct net_device *dev, struct cfg80211_a
 #ifdef CONFIG_SCSC_WLAN_WIFI_SHARING
 bool slsi_if_valid_wifi_sharing_channel(struct slsi_dev *sdev, int freq);
 void slsi_extract_valid_wifi_sharing_channels(struct slsi_dev *sdev);
-void slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device *dev,
+int slsi_check_if_non_indoor_channel(struct slsi_dev *sdev, int freq);
+int slsi_select_wifi_sharing_ap_channel(struct wiphy *wiphy, struct net_device *dev,
                                         struct cfg80211_ap_settings *settings, struct slsi_dev *sdev,
                                         int *wifi_sharing_channel_switched);
 int slsi_set_mib_wifi_sharing_5ghz_channel(struct slsi_dev *sdev, u16 psid, int value,