Browse Source

qcacld-3.0: Add chload param in LL radio stats event

chload is to indicate channel load condition and it is added
in LL radio stats vendor event.

Change-Id: I9371bf69f69ed62cc9dc97b6b2903e631b748ed4
CRs-Fixed: 2990982
Jia Ding 3 years ago
parent
commit
021761043e
1 changed files with 34 additions and 0 deletions
  1. 34 0
      core/hdd/src/wlan_hdd_stats.c

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

@@ -977,6 +977,33 @@ hdd_link_layer_process_iface_stats(struct hdd_adapter *adapter,
 	cfg80211_vendor_cmd_reply(vendor_event);
 }
 
+/**
+ * put_channel_stats_chload - put chload of channel stats
+ * @vendor_event: vendor event
+ * @channel_stats: Pointer to channel stats
+ *
+ * Return: bool
+ */
+static bool put_channel_stats_chload(struct sk_buff *vendor_event,
+				     struct wifi_channel_stats *channel_stats)
+{
+	uint64_t txrx_time;
+	uint32_t chload;
+
+	if (!channel_stats->on_time)
+		return true;
+
+	txrx_time = (channel_stats->tx_time + channel_stats->rx_time) * 100;
+	chload = qdf_do_div(txrx_time, channel_stats->on_time);
+
+	if (nla_put_u8(vendor_event,
+		       QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_LOAD_PERCENTAGE,
+		       chload))
+		return false;
+
+	return true;
+}
+
 /**
  * hdd_llstats_radio_fill_channels() - radio stats fill channels
  * @adapter: Pointer to device adapter
@@ -1051,6 +1078,13 @@ static int hdd_llstats_radio_fill_channels(struct hdd_adapter *adapter,
 					radiostat->num_channels, i);
 				return -EINVAL;
 			}
+
+			if (!put_channel_stats_chload(vendor_event,
+						      channel_stats)) {
+				hdd_err("nla_put failed for chload (%u, %d)",
+					radiostat->num_channels, i);
+				return -EINVAL;
+			}
 		}
 
 		nla_nest_end(vendor_event, chinfo);