Browse Source

qcacld-3.0: Validate the duration and interval for P2P_SET_NOA

The following are the firmware expectations for the parameters
through p2p_set_noa:
If count > 1 , the duration should be smaller than interval.
If count = 1, the duration can be same or smaller as interval.
Hence, set the duration as interval if it is configured
greater than interval.
This commit adds the checks accordingly.
Fails the command if the above conditions do not pass.

Change-Id: Ic273b0167c3551cd4b21d4c6dc7f31ba5329bebc
CRs-Fixed: 2941170
Surya Prakash Sivaraj 3 years ago
parent
commit
1eb074d4a3
1 changed files with 8 additions and 1 deletions
  1. 8 1
      core/hdd/src/wlan_hdd_p2p.c

+ 8 - 1
core/hdd/src/wlan_hdd_p2p.c

@@ -511,6 +511,7 @@ int hdd_set_p2p_noa(struct net_device *dev, uint8_t *command)
 	hdd_debug("P2P_SET GO noa: count=%d interval=%d duration=%d",
 		count, interval, duration);
 	duration = MS_TO_TU_MUS(duration);
+	interval = MS_TO_TU_MUS(interval);
 	/* PS Selection
 	 * Periodic noa (2)
 	 * Single NOA   (4)
@@ -518,15 +519,21 @@ int hdd_set_p2p_noa(struct net_device *dev, uint8_t *command)
 	noa.opp_ps = 0;
 	noa.ct_window = 0;
 	if (count == 1) {
+		if (duration > interval)
+			duration = interval;
 		noa.duration = 0;
 		noa.single_noa_duration = duration;
 		noa.ps_selection = P2P_POWER_SAVE_TYPE_SINGLE_NOA;
 	} else {
+		if (duration >= interval) {
+			hdd_err("Duration should be less than interval");
+			return -EINVAL;
+		}
 		noa.duration = duration;
 		noa.single_noa_duration = 0;
 		noa.ps_selection = P2P_POWER_SAVE_TYPE_PERIODIC_NOA;
 	}
-	noa.interval = MS_TO_TU_MUS(interval);
+	noa.interval = interval;
 	noa.count = count;
 	noa.vdev_id = adapter->vdev_id;