From 6600e57e1e4b7cb2276d695c9bd2c962411592ad 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 | 7 ++++++- 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, 37 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/scsc/cfg80211_ops.c b/drivers/net/wireless/scsc/cfg80211_ops.c index 14bc10394840..7c76b40fe2c7 100755 --- a/drivers/net/wireless/scsc/cfg80211_ops.c +++ b/drivers/net/wireless/scsc/cfg80211_ops.c @@ -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); diff --git a/drivers/net/wireless/scsc/dev.c b/drivers/net/wireless/scsc/dev.c index e2d27cc77947..b4ec5c571f1d 100755 --- a/drivers/net/wireless/scsc/dev.c +++ b/drivers/net/wireless/scsc/dev.c @@ -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); diff --git a/drivers/net/wireless/scsc/dev.h b/drivers/net/wireless/scsc/dev.h index 25c391149c82..6658988a352c 100755 --- a/drivers/net/wireless/scsc/dev.h +++ b/drivers/net/wireless/scsc/dev.h @@ -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: diff --git a/drivers/net/wireless/scsc/mlme.c b/drivers/net/wireless/scsc/mlme.c index ca380c7b716c..71ccc34f5f60 100755 --- a/drivers/net/wireless/scsc/mlme.c +++ b/drivers/net/wireless/scsc/mlme.c @@ -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 diff --git a/drivers/net/wireless/scsc/nl80211_vendor.c b/drivers/net/wireless/scsc/nl80211_vendor.c index 0b3301cb3c31..422ff46a4117 100755 --- a/drivers/net/wireless/scsc/nl80211_vendor.c +++ b/drivers/net/wireless/scsc/nl80211_vendor.c @@ -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) { -- 2.20.1