From 649db902e97f8e61ccf0eadeb0c72a981f31afbe Mon Sep 17 00:00:00 2001 From: sunyue5 Date: Thu, 24 Jan 2019 16:57:58 +0800 Subject: [PATCH] scsc: Add sysfs to enable/disable MAC randomisation 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 Reviewed-on: https://gerrit.mot.com/1300264 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Hua Tan Submit-Approved: Jira Key --- drivers/net/wireless/scsc/cfg80211_ops.c | 6 +++++- drivers/net/wireless/scsc/dev.c | 17 +++++++++++++++++ drivers/net/wireless/scsc/dev.h | 6 ++++++ drivers/net/wireless/scsc/mlme.c | 2 +- drivers/net/wireless/scsc/nl80211_vendor.c | 7 +++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/scsc/cfg80211_ops.c b/drivers/net/wireless/scsc/cfg80211_ops.c index 0f3b7b588186..0f4f9884cfa0 100755 --- a/drivers/net/wireless/scsc/cfg80211_ops.c +++ b/drivers/net/wireless/scsc/cfg80211_ops.c @@ -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); diff --git a/drivers/net/wireless/scsc/dev.c b/drivers/net/wireless/scsc/dev.c index b66f530ef86f..347b813a30c9 100755 --- a/drivers/net/wireless/scsc/dev.c +++ b/drivers/net/wireless/scsc/dev.c @@ -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); diff --git a/drivers/net/wireless/scsc/dev.h b/drivers/net/wireless/scsc/dev.h index 60c34343a719..001f4199e75c 100755 --- a/drivers/net/wireless/scsc/dev.h +++ b/drivers/net/wireless/scsc/dev.h @@ -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; diff --git a/drivers/net/wireless/scsc/mlme.c b/drivers/net/wireless/scsc/mlme.c index 06bc51288211..18d1e31ae39c 100755 --- a/drivers/net/wireless/scsc/mlme.c +++ b/drivers/net/wireless/scsc/mlme.c @@ -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 diff --git a/drivers/net/wireless/scsc/nl80211_vendor.c b/drivers/net/wireless/scsc/nl80211_vendor.c index bc783e171c36..32597c98f855 100755 --- a/drivers/net/wireless/scsc/nl80211_vendor.c +++ b/drivers/net/wireless/scsc/nl80211_vendor.c @@ -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) { -- 2.20.1