qcacld-3.0: Refactor mlo ll interface stats code

Refactor current mlo link layer interface stats code.

Change-Id: I94326ae8fc8abaa2f1abd6d0e0e5ac9a9750433b
CRs-Fixed: 3602068
Šī revīzija ir iekļauta:
Aditya Kodukula
2023-08-29 14:37:21 -07:00
revīziju iesūtīja Rahul Choudhary
vecāks 825a7d1dd9
revīzija bf9795bdea

Parādīt failu

@@ -712,20 +712,21 @@ static void wlan_hdd_update_sinfo(struct station_info *sinfo,
}
static void
wlan_hdd_get_mlo_peers_count(struct hdd_adapter *adapter, uint32_t *num_links)
wlan_hdd_get_mlo_links_count(struct hdd_adapter *adapter, uint32_t *count)
{
struct wlan_hdd_link_info *link_info;
struct hdd_station_ctx *sta_ctx;
u32 num_peers = 0;
u32 num_links = 0;
hdd_adapter_for_each_link_info(adapter, link_info) {
sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
if (sta_ctx->conn_info.ieee_link_id != WLAN_INVALID_LINK_ID)
num_peers++;
num_links++;
}
*num_links = num_peers;
*count = num_links;
}
#else
static inline bool
wlan_hdd_is_per_link_stats_supported(struct hdd_context *hdd_ctx)
@@ -759,7 +760,7 @@ wlan_hdd_update_sinfo(struct station_info *sinfo,
}
static inline void
wlan_hdd_get_mlo_peers_count(struct hdd_adapter *adapter, uint8_t *num_links)
wlan_hdd_get_mlo_links_count(struct hdd_adapter *adapter, uint32_t *count)
{
}
#endif
@@ -911,53 +912,24 @@ static bool put_wifi_peer_rates(struct wifi_peer_info *stats,
#if defined(WLAN_FEATURE_11BE_MLO) && defined(CFG80211_11BE_BASIC)
/**
* wlan_hdd_put_mlo_link_iface_info() - Send per mlo link info to framework
* @hdd_ctx: Pointer to hdd_context
* @if_stat: Pointer to wifi_interface_stats
* @info: Pointer to wlan_hdd_mlo_iface_stats_info struct
* @skb: Pointer to data buffer
*
* Return: True on success, False on failure
*/
static bool
wlan_hdd_put_mlo_link_iface_info(struct hdd_context *hdd_ctx,
struct wifi_interface_stats *if_stat,
wlan_hdd_put_mlo_link_iface_info(struct wlan_hdd_mlo_iface_stats_info *info,
struct sk_buff *skb)
{
struct wlan_hdd_mlo_iface_stats_info info = {0};
struct wlan_hdd_link_info *link_info;
struct hdd_station_ctx *sta_ctx;
if (!if_stat) {
hdd_err("invalid wifi interface stats");
return false;
}
link_info = hdd_get_link_info_by_bssid(hdd_ctx,
(const uint8_t *)if_stat->info.bssid.bytes);
if (!link_info) {
hdd_err("invalid link_info");
return false;
}
sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
info.link_id = sta_ctx->conn_info.ieee_link_id;
info.freq = sta_ctx->conn_info.chan_freq;
if (if_stat->info.state != WIFI_ASSOCIATED) {
hdd_debug_rl("vdev_id[%u] is not associated", if_stat->vdev_id);
return false;
}
if (nla_put_u8(skb,
QCA_WLAN_VENDOR_ATTR_LL_STATS_MLO_LINK_ID,
info.link_id) ||
info->link_id) ||
nla_put_u32(skb,
QCA_WLAN_VENDOR_ATTR_LL_STATS_RADIO_ID,
info.radio_id) ||
info->radio_id) ||
nla_put_u32(skb,
QCA_WLAN_VENDOR_ATTR_LL_STATS_CHANNEL_INFO_CENTER_FREQ,
info.freq)) {
info->freq)) {
hdd_err("wlan_hdd_put_mlo_link_iface_info failed");
return false;
}
@@ -965,6 +937,30 @@ wlan_hdd_put_mlo_link_iface_info(struct hdd_context *hdd_ctx,
return true;
}
/**
* wlan_hdd_get_connected_link_info() - Get connected links' id and frequency
* @link_info: Link info pointerin adapter
* @info: Pointer to wlan_hdd_mlo_iface_stats_info struct
*
* Return: True on success, False on failure
*/
static void
wlan_hdd_get_connected_link_info(struct wlan_hdd_link_info *link_info,
struct wlan_hdd_mlo_iface_stats_info *info)
{
struct hdd_station_ctx *sta_ctx;
if (!link_info) {
hdd_err("Invalid link_info");
info->link_id = WLAN_INVALID_LINK_ID;
return;
}
sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
info->link_id = sta_ctx->conn_info.ieee_link_id;
info->freq = sta_ctx->conn_info.chan_freq;
}
/**
* wlan_hdd_put_mlo_peer_link_id() - send mlo link_id as part of mlo peer stats
* @vendor_event: Pointer to vendor event
@@ -1425,7 +1421,7 @@ bool hdd_get_interface_info(struct wlan_hdd_link_info *link_info,
info->state = WIFI_AUTHENTICATING;
}
if (hdd_cm_is_vdev_associated(link_info) ||
link_info->vdev_id == WLAN_UMAC_VDEV_ID_MAX) {
link_info->vdev_id == WLAN_INVALID_VDEV_ID) {
info->state = WIFI_ASSOCIATED;
qdf_copy_macaddr(&info->bssid,
&sta_ctx->conn_info.bssid);
@@ -1590,36 +1586,6 @@ hdd_cache_ll_iface_stats(struct hdd_context *hdd_ctx,
link_info->ll_iface_stats = *if_stat;
}
/**
* wlan_hdd_get_iface_stats() - Get ll_iface stats info from link_info
* @link_info: Link info pointer of STA adapter
* @if_stat: Pointer to wifi_interface_stats structure
*
* Return: 0 on success, error on failure
*/
static int wlan_hdd_get_iface_stats(struct wlan_hdd_link_info *link_info,
struct wifi_interface_stats *if_stat)
{
if (!link_info || !if_stat) {
hdd_err("Invalid link_info or interface stats");
return -EINVAL;
}
if (link_info->vdev_id == WLAN_UMAC_VDEV_ID_MAX)
link_info->ll_iface_stats.vdev_id = WLAN_UMAC_VDEV_ID_MAX;
qdf_mem_copy(if_stat, &link_info->ll_iface_stats,
sizeof(link_info->ll_iface_stats));
if (!hdd_get_interface_info(link_info, &if_stat->info)) {
hdd_err("Unable to get iface info for vdev[%u]",
if_stat->vdev_id);
return -EINVAL;
}
return 0;
}
/**
* wlan_hdd_update_wmm_ac_stats() - Populate ll_iface ac stats
* @link_info: Link info pointer of STA adapter
@@ -1809,25 +1775,81 @@ exit:
#ifndef WLAN_HDD_MULTI_VDEV_SINGLE_NDEV
/**
* wlan_hdd_send_mlo_ll_iface_stats() - send mlo ll stats to userspace
* wlan_hdd_get_iface_stats() - Get ll_iface stats info from link_info
* @link_info: Link info pointer of STA adapter
* @if_stat: Pointer to wifi_interface_stats structure
*
* Return: 0 on success, error on failure
*/
static int wlan_hdd_get_iface_stats(struct wlan_hdd_link_info *link_info,
struct wifi_interface_stats *if_stat)
{
if (!link_info || !if_stat) {
hdd_err("Invalid link_info or interface stats");
return -EINVAL;
}
qdf_mem_copy(if_stat, &link_info->ll_iface_stats,
sizeof(link_info->ll_iface_stats));
if (!hdd_get_interface_info(link_info, &if_stat->info)) {
hdd_err("Unable to get iface info for vdev[%u]",
if_stat->vdev_id);
return -EINVAL;
}
return 0;
}
static bool
wlan_hdd_get_mlo_iface_info(struct hdd_context *hdd_ctx,
struct wifi_interface_stats *stats,
struct wlan_hdd_mlo_iface_stats_info *info)
{
struct wlan_hdd_link_info *link_info;
struct hdd_station_ctx *sta_ctx;
if (!stats) {
hdd_err("invalid wifi interface stats");
return false;
}
link_info = hdd_get_link_info_by_bssid(hdd_ctx,
(const uint8_t *)stats->info.bssid.bytes);
if (!link_info) {
hdd_err("invalid link_info");
return false;
}
sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(link_info);
info->link_id = sta_ctx->conn_info.ieee_link_id;
info->freq = sta_ctx->conn_info.chan_freq;
return true;
}
/**
* wlan_hdd_send_mlo_ll_iface_stats_to_user() - send mlo ll stats to userspace
* @adapter: Pointer to adapter
*
* Return: none
*/
static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
static void
wlan_hdd_send_mlo_ll_iface_stats_to_user(struct hdd_adapter *adapter)
{
struct hdd_mlo_adapter_info *mlo_adapter_info;
struct hdd_adapter *link_adapter, *ml_adapter;
struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
u32 num_peers, per_link_peers;
u32 num_links, per_link_peers;
uint8_t i, j = 0;
int8_t rssi;
struct wifi_interface_stats cumulative_if_stat = {0};
struct wlan_hdd_mlo_iface_stats_info info = {0};
struct wifi_interface_stats *link_if_stat;
bool update_stats = false;
QDF_STATUS status;
struct nlattr *ml_if_stats_nest;
struct nlattr *ml_iface_stats;
struct nlattr *ml_iface_nest, *ml_iface_links;
struct sk_buff *skb;
struct wlan_hdd_link_info *link_info;
struct qdf_mac_addr *netdev_addr;
@@ -1843,8 +1865,7 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
link_info = ml_adapter->deflink;
rssi = link_info->rssi;
wlan_hdd_get_mlo_peers_count(adapter, &num_peers);
num_peers = hdd_ctx->num_mlo_peers;
wlan_hdd_get_mlo_links_count(adapter, &num_links);
skb = wlan_cfg80211_vendor_cmd_alloc_reply_skb(hdd_ctx->wiphy,
LL_STATS_EVENT_BUF_SIZE);
@@ -1854,13 +1875,13 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
return;
}
link_if_stat = qdf_mem_malloc(sizeof(*link_if_stat) * num_peers);
link_if_stat = qdf_mem_malloc(sizeof(*link_if_stat) * num_links);
if (!link_if_stat) {
hdd_err("failed to allocate memory for link iface stat");
goto err;
}
hdd_debug("WMI_MLO_LINK_STATS_IFACE Data. Num_peers = %u", num_peers);
hdd_debug("WMI_MLO_LINK_STATS_IFACE Data. Num_links = %u", num_links);
if (!hdd_get_interface_info(link_info, &cumulative_if_stat.info)) {
hdd_err("hdd_get_interface_info get fail for ml_adapter");
@@ -1889,15 +1910,15 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
&link_if_stat[j]))
goto err;
j++;
if (j == num_peers)
if (j == num_links)
break;
continue;
}
if (wlan_hdd_get_iface_stats(link_info, &link_if_stat[i]))
if (wlan_hdd_get_iface_stats(link_info, &link_if_stat[j]))
goto err;
j++;
if (j == num_peers)
if (j == num_links)
break;
if (rssi <= link_info->rssi) {
@@ -1918,21 +1939,21 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
if (QDF_IS_STATUS_ERROR(status))
hdd_err_rl("mlo_iface_stats: failed to get bss peer_mld_mac");
if (!put_wifi_iface_stats(&cumulative_if_stat, num_peers, skb)) {
if (!put_wifi_iface_stats(&cumulative_if_stat, num_links, skb)) {
hdd_err("put_wifi_iface_stats fail");
goto err;
}
ml_if_stats_nest = nla_nest_start(skb,
QCA_WLAN_VENDOR_ATTR_LL_STATS_MLO_LINK);
if (!ml_if_stats_nest) {
ml_iface_nest = nla_nest_start(skb,
QCA_WLAN_VENDOR_ATTR_LL_STATS_MLO_LINK);
if (!ml_iface_nest) {
hdd_err("Nesting mlo iface stats info failed");
goto err;
}
for (i = 0; i < num_peers; i++) {
ml_iface_stats = nla_nest_start(skb, i);
if (!ml_iface_stats) {
for (i = 0; i < num_links; i++) {
ml_iface_links = nla_nest_start(skb, i);
if (!ml_iface_links) {
hdd_err("per link mlo iface stats failed");
goto err;
}
@@ -1940,8 +1961,11 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
per_link_peers =
link_info->ll_iface_stats.link_stats.num_peers;
if (!wlan_hdd_put_mlo_link_iface_info(hdd_ctx,
&link_if_stat[i], skb))
if (!wlan_hdd_get_mlo_iface_info(hdd_ctx,
&link_if_stat[i], &info))
goto err;
if (!wlan_hdd_put_mlo_link_iface_info(&info, skb))
goto err;
if (!put_wifi_iface_stats(&link_if_stat[i],
@@ -1950,9 +1974,9 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
goto err;
}
nla_nest_end(skb, ml_iface_stats);
nla_nest_end(skb, ml_iface_links);
}
nla_nest_end(skb, ml_if_stats_nest);
nla_nest_end(skb, ml_iface_nest);
wlan_cfg80211_vendor_cmd_reply(skb);
qdf_mem_free(link_if_stat);
@@ -1963,18 +1987,20 @@ err:
qdf_mem_free(link_if_stat);
}
#else
static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
static void
wlan_hdd_send_mlo_ll_iface_stats_to_user(struct hdd_adapter *adapter)
{
struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
u32 num_peers, per_link_peers;
u32 num_links, per_link_peers;
uint8_t i = 0;
int8_t rssi = WLAN_INVALID_PER_CHAIN_RSSI;
struct wifi_interface_stats cumulative_if_stat = {0};
struct wifi_interface_stats *link_if_stat;
struct wlan_hdd_mlo_iface_stats_info info = {0};
struct wifi_interface_stats *stats;
struct wifi_interface_info *iface_info;
bool update_stats;
QDF_STATUS status;
struct nlattr *ml_if_stats_nest;
struct nlattr *ml_iface_stats;
struct nlattr *ml_iface_nest, *ml_iface_links;
struct sk_buff *skb;
struct wlan_hdd_link_info *link_info;
struct qdf_mac_addr *netdev_addr;
@@ -1995,45 +2021,30 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
return;
}
wlan_hdd_get_mlo_peers_count(adapter, &num_peers);
wlan_hdd_get_mlo_links_count(adapter, &num_links);
hdd_debug("WMI_MLO_LINK_STATS_IFACE Data. Num_peers = %u", num_peers);
link_if_stat = qdf_mem_malloc(sizeof(*link_if_stat) * num_peers);
if (!link_if_stat) {
hdd_err("failed to allocate memory for link iface stat");
goto err;
}
if (!hdd_get_interface_info(adapter->deflink,
&cumulative_if_stat.info)) {
hdd_err("hdd_get_interface_info get fail for ml_adapter");
goto err;
}
hdd_debug("WMI_MLO_LINK_STATS_IFACE Data. Num_links = %u", num_links);
hdd_adapter_for_each_link_info(adapter, link_info) {
if (link_info->rssi != 0 &&
rssi <= link_info->rssi) {
wlan_hdd_get_connected_link_info(link_info, &info);
if (info.link_id == WLAN_INVALID_LINK_ID)
continue;
if ((link_info->rssi != 0) && (rssi <= link_info->rssi)) {
rssi = link_info->rssi;
update_stats = true;
} else {
update_stats = false;
}
if (wlan_hdd_get_iface_stats(link_info, &link_if_stat[i]))
iface_info = &link_info->ll_iface_stats.info;
if (!hdd_get_interface_info(link_info, iface_info)) {
hdd_err("get iface info failed for link %u", info.link_id);
goto err;
if (link_info->vdev_id != WLAN_UMAC_VDEV_ID_MAX)
qdf_mem_copy(&link_info->ll_iface_stats,
&link_if_stat[i],
sizeof(*link_if_stat));
}
wlan_hdd_update_iface_stats_info(link_info, &cumulative_if_stat,
update_stats);
i++;
if (i == num_peers)
break;
}
netdev_addr = hdd_adapter_get_netdev_mac_addr(adapter);
@@ -2044,50 +2055,51 @@ static void wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
if (QDF_IS_STATUS_ERROR(status))
hdd_err_rl("mlo_iface_stats: failed to get bss peer_mld_mac");
if (!put_wifi_iface_stats(&cumulative_if_stat, num_peers, skb)) {
if (!put_wifi_iface_stats(&cumulative_if_stat, num_links, skb)) {
hdd_err("put_wifi_iface_stats fail");
goto err;
}
ml_if_stats_nest =
ml_iface_nest =
nla_nest_start(skb, QCA_WLAN_VENDOR_ATTR_LL_STATS_MLO_LINK);
if (!ml_if_stats_nest) {
if (!ml_iface_nest) {
hdd_err("Nesting mlo iface stats info failed");
goto err;
}
for (i = 0; i < num_peers; i++) {
ml_iface_stats = nla_nest_start(skb, i);
if (!ml_iface_stats) {
hdd_adapter_for_each_link_info(adapter, link_info) {
ml_iface_links = nla_nest_start(skb, i);
if (!ml_iface_links) {
hdd_err("per link mlo iface stats failed");
goto err;
}
per_link_peers =
adapter->deflink->ll_iface_stats.link_stats.num_peers;
wlan_hdd_get_connected_link_info(link_info, &info);
if (info.link_id == WLAN_INVALID_LINK_ID)
continue;
if (!wlan_hdd_put_mlo_link_iface_info(hdd_ctx,
&link_if_stat[i], skb))
stats = &link_info->ll_iface_stats;
per_link_peers = stats->link_stats.num_peers;
if (!wlan_hdd_put_mlo_link_iface_info(&info, skb))
goto err;
if (!put_wifi_iface_stats(&link_if_stat[i],
per_link_peers, skb)) {
hdd_err("put_wifi_iface_stats failed for link[%u]", i);
if (!put_wifi_iface_stats(stats, per_link_peers, skb)) {
hdd_err("put iface stats failed for link[%u]", info.link_id);
goto err;
}
nla_nest_end(skb, ml_iface_stats);
nla_nest_end(skb, ml_iface_links);
i++;
}
nla_nest_end(skb, ml_if_stats_nest);
nla_nest_end(skb, ml_iface_nest);
wlan_cfg80211_vendor_cmd_reply(skb);
qdf_mem_free(link_if_stat);
hdd_nofl_debug("Sent mlo interface stats to userspace");
return;
err:
wlan_cfg80211_vendor_free_skb(skb);
qdf_mem_free(link_if_stat);
}
#endif
#else
@@ -2098,7 +2110,7 @@ hdd_cache_ll_iface_stats(struct hdd_context *hdd_ctx,
}
static inline void
wlan_hdd_send_mlo_ll_iface_stats(struct hdd_adapter *adapter)
wlan_hdd_send_mlo_ll_iface_stats_to_user(struct hdd_adapter *adapter)
{
}
@@ -3318,8 +3330,9 @@ static QDF_STATUS wlan_hdd_stats_request_needed(struct hdd_adapter *adapter)
}
#endif /* FEATURE_CLUB_LL_STATS_AND_GET_STATION */
static void wlan_hdd_send_mlo_ll_stats(struct wlan_hdd_link_info *link_info,
void *mlo_peer_stats)
static void
wlan_hdd_send_mlo_ll_stats_to_user(struct wlan_hdd_link_info *link_info,
void *mlo_peer_stats)
{
if (!link_info) {
hdd_err("Invalid link_info");
@@ -3329,7 +3342,7 @@ static void wlan_hdd_send_mlo_ll_stats(struct wlan_hdd_link_info *link_info,
if (!wlan_hdd_is_mlo_connection(link_info))
return;
wlan_hdd_send_mlo_ll_iface_stats(link_info->adapter);
wlan_hdd_send_mlo_ll_iface_stats_to_user(link_info->adapter);
wlan_hdd_send_mlo_ll_peer_stats(link_info->adapter->hdd_ctx,
(struct wifi_peer_stat *)mlo_peer_stats);
}
@@ -3445,7 +3458,7 @@ static int wlan_hdd_send_ll_stats_req(struct wlan_hdd_link_info *link_info,
qdf_list_destroy(&priv->ll_stats_q);
if (!ret && req->reqId != DEBUGFS_LLSTATS_REQID)
wlan_hdd_send_mlo_ll_stats(link_info, mlo_stats);
wlan_hdd_send_mlo_ll_stats_to_user(link_info, mlo_stats);
qdf_mem_free(mlo_stats);