Ver Fonte

qcacld-3.0: Reject dynamic set mac address if SAP is in up state

Currently the expectation from host is that user space needs to
set dynamic mac address only before start_ap in case of SAP.
In driver there is no such check to reject set mac address
command if SAP is already in up state which leads to unexpected
behaviour at fw.
To address this issue add a check in host to reject dynamic set
mac address command for SAP mode if SAP is already in up state.

Change-Id: I8f5456490574288afba86ec3a732b3dc7ed65bce
CRs-Fixed: 3109470
Ashish há 3 anos atrás
pai
commit
d9f45f4acd

+ 16 - 0
core/hdd/inc/wlan_hdd_main.h

@@ -5179,6 +5179,15 @@ int hdd_dynamic_mac_address_set(struct hdd_context *hdd_ctx,
 				struct hdd_adapter *adapter,
 				struct qdf_mac_addr mac_addr);
 
+/**
+ * hdd_is_dynamic_set_mac_addr_allowed() - API to check dynamic MAC address
+ *				           update is allowed or not
+ * @adapter: Pointer to the adapter structure
+ *
+ * Return: true or false
+ */
+bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter);
+
 #if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC)
 /**
  * hdd_update_vdev_mac_address() - Update VDEV MAC address dynamically
@@ -5215,6 +5224,13 @@ static inline int hdd_dynamic_mac_address_set(struct hdd_context *hdd_ctx,
 {
 	return 0;
 }
+
+static inline bool
+hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter)
+{
+	return false;
+}
+
 #endif /* WLAN_FEATURE_DYNAMIC_MAC_ADDR_UPDATE */
 
 #ifdef FEATURE_WLAN_FULL_POWER_DOWN_SUPPORT

+ 3 - 0
core/hdd/src/wlan_hdd_hostapd.c

@@ -772,6 +772,9 @@ static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr)
 		  dev->name);
 
 	if (adapter->vdev) {
+		if (!hdd_is_dynamic_set_mac_addr_allowed(adapter))
+			return -ENOTSUPP;
+
 		ret = hdd_dynamic_mac_address_set(hdd_ctx, adapter, mac_addr);
 		if (ret)
 			return ret;

+ 25 - 31
core/hdd/src/wlan_hdd_main.c

@@ -5277,47 +5277,52 @@ static void hdd_update_set_mac_addr_req_ctx(struct hdd_adapter *adapter,
 #endif
 
 /**
- * hdd_is_dynamic_set_mac_addr_allowed() - API to check dynamic MAC address
- *				           update is allowed or not
- * @adapter: Pointer to the adapter structure
+ * hdd_is_dynamic_set_mac_addr_supported() - API to check dynamic MAC address
+ *				             update is supported or not
+ * @hdd_ctx: Pointer to the HDD context
  *
  * Return: true or false
  */
-static bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter)
+static inline bool
+hdd_is_dynamic_set_mac_addr_supported(struct hdd_context *hdd_ctx)
+{
+	return hdd_ctx->is_vdev_macaddr_dynamic_update_supported;
+}
+
+bool hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter)
 {
 	if (!adapter->vdev) {
 		hdd_err("VDEV is NULL");
 		return false;
 	}
 
+	if (!hdd_is_dynamic_set_mac_addr_supported(adapter->hdd_ctx)) {
+		hdd_info_rl("On iface up, set mac address change isn't supported");
+		return false;
+	}
+
 	switch (adapter->device_mode) {
 	case QDF_STA_MODE:
 		if (!cm_is_vdev_disconnected(adapter->vdev)) {
-			hdd_err("VDEV is not in disconnected state, set mac address isn't supported");
+			hdd_info_rl("VDEV is not in disconnected state, set mac address isn't supported");
 			return false;
 		}
 	case QDF_P2P_DEVICE_MODE:
 		return true;
+	case QDF_SAP_MODE:
+		if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) {
+			hdd_info_rl("SAP is in up state, set mac address isn't supported");
+			return false;
+		} else {
+			return true;
+		}
 	default:
-		hdd_err("Dynamic set mac address isn't supported for opmode:%d",
+		hdd_info_rl("Dynamic set mac address isn't supported for opmode:%d",
 			adapter->device_mode);
 		return false;
 	}
 }
 
-/**
- * hdd_is_dynamic_set_mac_addr_supported() - API to check dynamic MAC address
- *				             update is supported or not
- * @hdd_ctx: Pointer to the HDD context
- *
- * Return: true or false
- */
-static inline bool
-hdd_is_dynamic_set_mac_addr_supported(struct hdd_context *hdd_ctx)
-{
-	return hdd_ctx->is_vdev_macaddr_dynamic_update_supported;
-}
-
 int hdd_dynamic_mac_address_set(struct hdd_context *hdd_ctx,
 				struct hdd_adapter *adapter,
 				struct qdf_mac_addr mac_addr)
@@ -5423,12 +5428,6 @@ static void hdd_set_mac_addr_event_cb(uint8_t vdev_id, uint8_t status)
 	osif_request_put(req);
 }
 #else
-static inline bool
-hdd_is_dynamic_set_mac_addr_allowed(struct hdd_adapter *adapter)
-{
-	return false;
-}
-
 static inline bool
 hdd_is_dynamic_set_mac_addr_supported(struct hdd_context *hdd_ctx)
 {
@@ -5465,13 +5464,8 @@ static int __hdd_set_mac_address(struct net_device *dev, void *addr)
 		return ret;
 
 	if (net_if_running) {
-		if (hdd_is_dynamic_set_mac_addr_supported(hdd_ctx)) {
-			if (!hdd_is_dynamic_set_mac_addr_allowed(adapter))
-				return -ENOTSUPP;
-		} else {
-			hdd_err("On iface up, set mac address change isn't supported");
+		if (!hdd_is_dynamic_set_mac_addr_allowed(adapter))
 			return -ENOTSUPP;
-		}
 	}
 
 	qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr));