浏览代码

qcacld-3.0: Check for max allowed STA vdevs in hdd_start_adapter()

When set ini gEnableConcurrentSTA to wlan1, two adapters with STA
type will be opened in initialization, in STA+P2P_CLI test case,
it will be failed for checking maximum allowed STA vdevs in change
interface APIs from QDF_P2P_DEVICE_MODE to QDF_P2P_CLIENT_MODE. If
just open adapter with STA type and don't start adapter, it won't
create vdev in firmware.

When do interface up action, hdd_start_adapter() will create vdev in
firmware really, so add interface up status check when checking for
max allowed STA vdevs and check max allowed STA vdevs in
hdd_start_adapter().

Change-Id: I5b2dd09fb58aa3135743a029889e689729bd05a7
CRs-Fixed: 2815174
hqu 4 年之前
父节点
当前提交
592423cb90
共有 2 个文件被更改,包括 43 次插入49 次删除
  1. 0 7
      core/hdd/src/wlan_hdd_cfg80211.c
  2. 43 42
      core/hdd/src/wlan_hdd_main.c

+ 0 - 7
core/hdd/src/wlan_hdd_cfg80211.c

@@ -17067,13 +17067,6 @@ static int __wlan_hdd_cfg80211_change_iface(struct wiphy *wiphy,
 		  qdf_opmode_str(adapter->device_mode),
 		  qdf_opmode_str(new_mode));
 
-	if ((new_mode == QDF_STA_MODE || new_mode == QDF_P2P_CLIENT_MODE) &&
-	    (adapter->device_mode != QDF_STA_MODE &&
-	    adapter->device_mode != QDF_P2P_CLIENT_MODE)) {
-		if (hdd_max_sta_vdev_count_reached(adapter->hdd_ctx))
-			return -EINVAL;
-	}
-
 	errno = hdd_trigger_psoc_idle_restart(hdd_ctx);
 	if (errno) {
 		hdd_err("Failed to restart psoc; errno:%d", errno);

+ 43 - 42
core/hdd/src/wlan_hdd_main.c

@@ -3027,6 +3027,44 @@ wlan_hdd_update_dbs_scan_and_fw_mode_config(void)
 	return status;
 }
 
+/**
+ * hdd_max_sta_interface_up_count_reached() - check sta/p2p_cli vdev count
+ * @adapter: HDD adapter
+ *
+ * Return: true if vdev limit reached
+ */
+static bool hdd_max_sta_interface_up_count_reached(struct hdd_adapter *adapter)
+{
+	struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
+	struct hdd_adapter *temp_adapter = NULL, *next_adapter = NULL;
+	uint8_t intf_count = 0;
+
+	if (0 == CFG_TGT_DEFAULT_MAX_STA_VDEVS)
+		return false;
+
+	/*
+	 * Check for max no of supported STA/P2PCLI VDEVs before
+	 * creating another one.
+	 */
+	hdd_for_each_adapter_dev_held_safe(hdd_ctx, temp_adapter,
+					   next_adapter) {
+		if ((temp_adapter != adapter) &&
+		    (temp_adapter->dev->flags & IFF_UP) &&
+		    ((temp_adapter->device_mode == QDF_STA_MODE) ||
+		     (temp_adapter->device_mode == QDF_P2P_CLIENT_MODE)))
+			intf_count++;
+
+		dev_put(temp_adapter->dev);
+	}
+
+	if (intf_count >= CFG_TGT_DEFAULT_MAX_STA_VDEVS) {
+		hdd_err("Max limit reached sta vdev-current %d max %d",
+			intf_count, CFG_TGT_DEFAULT_MAX_STA_VDEVS);
+		return true;
+	}
+	return false;
+}
+
 /**
  * hdd_start_adapter() - Wrapper function for device specific adapter
  * @adapter: pointer to HDD adapter
@@ -3046,10 +3084,14 @@ int hdd_start_adapter(struct hdd_adapter *adapter)
 	hdd_debug("Start_adapter for mode : %d", adapter->device_mode);
 
 	switch (device_mode) {
+	case QDF_STA_MODE:
 	case QDF_P2P_CLIENT_MODE:
+		if (hdd_max_sta_interface_up_count_reached(adapter))
+			goto err_start_adapter;
+
+	/* fall through */
 	case QDF_P2P_DEVICE_MODE:
 	case QDF_OCB_MODE:
-	case QDF_STA_MODE:
 	case QDF_MONITOR_MODE:
 	case QDF_NAN_DISC_MODE:
 		ret = hdd_start_station_adapter(adapter);
@@ -6339,42 +6381,6 @@ static void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work)
 	osif_vdev_sync_op_stop(vdev_sync);
 }
 
-static u8 hdd_get_mode_specific_interface_count(struct hdd_context *hdd_ctx,
-						enum QDF_OPMODE mode)
-{
-	struct hdd_adapter *adapter = NULL, *next_adapter = NULL;
-	u8 intf_count = 0;
-
-	hdd_for_each_adapter_dev_held_safe(hdd_ctx, adapter, next_adapter) {
-		if (adapter->device_mode == mode)
-			intf_count++;
-
-		dev_put(adapter->dev);
-	}
-	return intf_count;
-}
-
-bool hdd_max_sta_vdev_count_reached(struct hdd_context *hdd_ctx)
-{
-	u8 intf_count;
-
-	/*
-	 * Check for max no of supported STA/P2PCLI VDEVs before
-	 * creating another one.
-	 */
-	intf_count = hdd_get_mode_specific_interface_count(hdd_ctx,
-							   QDF_STA_MODE);
-	intf_count += hdd_get_mode_specific_interface_count(hdd_ctx,
-						QDF_P2P_CLIENT_MODE);
-	if (CFG_TGT_DEFAULT_MAX_STA_VDEVS &&
-	    (intf_count >= CFG_TGT_DEFAULT_MAX_STA_VDEVS)) {
-		hdd_err("Max limit reached sta vdev-current %d max %d",
-			intf_count, CFG_TGT_DEFAULT_MAX_STA_VDEVS);
-		return true;
-	}
-	return false;
-}
-
 /**
  * hdd_open_adapter() - open and setup the hdd adatper
  * @hdd_ctx: global hdd context
@@ -6445,11 +6451,6 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t sessio
 
 	/* fall through */
 	case QDF_P2P_CLIENT_MODE:
-
-		if (hdd_max_sta_vdev_count_reached(hdd_ctx))
-			return NULL;
-
-	/* fall through */
 	case QDF_P2P_DEVICE_MODE:
 	case QDF_OCB_MODE:
 	case QDF_NDI_MODE: