Browse Source

qcacld-3.0: Support tx_bitrate for SON node info

tx_bitrate is used as indication of macThroughputCapacity in transmitter
link metric for backhaul STA link.

tx_bitrate is added in wlan_node_info structure and os_if interface is
exposed so that SON module could get the tx_bitrate parameter.

Change-Id: Ib9949906b3247519bf8c1ce786d6b93d38d4d8ea
CRs-Fixed: 3154548
Jia Ding 2 years ago
parent
commit
0e8a200692

+ 44 - 3
core/hdd/src/wlan_hdd_son.c

@@ -2276,9 +2276,36 @@ wlan_hdd_son_get_ieee_phymode(enum wlan_phymode wlan_phymode)
 	return wlanphymode2ieeephymode[wlan_phymode];
 }
 
-static QDF_STATUS hdd_son_get_node_info(struct wlan_objmgr_vdev *vdev,
-					uint8_t *mac_addr,
-					wlan_node_info *node_info)
+static QDF_STATUS hdd_son_get_node_info_sta(struct wlan_objmgr_vdev *vdev,
+					    uint8_t *mac_addr,
+					    wlan_node_info *node_info)
+{
+	struct hdd_adapter *adapter = wlan_hdd_get_adapter_from_objmgr(vdev);
+	struct hdd_station_ctx *sta_ctx;
+	struct hdd_context *hdd_ctx;
+
+	hdd_ctx = adapter->hdd_ctx;
+	if (wlan_hdd_validate_context(hdd_ctx))
+		return QDF_STATUS_E_FAILURE;
+
+	if (!hdd_cm_is_vdev_associated(adapter)) {
+		hdd_debug_rl("STA adapter not connected");
+		/* Still return success and framework will see default stats */
+		return QDF_STATUS_SUCCESS;
+	}
+
+	hdd_get_max_tx_bitrate(hdd_ctx, adapter);
+
+	sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+	node_info->tx_bitrate = cfg80211_calculate_bitrate(
+			&sta_ctx->cache_conn_info.max_tx_bitrate);
+	hdd_debug("tx_bitrate %u", node_info->tx_bitrate);
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS hdd_son_get_node_info_sap(struct wlan_objmgr_vdev *vdev,
+					    uint8_t *mac_addr,
+					    wlan_node_info *node_info)
 {
 	struct hdd_adapter *adapter = wlan_hdd_get_adapter_from_objmgr(vdev);
 	struct hdd_station_info *sta_info;
@@ -2321,6 +2348,20 @@ static QDF_STATUS hdd_son_get_node_info(struct wlan_objmgr_vdev *vdev,
 	return QDF_STATUS_SUCCESS;
 }
 
+static QDF_STATUS hdd_son_get_node_info(struct wlan_objmgr_vdev *vdev,
+					uint8_t *mac_addr,
+					wlan_node_info *node_info)
+{
+	struct hdd_adapter *adapter = wlan_hdd_get_adapter_from_objmgr(vdev);
+
+	if (adapter->device_mode == QDF_STA_MODE)
+		return hdd_son_get_node_info_sta(vdev, mac_addr, node_info);
+	else if (adapter->device_mode == QDF_SAP_MODE)
+		return hdd_son_get_node_info_sap(vdev, mac_addr, node_info);
+	else
+		return QDF_STATUS_SUCCESS;
+}
+
 static QDF_STATUS hdd_son_get_peer_capability(struct wlan_objmgr_vdev *vdev,
 					      struct wlan_objmgr_peer *peer,
 					      wlan_peer_cap *peer_cap)

+ 1 - 60
core/hdd/src/wlan_hdd_station_info.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -442,65 +442,6 @@ fail:
 	return -EINVAL;
 }
 
-/**
- * hdd_get_max_tx_bitrate() - Get the max tx bitrate of the AP
- * @hdd_ctx: hdd context
- * @adapter: hostapd interface
- *
- * THis function gets the MAX supported rate by AP and cache
- * it into connection info structure
- *
- * Return: None
- */
-static void hdd_get_max_tx_bitrate(struct hdd_context *hdd_ctx,
-				   struct hdd_adapter *adapter)
-{
-	struct station_info sinfo;
-	enum tx_rate_info tx_rate_flags;
-	uint8_t tx_mcs_index, tx_nss = 1;
-	uint16_t my_tx_rate;
-	struct hdd_station_ctx *hdd_sta_ctx;
-	struct wlan_objmgr_vdev *vdev;
-
-	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
-
-	qdf_mem_zero(&sinfo, sizeof(struct station_info));
-
-	sinfo.signal = adapter->rssi;
-	tx_rate_flags = adapter->hdd_stats.class_a_stat.tx_rx_rate_flags;
-	tx_mcs_index = adapter->hdd_stats.class_a_stat.tx_mcs_index;
-	my_tx_rate = adapter->hdd_stats.class_a_stat.tx_rate;
-
-	if (!(tx_rate_flags & TX_RATE_LEGACY)) {
-		vdev = hdd_objmgr_get_vdev_by_user(adapter,
-						   WLAN_OSIF_STATS_ID);
-		if (vdev) {
-			/*
-			 * Take static NSS for reporting max rates.
-			 * NSS from FW is not reliable as it changes
-			 * as per the environment quality.
-			 */
-			tx_nss = wlan_vdev_mlme_get_nss(vdev);
-			hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_STATS_ID);
-		} else {
-			tx_nss = adapter->hdd_stats.class_a_stat.tx_nss;
-		}
-		hdd_check_and_update_nss(hdd_ctx, &tx_nss, NULL);
-
-		if (tx_mcs_index == INVALID_MCS_IDX)
-			tx_mcs_index = 0;
-	}
-
-	if (hdd_report_max_rate(adapter, hdd_ctx->mac_handle, &sinfo.txrate,
-				sinfo.signal, tx_rate_flags, tx_mcs_index,
-				my_tx_rate, tx_nss)) {
-		hdd_sta_ctx->cache_conn_info.max_tx_bitrate = sinfo.txrate;
-		hdd_debug("Reporting max tx rate flags %d mcs %d nss %d bw %d",
-			  sinfo.txrate.flags, sinfo.txrate.mcs,
-			  sinfo.txrate.nss, sinfo.txrate.bw);
-	}
-}
-
 /**
  * hdd_add_sta_info() - add station info attribute
  * @skb: pointer to sk buff

+ 49 - 0
core/hdd/src/wlan_hdd_stats.c

@@ -5376,6 +5376,55 @@ static void wlan_hdd_fill_os_rate_info(enum tx_rate_info rate_flags,
 		os_rate->flags |= RATE_INFO_FLAGS_SHORT_GI;
 }
 
+void hdd_get_max_tx_bitrate(struct hdd_context *hdd_ctx,
+			    struct hdd_adapter *adapter)
+{
+	struct station_info sinfo;
+	enum tx_rate_info tx_rate_flags;
+	uint8_t tx_mcs_index, tx_nss = 1;
+	uint16_t my_tx_rate;
+	struct hdd_station_ctx *hdd_sta_ctx;
+	struct wlan_objmgr_vdev *vdev;
+
+	hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
+
+	qdf_mem_zero(&sinfo, sizeof(struct station_info));
+
+	sinfo.signal = adapter->rssi;
+	tx_rate_flags = adapter->hdd_stats.class_a_stat.tx_rx_rate_flags;
+	tx_mcs_index = adapter->hdd_stats.class_a_stat.tx_mcs_index;
+	my_tx_rate = adapter->hdd_stats.class_a_stat.tx_rate;
+
+	if (!(tx_rate_flags & TX_RATE_LEGACY)) {
+		vdev = hdd_objmgr_get_vdev_by_user(adapter,
+						   WLAN_OSIF_STATS_ID);
+		if (vdev) {
+			/*
+			 * Take static NSS for reporting max rates.
+			 * NSS from FW is not reliable as it changes
+			 * as per the environment quality.
+			 */
+			tx_nss = wlan_vdev_mlme_get_nss(vdev);
+			hdd_objmgr_put_vdev_by_user(vdev, WLAN_OSIF_STATS_ID);
+		} else {
+			tx_nss = adapter->hdd_stats.class_a_stat.tx_nss;
+		}
+		hdd_check_and_update_nss(hdd_ctx, &tx_nss, NULL);
+
+		if (tx_mcs_index == INVALID_MCS_IDX)
+			tx_mcs_index = 0;
+	}
+
+	if (hdd_report_max_rate(adapter, hdd_ctx->mac_handle, &sinfo.txrate,
+				sinfo.signal, tx_rate_flags, tx_mcs_index,
+				my_tx_rate, tx_nss)) {
+		hdd_sta_ctx->cache_conn_info.max_tx_bitrate = sinfo.txrate;
+		hdd_debug("Reporting max tx rate flags %d mcs %d nss %d bw %d",
+			  sinfo.txrate.flags, sinfo.txrate.mcs,
+			  sinfo.txrate.nss, sinfo.txrate.bw);
+	}
+}
+
 bool hdd_report_max_rate(struct hdd_adapter *adapter,
 			 mac_handle_t mac_handle,
 			 struct rate_info *rate,

+ 13 - 0
core/hdd/src/wlan_hdd_stats.h

@@ -570,6 +570,19 @@ int wlan_hdd_get_temperature(struct hdd_adapter *adapter, int *temperature);
  */
 void wlan_hdd_display_txrx_stats(struct hdd_context *hdd_ctx);
 
+/**
+ * hdd_get_max_tx_bitrate() - Get the max tx bitrate of the AP
+ * @hdd_ctx: hdd context
+ * @adapter: hostapd interface
+ *
+ * THis function gets the MAX supported rate by AP and cache
+ * it into connection info structure
+ *
+ * Return: None
+ */
+void hdd_get_max_tx_bitrate(struct hdd_context *hdd_ctx,
+			    struct hdd_adapter *adapter);
+
 /**
  * hdd_report_max_rate() - Fill the max rate stats in the station info structure
  * to be sent to the userspace.

+ 2 - 0
os_if/son/src/os_if_son.c

@@ -1783,6 +1783,8 @@ QDF_STATUS os_if_son_get_node_datarate_info(struct wlan_objmgr_vdev *vdev,
 	return status;
 }
 
+qdf_export_symbol(os_if_son_get_node_datarate_info);
+
 uint32_t os_if_son_get_peer_max_mcs_idx(struct wlan_objmgr_vdev *vdev,
 					struct wlan_objmgr_peer *peer)
 {