From e3e37ff9f78cfe93525d640c858d113a2f0e6d0d Mon Sep 17 00:00:00 2001 From: Tim Zimmermann Date: Sun, 3 Mar 2024 13:29:22 +0100 Subject: [PATCH] bcmdhd.101.10.361.x: Align link layer stats with AOSP HAL code Fixes: 02-25 07:14:06.397 6516 6707 E WifiStaIfaceAidlImpl: getLinkLayerStats failed with service-specific exception: android.os.ServiceSpecificException: (code 9) Change-Id: I451941bbdac98c1a208bce9ee54d1760259f65c9 --- bcmdhd.101.10.361.x/include/dngl_stats.h | 9 ++++++++ bcmdhd.101.10.361.x/wifi_stats.h | 9 ++++++++ bcmdhd.101.10.361.x/wl_cfgvendor.c | 26 +++++++++++++++++++++--- bcmdhd.101.10.361.x/wl_cfgvendor.h | 8 ++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/bcmdhd.101.10.361.x/include/dngl_stats.h b/bcmdhd.101.10.361.x/include/dngl_stats.h index 12195f2..f43d6cc 100755 --- a/bcmdhd.101.10.361.x/include/dngl_stats.h +++ b/bcmdhd.101.10.361.x/include/dngl_stats.h @@ -204,6 +204,8 @@ typedef struct { wifi_radio radio; uint32 on_time; uint32 tx_time; + uint32 num_tx_levels; + uint32 *tx_time_per_levels; uint32 rx_time; uint32 on_time_scan; uint32 on_time_nbd; @@ -259,10 +261,17 @@ typedef enum } wifi_peer_type; /* per peer statistics */ +typedef struct { + uint16 sta_count; /* station count */ + uint16 chan_util; /* channel utilization */ + uint8 PAD[4]; +} bssload_info_t; + typedef struct { wifi_peer_type type; /* peer type (AP, TDLS, GO etc.) */ uint8 peer_mac_address[6]; /* mac address */ uint32 capabilities; /* peer WIFI_CAPABILITY_XXX */ + bssload_info_t bssload; /* STA count and CU */ uint32 num_rate; /* number of rates */ wifi_rate_stat rate_stats[1]; /* per rate statistics, number of entries = num_rate */ } wifi_peer_info; diff --git a/bcmdhd.101.10.361.x/wifi_stats.h b/bcmdhd.101.10.361.x/wifi_stats.h index a4d2e73..d74ae93 100755 --- a/bcmdhd.101.10.361.x/wifi_stats.h +++ b/bcmdhd.101.10.361.x/wifi_stats.h @@ -191,6 +191,8 @@ typedef struct { wifi_radio radio; uint32 on_time; uint32 tx_time; + uint32 num_tx_levels; + uint32 *tx_time_per_levels; uint32 rx_time; uint32 on_time_scan; uint32 on_time_nbd; @@ -246,10 +248,17 @@ typedef enum } wifi_peer_type; /* per peer statistics */ +typedef struct bssload_info { + uint16 sta_count; /* station count */ + uint16 chan_util; /* channel utilization */ + u8 PAD[4]; +} bssload_info_t; + typedef struct { wifi_peer_type type; /* peer type (AP, TDLS, GO etc.) */ uint8 peer_mac_address[6]; /* mac address */ uint32 capabilities; /* peer WIFI_CAPABILITY_XXX */ + bssload_info_t bssload; /* STA count and CU */ uint32 num_rate; /* number of rates */ wifi_rate_stat rate_stats[1]; /* per rate statistics, number of entries = num_rate */ } wifi_peer_info; diff --git a/bcmdhd.101.10.361.x/wl_cfgvendor.c b/bcmdhd.101.10.361.x/wl_cfgvendor.c index bf9415b..de4750a 100755 --- a/bcmdhd.101.10.361.x/wl_cfgvendor.c +++ b/bcmdhd.101.10.361.x/wl_cfgvendor.c @@ -6891,6 +6891,8 @@ static int wl_cfgvendor_lstats_get_info(struct wiphy *wiphy, uint32 cca_busy_time = 0; int cur_chansp, cur_band; chanspec_t cur_chanspec; + struct sk_buff *skb; + int mem_needed; COMPAT_STRUCT_IFACE(wifi_iface_stat, iface); @@ -7311,10 +7313,28 @@ static int wl_cfgvendor_lstats_get_info(struct wiphy *wiphy, err = BCME_BADLEN; goto exit; } - err = wl_cfgvendor_send_cmd_reply(wiphy, outdata, total_len); + mem_needed = VENDOR_REPLY_OVERHEAD + (ATTRIBUTE_U32_LEN) + total_len; + skb = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, mem_needed); + if (unlikely(!skb)) { + WL_ERR(("skb alloc failed")); + err = -ENOMEM; + goto exit; + } + err = nla_put_u32(skb, ANDR_WIFI_STATS_ATTRIBUTE_NUM_RADIO, 1); + if (unlikely(err)) { + kfree_skb(skb); + goto exit; + } + err = nla_put(skb, ANDR_WIFI_STATS_ATTRIBUTE_STATS_INFO, total_len, outdata); + if (unlikely(err)) { + kfree_skb(skb); + goto exit; + } - if (unlikely(err)) - WL_ERR(("Vendor Command reply failed ret:%d \n", err)); + err = cfg80211_vendor_cmd_reply(skb); + if (unlikely(err)) { + WL_ERR(("Vendor command reply failed ret:%d\n", err)); + } exit: #ifdef CHAN_STATS_SUPPORT diff --git a/bcmdhd.101.10.361.x/wl_cfgvendor.h b/bcmdhd.101.10.361.x/wl_cfgvendor.h index 5c78e2f..6373a42 100755 --- a/bcmdhd.101.10.361.x/wl_cfgvendor.h +++ b/bcmdhd.101.10.361.x/wl_cfgvendor.h @@ -638,6 +638,14 @@ enum andr_wifi_attr { /* Any new ANDR_WIFI attribute add prior to the ANDR_WIFI_ATTRIBUTE_MAX */ ANDR_WIFI_ATTRIBUTE_MAX }; +enum andr_wifi_stats_attr { + ANDR_WIFI_STATS_ATTRIBUTE_INVALID, + ANDR_WIFI_STATS_ATTRIBUTE_NUM_RADIO, + ANDR_WIFI_STATS_ATTRIBUTE_STATS_INFO, + ANDR_WIFI_STATS_ATTRIBUTE_ML_STATS_INFO, + /* Any new ANDR_WIFI_STATS attribute add prior to the ANDR_WIFI_STATS_ATTRIBUTE_MAX */ + ANDR_WIFI_STATS_ATTRIBUTE_MAX +}; enum apf_attributes { APF_ATTRIBUTE_VERSION, APF_ATTRIBUTE_MAX_LEN, -- 2.20.1