Browse Source

qcacld-3.0: Update rssi when get all tdls peers

It doesn't update rssi of tdls peers. So add logic to update it when
get all tdls peers.

Change-Id: I81d4536b5cb2443b088ee4a5d425d548eac152d6
CRs-Fixed: 2435903
Wu Gao 6 years ago
parent
commit
18e788a176

+ 24 - 18
components/tdls/core/src/wlan_tdls_mgmt.c

@@ -44,31 +44,37 @@ const char *const tdls_action_frames_type[] = { "TDLS Setup Request",
 					 "TDLS Peer Traffic Response",
 					 "TDLS Discovery Request"};
 
-/**
- * tdls_set_rssi() - Set TDLS RSSI on peer given by mac
- * @tdls_vdev: tdls vdev object
- * @mac: MAC address of Peer
- * @rx_rssi: rssi value
- *
- * Set RSSI on TDSL peer
- *
- * Return: 0 for success or -EINVAL otherwise
- */
-static int tdls_set_rssi(struct tdls_vdev_priv_obj *tdls_vdev,
-		  const uint8_t *mac,
-		  int8_t rx_rssi)
+QDF_STATUS tdls_set_rssi(struct wlan_objmgr_vdev *vdev,
+			 uint8_t *mac, int8_t rssi)
 {
+	struct tdls_vdev_priv_obj *tdls_vdev;
 	struct tdls_peer *curr_peer;
 
+	if (!vdev || !mac) {
+		tdls_err("null pointer");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	tdls_debug("rssi %d, peer " QDF_MAC_ADDR_STR,
+		   rssi, QDF_MAC_ADDR_ARRAY(mac));
+
+	tdls_vdev = wlan_objmgr_vdev_get_comp_private_obj(
+			vdev, WLAN_UMAC_COMP_TDLS);
+
+	if (!tdls_vdev) {
+		tdls_err("null tdls vdev");
+		return QDF_STATUS_E_EXISTS;
+	}
+
 	curr_peer = tdls_find_peer(tdls_vdev, mac);
 	if (!curr_peer) {
-		tdls_err("curr_peer is NULL");
-		return -EINVAL;
+		tdls_debug("null peer");
+		return QDF_STATUS_E_EXISTS;
 	}
 
-	curr_peer->rssi = rx_rssi;
+	curr_peer->rssi = rssi;
 
-	return 0;
+	return QDF_STATUS_SUCCESS;
 }
 
 /**
@@ -110,7 +116,7 @@ static QDF_STATUS tdls_process_rx_mgmt(
 		       QDF_MAC_ADDR_STR " RSSI[%d] <--- OTA",
 		       QDF_MAC_ADDR_ARRAY(mac), rx_mgmt->rx_rssi);
 			tdls_recv_discovery_resp(tdls_vdev, mac);
-			tdls_set_rssi(tdls_vdev, mac, rx_mgmt->rx_rssi);
+			tdls_set_rssi(tdls_vdev->vdev, mac, rx_mgmt->rx_rssi);
 	}
 
 	if (rx_mgmt->buf[TDLS_PUBLIC_ACTION_FRAME_OFFSET] ==

+ 13 - 0
components/tdls/core/src/wlan_tdls_mgmt.h

@@ -75,5 +75,18 @@ QDF_STATUS tdls_mgmt_rx_ops(struct wlan_objmgr_psoc *psoc,
  * Return: QDF_STATUS
  */
 QDF_STATUS tdls_process_rx_frame(struct scheduler_msg *msg);
+
+/**
+ * tdls_set_rssi() - Set TDLS RSSI on peer given by mac
+ * @vdev: vdev object
+ * @mac: MAC address of Peer
+ * @rssi: rssi value
+ *
+ * Set RSSI on TDSL peer
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS tdls_set_rssi(struct wlan_objmgr_vdev *vdev,
+			 uint8_t *mac, int8_t rssi);
 #endif
 

+ 18 - 0
components/tdls/dispatcher/inc/wlan_tdls_ucfg_api.h

@@ -256,6 +256,18 @@ QDF_STATUS ucfg_set_tdls_offchan_mode(struct wlan_objmgr_vdev *vdev,
 QDF_STATUS ucfg_set_tdls_secoffchanneloffset(struct wlan_objmgr_vdev *vdev,
 					     int offchanoffset);
 
+/**
+ * ucfg_tdls_set_rssi() - API to set TDLS RSSI on peer given by mac
+ * @vdev: vdev object
+ * @mac: MAC address of Peer
+ * @rssi: rssi value
+ *
+ * Set RSSI on TDLS peer
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS ucfg_tdls_set_rssi(struct wlan_objmgr_vdev *vdev,
+			      uint8_t *mac, int8_t rssi);
 #else
 
 static inline
@@ -313,5 +325,11 @@ QDF_STATUS ucfg_tdls_teardown_links(struct wlan_objmgr_vdev *vdev)
 	return QDF_STATUS_SUCCESS;
 }
 
+static inline
+QDF_STATUS ucfg_tdls_set_rssi(struct wlan_objmgr_vdev *vdev,
+			      uint8_t *mac, int8_t rssi)
+{
+	return QDF_STATUS_SUCCESS;
+}
 #endif /* FEATURE_WLAN_TDLS */
 #endif

+ 6 - 0
components/tdls/dispatcher/src/wlan_tdls_ucfg_api.c

@@ -1110,3 +1110,9 @@ free:
 	qdf_mem_free(req);
 	return status;
 }
