scsc: Add sysfs to enable/disable MAC randomisation
authorsunyue5 <sunyue5@motorola.com>
Thu, 24 Jan 2019 08:57:58 +0000 (16:57 +0800)
committerlingsen1 <lingsen1@lenovo.com>
Sun, 7 Feb 2021 09:36:54 +0000 (17:36 +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 0f3b7b5881862250352731bc433cdb707bafebc0..0f4f9884cfa027482351674717c12071ed5f2f60 100755 (executable)
@@ -677,7 +677,11 @@ int slsi_scan(struct wiphy *wiphy, struct net_device *dev,
         * mac radomization for scan should be disbaled to avoid WPS overlap.
         * Firmware also disables Mac Randomization for WPS Scan.
         */
-       if (request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR && !wps_sta) {
+       //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 && !wps_sta) {
+       //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 b66f530ef86f6d9562a519c9e3aab8fb336ebb10..347b813a30c90bf3b6554ccfc88e63170ded971e 100755 (executable)
@@ -104,6 +104,14 @@ module_param(nan_max_ndi_ifaces, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(nan_max_ndi_ifaces, "max ndi interface");
 #endif
 
+//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;
@@ -167,6 +175,15 @@ int slsi_get_nan_max_ndi_ifaces(void)
 }
 #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 60c34343a719c71a3b62466a7c412b3b826af0f4..001f4199e75cc292c2296e04d6c9fc32e1fdbcef 100755 (executable)
@@ -1333,6 +1333,12 @@ int slsi_get_nan_max_ndi_ifaces(void);
 #endif
 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)
 {
        u16 host_tag = 0;
index 06bc51288211e74d3509b13aebc6e8a9e3b91c66..18d1e31ae39cc1023f53a88fe623374350445b69 100755 (executable)
@@ -1240,7 +1240,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 bc783e171c36e9380053367e3b1898aac15d2528..32597c98f85586887bd1aff4bf7dc6923ab48d9c 100755 (executable)
@@ -2645,6 +2645,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) {