Browse Source

qcacld-3.0: Clear ftm_time_sync offset on disconnect and add bssid in sysfs

The Qtime offset derived with a connected AP (master) are not
cleared on disconnect. This leads to storage of stale offset
values. So clear the stale Qtime offset values on disconnection.

Currently there is no information in ftm_time_sync sysfs entry
regarding which BSSID the Qtime offset values are derived.
Add the BSSID info in the sysfs entry.

Change-Id: Iac47bccffae005602469a658e5ca0bc9008ac4b4
CRs-Fixed: 2629822
Surabhi Vishnoi 5 years ago
parent
commit
85d94fc4b9

+ 11 - 0
components/ftm_time_sync/core/inc/ftm_time_sync_main.h

@@ -168,4 +168,15 @@ QDF_STATUS ftm_time_sync_stop(struct wlan_objmgr_vdev *vdev);
  * Return: the number of bytes written in buf
  */
 ssize_t ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf);
+
+/**
+ * ftm_time_sync_update_bssid() - Update the bssid info
+ * @vdev: vdev context
+ * @bssid: bssid of connected AP
+ *
+ * Return: None
+ */
+void ftm_time_sync_update_bssid(struct wlan_objmgr_vdev *vdev,
+				struct qdf_mac_addr bssid);
+
 #endif /* end of _FTM_TIME_SYNC_MAIN_H_ */

+ 2 - 0
components/ftm_time_sync/core/inc/ftm_time_sync_priv.h

@@ -89,6 +89,7 @@ struct ftm_time_sync_psoc_priv {
  * @num_qtime_pair: number of qmaster and qslave pair derived
  * @num_reads: number of times the qtime to be captured
  * @valid: send qtime to FW only if this is true
+ * @bssid: bssid of connected AP
  */
 struct ftm_time_sync_vdev_priv {
 	struct wlan_objmgr_vdev *vdev;
@@ -101,6 +102,7 @@ struct ftm_time_sync_vdev_priv {
 	int num_qtime_pair;
 	int num_reads;
 	bool valid;
+	struct qdf_mac_addr bssid;
 };
 
 #endif /* End  of _FTM_TIME_SYNC_PRIV_STRUCT_H_ */

+ 24 - 0
components/ftm_time_sync/core/src/ftm_time_sync_main.c

@@ -361,6 +361,7 @@ QDF_STATUS ftm_time_sync_send_trigger(struct wlan_objmgr_vdev *vdev)
 QDF_STATUS ftm_time_sync_stop(struct wlan_objmgr_vdev *vdev)
 {
 	struct ftm_time_sync_vdev_priv *vdev_priv;
+	int iter;
 
 	vdev_priv = ftm_time_sync_vdev_get_priv(vdev);
 	if (!vdev_priv) {
@@ -370,6 +371,13 @@ QDF_STATUS ftm_time_sync_stop(struct wlan_objmgr_vdev *vdev)
 
 	qdf_delayed_work_stop_sync(&vdev_priv->ftm_time_sync_work);
 
+	for (iter = 0; iter < vdev_priv->num_qtime_pair; iter++) {
+		vdev_priv->ftm_ts_priv.time_pair[iter].qtime_master = 0;
+		vdev_priv->ftm_ts_priv.time_pair[iter].qtime_slave = 0;
+	}
+
+	vdev_priv->num_qtime_pair = 0;
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -386,6 +394,9 @@ ssize_t ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf)
 		return 0;
 	}
 
+	size = qdf_scnprintf(buf, PAGE_SIZE, "%s %pM\n", "BSSID",
+			     vdev_priv->bssid.bytes);
+
 	for (iter = 0; iter < vdev_priv->num_qtime_pair; iter++) {
 		q_master = vdev_priv->ftm_ts_priv.time_pair[iter].qtime_master;
 		q_slave = vdev_priv->ftm_ts_priv.time_pair[iter].qtime_slave;
@@ -399,3 +410,16 @@ ssize_t ftm_time_sync_show(struct wlan_objmgr_vdev *vdev, char *buf)
 	return size;
 }
 
+void ftm_time_sync_update_bssid(struct wlan_objmgr_vdev *vdev,
+				struct qdf_mac_addr bssid)
+{
+	struct ftm_time_sync_vdev_priv *vdev_priv;
+
+	vdev_priv = ftm_time_sync_vdev_get_priv(vdev);
+	if (!vdev_priv) {
+		ftm_time_sync_debug("Failed to get ftm time sync vdev_priv");
+		return;
+	}
+
+	vdev_priv->bssid = bssid;
+}

+ 3 - 1
components/ftm_time_sync/dispatcher/inc/ftm_time_sync_ucfg_api.h

@@ -74,6 +74,7 @@ void ucfg_ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool value);
  * ucfg_ftm_time_sync_update_sta_connect_state() - Handler for STA state change
  * @vdev: STA vdev
  * @state: connected/disconnected state
+ * @bssid: bssid of connected AP
  *
  * This function triggers the FTM time sync feature in case of connection and
  * stops the ftm sync feature in case of disconnection.
@@ -82,7 +83,8 @@ void ucfg_ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool value);
  */
 void
 ucfg_ftm_time_sync_update_sta_connect_state(struct wlan_objmgr_vdev *vdev,
-					    enum ftm_time_sync_sta_state state);
+					    enum ftm_time_sync_sta_state state,
+					    struct qdf_mac_addr bssid);
 
 /**
  * ucfg_ftm_time_sync_update_bss_state() - Handler to notify bss start/stop

+ 4 - 1
components/ftm_time_sync/dispatcher/src/ftm_time_sync_ucfg_api.c

@@ -123,7 +123,8 @@ void ucfg_ftm_time_sync_set_enable(struct wlan_objmgr_psoc *psoc, bool enable)
 
 void ucfg_ftm_time_sync_update_sta_connect_state(
 					struct wlan_objmgr_vdev *vdev,
-					enum ftm_time_sync_sta_state sta_state)
+					enum ftm_time_sync_sta_state sta_state,
+					struct qdf_mac_addr bssid)
 {
 	struct wlan_objmgr_psoc *psoc;
 	enum ftm_time_sync_role role;
@@ -140,6 +141,8 @@ void ucfg_ftm_time_sync_update_sta_connect_state(
 			ftm_time_sync_send_trigger(vdev);
 		else
 			ftm_time_sync_stop(vdev);
+
+		ftm_time_sync_update_bssid(vdev, bssid);
 	}
 }
 

+ 5 - 1
core/hdd/src/wlan_hdd_ftm_time_sync.c

@@ -44,6 +44,7 @@ void
 hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
 				   enum ftm_time_sync_sta_state state)
 {
+	struct hdd_station_ctx *hdd_sta_ctx;
 	struct wlan_objmgr_psoc *psoc;
 	struct net_device *net_dev;
 
@@ -65,5 +66,8 @@ hdd_ftm_time_sync_sta_state_notify(struct hdd_adapter *adapter,
 					   &dev_attr_ftm_time_sync);
 	}
 
-	ucfg_ftm_time_sync_update_sta_connect_state(adapter->vdev, state);
+	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+	ucfg_ftm_time_sync_update_sta_connect_state(
+						adapter->vdev, state,
+						hdd_sta_ctx->conn_info.bssid);
 }