+
+QDF_STATUS ucfg_tdls_set_rssi(struct wlan_objmgr_vdev *vdev,
+			      uint8_t *mac, int8_t rssi)
+{
+	return tdls_set_rssi(vdev, mac, rssi);
+}

+ 33 - 0
os_if/tdls/src/wlan_cfg80211_tdls.c

@@ -33,6 +33,9 @@
 #include <qdf_mem.h>
 #include <wlan_utility.h>
 #include <wlan_reg_services_api.h>
+#ifdef QCA_SUPPORT_CP_STATS
+#include "wlan_cfg80211_mc_cp_stats.h"
+#endif
 
 #define MAX_CHANNEL (NUM_24GHZ_CHANNELS + NUM_5GHZ_CHANNELS)
 
@@ -642,6 +645,34 @@ fail:
 	wlan_objmgr_vdev_release_ref(vdev, WLAN_TDLS_NB_ID);
 }
 
+#ifdef QCA_SUPPORT_CP_STATS
+static void wlan_cfg80211_update_tdls_peers_rssi(struct wlan_objmgr_vdev *vdev)
+{
+	int ret = 0, i;
+	struct stats_event *rssi_info;
+	struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT;
+
+	rssi_info = wlan_cfg80211_mc_cp_stats_get_peer_rssi(
+			vdev, bcast_mac.bytes,
+			&ret);
+	if (ret || !rssi_info) {
+		cfg80211_err("get peer rssi fail");
+		wlan_cfg80211_mc_cp_stats_free_stats_event(rssi_info);
+		return;
+	}
+
+	for (i = 0; i < rssi_info->num_peer_stats; i++)
+		ucfg_tdls_set_rssi(vdev, rssi_info->peer_stats[i].peer_macaddr,
+				   rssi_info->peer_stats[i].peer_rssi);
+
+	wlan_cfg80211_mc_cp_stats_free_stats_event(rssi_info);
+}
+#else
+static void wlan_cfg80211_update_tdls_peers_rssi(struct wlan_objmgr_vdev *vdev)
+{
+}
+#endif
+
 int wlan_cfg80211_tdls_get_all_peers(struct wlan_objmgr_vdev *vdev,
 				char *buf, int buflen)
 {
@@ -654,6 +685,8 @@ int wlan_cfg80211_tdls_get_all_peers(struct wlan_objmgr_vdev *vdev,
 	osif_priv = wlan_vdev_get_ospriv(vdev);
 	tdls_priv = osif_priv->osif_tdls;
 
+	wlan_cfg80211_update_tdls_peers_rssi(vdev);
+
 	reinit_completion(&tdls_priv->tdls_user_cmd_comp);
 	status = ucfg_tdls_get_all_peers(vdev, buf, buflen);
 	if (QDF_IS_STATUS_ERROR(status)) {