scsc: Add sysfs to enable/disable MAC randomisation
authorsunyue5 <sunyue5@motorola.com>
Thu, 24 Jan 2019 08:57:58 +0000 (16:57 +0800)
committerxiest1 <xiest1@lenovo.com>
Tue, 5 Nov 2019 09:30:38 +0000 (17:30 +0800)
We need disable MAC randomisation for some test and debug
This change is to add a module parameter mac_randomisation_disabled
to enable/disable MAC randomisation.

Change-Id: I84a2f625ecb2f5c3a38b8041e909af1f8dfd8c18
Signed-off-by: sunyue5 <sunyue5@motorola.com>
Reviewed-on: https://gerrit.mot.com/1300264
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Hua Tan <tanhua1@motorola.com>
Submit-Approved: Jira Key

drivers/net/wireless/scsc/cfg80211_ops.c
drivers/net/wireless/scsc/dev.c
drivers/net/wireless/scsc/dev.h
drivers/net/wireless/scsc/mlme.c
drivers/net/wireless/scsc/nl80211_vendor.c

index 14bc103948401824064426e087072f30db2d0bd2..7c76b40fe2c7a13eae2a4b078ffa54a21822ed99 100755 (executable)
@@ -591,7 +591,12 @@ int slsi_scan(struct wiphy *wiphy, struct net_device *dev,
 
 #ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0))
-               if (request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
+                //BEGIN IKSAMP-1972
+                if (!slsi_dev_mac_randomisation_support()) {
+                        SLSI_ERR(sdev, "mac randomisation is disabled by module parameters");
+                } else if (request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
+                //END IKSAMP-1972
+
                        if (sdev->fw_mac_randomization_enabled) {
                                memcpy(sdev->scan_mac_addr, request->mac_addr, ETH_ALEN);
                                r = slsi_set_mac_randomisation_mask(sdev, request->mac_addr_mask);
index e2d27cc779474b36a4d52188d57439c698b4f4af..b4ec5c571f1d842b50db2c4ad883d3bfd9eb02ec 100755 (executable)
@@ -80,6 +80,14 @@ static bool nan_disabled;
 module_param(nan_disabled, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(nan_disabled, "Disable NAN: to disable NAN set 1.");
 
+//BEGIN IKSAMP-1972
+#ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
+static bool mac_randomisation_disabled;
+module_param(mac_randomisation_disabled, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(mac_randomisation_disabled, "Disable MAC Randomisation: to disable MAC randomisation set 1.");
+#endif
+//END IKSAMP-1972
+
 bool slsi_dev_gscan_supported(void)
 {
        return !gscan_disabled;
@@ -126,6 +134,15 @@ int slsi_dev_nan_supported(struct slsi_dev *sdev)
 #endif
 }
 
+//BEGIN IKSAMP-1972
+#ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
+bool slsi_dev_mac_randomisation_support(void)
+{
+       return !mac_randomisation_disabled;
+}
+#endif
+//END IKSAMP-1972
+
 static int slsi_dev_inetaddr_changed(struct notifier_block *nb, unsigned long data, void *arg)
 {
        struct slsi_dev     *sdev = container_of(nb, struct slsi_dev, inetaddr_notifier);
index 25c391149c82f1d3d1e2ca8f26cd4ab1da7f6ff3..6658988a352ccf895e20e4928f4fc8d28235823f 100755 (executable)
@@ -1243,6 +1243,12 @@ int slsi_dev_nan_supported(struct slsi_dev *sdev);
 void slsi_regd_init(struct slsi_dev *sdev);
 bool slsi_dev_rtt_supported(void);
 
+//BEGIN IKSAMP-1972
+#ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
+bool slsi_dev_mac_randomisation_support(void);
+#endif
+//END IKSAMP-1972
+
 static inline u16 slsi_tx_host_tag(struct slsi_dev *sdev, enum slsi_traffic_q tq)
 {
        /* host_tag:
index ca380c7b716c565d75ce02bab7d273b002b356ed..71ccc34f5f607691078a04e4064394aae37d42fe 100755 (executable)
@@ -1171,7 +1171,7 @@ static inline int slsi_set_scan_params(
 
 
 #ifdef CONFIG_SCSC_WLAN_ENABLE_MAC_RANDOMISATION
-       if (sdev->scan_addr_set)
+       if (sdev->scan_addr_set && slsi_dev_mac_randomisation_support()) //IKSAMP-1972
                fapi_set_memcpy(req, u.mlme_add_scan_req.device_address, sdev->scan_mac_addr);
        else
 #endif
index 0b3301cb3c3127cdc12dce3bcc6c6920c8ba8aa6..422ff46a4117b7525325a19cab645ac2d7265872 100755 (executable)
@@ -2519,6 +2519,13 @@ static int slsi_gscan_set_oui(struct wiphy *wiphy,
        const struct nlattr      *attr;
        u8 scan_oui[6];
 
+       //BEGIN IKSAMP-1972
+       if (!slsi_dev_mac_randomisation_support()) {
+               SLSI_ERR(sdev, "mac randomisation is disabled by module parameters");
+               return -EINVAL;
+       }
+       //END IKSAMP-1972
+
        memset(&scan_oui, 0, 6);
 
        if (!dev) {