Skip to content

Commit 9fa45d5

Browse files
nefigucluamarnathhullur
authored andcommitted
RDKBWIFI-401: Add VAP traffic stats collection and fix AP metrics reporting
New Features - Add mon_stats_type_vap_stats pipeline: vap_traffic_stats_t struct, wifi_stats_vap.c collector, per-VAP monitor task configuration - Add wifi_associated_dev3_timestamp_t wrapper to track per-STA measurement time; compute time_delta using CLOCK_MONOTONIC - Add em_app_event_type_vap_stats_periodic event type Radio & BSS Metrics - Fix receive_other to use ch_utilization_busy_ext instead of 0 - Change channel stats scan_mode ONCHAN→NONE; add early-return path - Add ESP AC BE/BK/VI/VO encoding/decoding and 24-bit unpack into em_bss_info byte arrays - Add multicast/broadcast byte counters to AP metrics encoder/decoder - Fix VAP lookup in translator to use BSSID matching; skip non-AP VAPs - Propagate radio metrics (noise/transmit/receive_self/receive_other) into em_radio_info via translator Bug Fixes - Fix unicast_bytes_rcvd overwritten with unicast_bytes_sent in decoder - Fix retrans_count mapped to rx_packtes_errs instead of retrans_cnt - Fix em_ap_metrics_report.radio_count not set after subdoc decode - Add missing return RETURN_OK in prepare_sta_traffic_stats_data() - Change assoc_sta_traffic_stats_t and assoc_sta_link_metrics_data_t fields from int to ULONG/unsigned int Known Limitations - VAP traffic stats return zero values; HAL API integration pending
1 parent 5b8d311 commit 9fa45d5

16 files changed

Lines changed: 580 additions & 61 deletions

include/wifi_base.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ typedef enum {
354354
mon_stats_type_associated_device_stats,
355355
mon_stats_type_radio_diagnostic_stats,
356356
mon_stats_type_radio_temperature,
357+
mon_stats_type_vap_stats,
357358
mon_stats_type_max
358359
} wifi_mon_stats_type_t;
359360

@@ -1022,6 +1023,7 @@ typedef struct {
10221023
bool connection_authorized;
10231024
bool rapid_disconnect_flag;
10241025
assoc_req_elem_t assoc_frame_data;
1026+
struct timespec timestamp;
10251027

10261028
/* wifi7 client specific data */
10271029
bool assoc_link; /* TRUE for auth/primary link, FALSE for secondary links */
@@ -1306,10 +1308,10 @@ typedef struct {
13061308

13071309
typedef struct {
13081310
mac_addr_t bssid;
1309-
int time_delta;
1310-
int est_mac_rate_down;
1311-
int est_mac_rate_up;
1312-
int rcpi;
1311+
unsigned int time_delta;
1312+
unsigned int est_mac_rate_down;
1313+
unsigned int est_mac_rate_up;
1314+
unsigned int rcpi;
13131315
} assoc_sta_link_metrics_data_t;
13141316

13151317
typedef struct {
@@ -1417,13 +1419,13 @@ typedef struct {
14171419

14181420
typedef struct {
14191421
mac_addr_t sta_mac;
1420-
int bytes_sent;
1421-
int bytes_rcvd;
1422-
int packets_sent;
1423-
int packets_rcvd;
1424-
int tx_packtes_errs;
1425-
int rx_packtes_errs;
1426-
int retrans_cnt;
1422+
ULONG bytes_sent;
1423+
ULONG bytes_rcvd;
1424+
ULONG packets_sent;
1425+
ULONG packets_rcvd;
1426+
ULONG tx_packtes_errs;
1427+
ULONG rx_packtes_errs;
1428+
ULONG retrans_cnt;
14271429
} assoc_sta_traffic_stats_t;
14281430

14291431
typedef struct {

source/apps/em/wifi_em.c

Lines changed: 170 additions & 36 deletions
Large diffs are not rendered by default.

source/apps/em/wifi_em.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef enum {
7676
em_app_event_type_neighbor_stats,
7777
em_app_event_type_ap_metrics_rad_chan_stats,
7878
em_app_event_type_assoc_dev_stats_periodic,
79+
em_app_event_type_vap_stats_periodic,
7980

8081
em_app_event_type_max
8182
} em_app_event_type_t;

source/core/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ OneWifi_SOURCES += $(top_srcdir)/source/core/services/vap_svc.c $(top_srcdir)/s
9999
OneWifi_SOURCES += $(top_srcdir)/source/core/services/vap_svc_mesh_ext.c
100100

101101
OneWifi_SOURCES += $(top_srcdir)/source/utils/jsonconv.c $(top_srcdir)/source/utils/collection.c $(top_srcdir)/source/utils/scheduler.c $(top_srcdir)/source/utils/caps.c
102-
OneWifi_SOURCES += $(top_srcdir)/source/stats/wifi_monitor.c $(top_srcdir)/source/utils/ext_blaster.pb-c.c $(top_srcdir)/source/stats/wifi_stats.c $(top_srcdir)/source/stats/wifi_stats_radio_channel.c $(top_srcdir)/source/stats/wifi_stats_neighbor_report.c $(top_srcdir)/source/stats/wifi_stats_radio_diagnostics.c $(top_srcdir)/source/stats/wifi_stats_assoc_client.c $(top_srcdir)/source/stats/wifi_stats_radio_temperature.c
102+
OneWifi_SOURCES += $(top_srcdir)/source/stats/wifi_monitor.c $(top_srcdir)/source/utils/ext_blaster.pb-c.c $(top_srcdir)/source/stats/wifi_stats.c $(top_srcdir)/source/stats/wifi_stats_radio_channel.c $(top_srcdir)/source/stats/wifi_stats_neighbor_report.c $(top_srcdir)/source/stats/wifi_stats_radio_diagnostics.c $(top_srcdir)/source/stats/wifi_stats_assoc_client.c $(top_srcdir)/source/stats/wifi_stats_radio_temperature.c $(top_srcdir)/source/stats/wifi_stats_vap.c
103103

104104
OneWifi_SOURCES += $(top_srcdir)/source/stubs/wifi_stubs.c
105105
OneWifi_SOURCES += $(top_srcdir)/source/ccsp/ccsp.c

source/core/wifi_events.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,21 @@ wifi_event_t *create_wifi_monitor_response_event(const void *msg, unsigned int m
492492
}
493493
}
494494
break;
495+
case mon_stats_type_vap_stats:
496+
if (response->stat_array_size > 0) {
497+
event->u.provider_response->stat_pointer = calloc(response->stat_array_size,
498+
sizeof(vap_traffic_stats_t));
499+
if (event->u.provider_response->stat_pointer == NULL) {
500+
wifi_util_error_print(WIFI_CTRL, "%s %d response allocation failed for %d\n",
501+
__FUNCTION__, __LINE__, response->data_type);
502+
free(event->u.provider_response);
503+
event->u.provider_response = NULL;
504+
free(event);
505+
event = NULL;
506+
return NULL;
507+
}
508+
}
509+
break;
495510
default:
496511
wifi_util_error_print(WIFI_CTRL, "%s %d default response type : %d\n", __FUNCTION__,
497512
__LINE__, response->data_type);
@@ -658,6 +673,18 @@ int copy_msg_to_event(const void *data, unsigned int msg_len, wifi_event_type_t
658673
memcpy(event->u.provider_response->stat_pointer, response->stat_pointer,
659674
(response->stat_array_size * sizeof(radio_data_t)));
660675
break;
676+
case mon_stats_type_vap_stats:
677+
if ((event->u.provider_response->stat_pointer == NULL) ||
678+
(response->stat_pointer == NULL)) {
679+
wifi_util_error_print(WIFI_CTRL,
680+
"%s %d data_type %d stat_pointer is NULL : %p, %p\n", __FUNCTION__,
681+
__LINE__, response->data_type, event->u.provider_response->stat_pointer,
682+
response->stat_pointer);
683+
return RETURN_ERR;
684+
}
685+
memcpy(event->u.provider_response->stat_pointer, response->stat_pointer,
686+
(response->stat_array_size * sizeof(vap_traffic_stats_t)));
687+
break;
661688
default:
662689
wifi_util_error_print(WIFI_CTRL, "%s %d default response type : %d\n", __FUNCTION__,
663690
__LINE__, response->data_type);

source/stats/wifi_monitor.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4677,7 +4677,6 @@ int provider_execute_task(void *arg)
46774677
return RETURN_OK;
46784678
}
46794679

4680-
46814680
int coordinator_create_collector_task(wifi_mon_collector_element_t *collector_elem)
46824681
{
46834682
wifi_monitor_t *mon_data = (wifi_monitor_t *)get_wifi_monitor();

source/stats/wifi_monitor.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ typedef struct {
3737
wifi_vapstatus_t ap_status;
3838
} ap_params_t;
3939

40+
typedef struct {
41+
ULONG ssid_UnicastBytesSent;
42+
ULONG ssid_UnicastBytesReceived;
43+
ULONG ssid_MulticastBytesSent;
44+
ULONG ssid_MulticastBytesReceived;
45+
ULONG ssid_BroadcastBytesSent;
46+
ULONG ssid_BroadcastBytesReceived;
47+
} vap_traffic_stats_t;
48+
4049
typedef struct {
4150
unsigned char bssid[32];
4251
hash_map_t *sta_map; //of type sta_data_t
@@ -45,6 +54,7 @@ typedef struct {
4554
struct timespec last_sta_update_time;
4655
ap_params_t ap_params;
4756
ssid_t ssid;
57+
vap_traffic_stats_t vap_traffic;
4858
} bssid_data_t;
4959

5060
#define WPA2_PSK 2
@@ -374,4 +384,12 @@ int generate_radio_temperature_provider_stats_key(wifi_mon_stats_config_t *confi
374384
int execute_radio_temperature_stats_api(wifi_mon_collector_element_t *c_elem, wifi_monitor_t *mon_data, unsigned long task_interval_ms);
375385
int copy_radio_temperature_stats_from_cache(wifi_mon_provider_element_t *p_elem, void **stats, unsigned int *stat_array_size, wifi_monitor_t *mon_cache);
376386

387+
/*Vap stats*/
388+
int validate_vap_args(wifi_mon_stats_args_t *args);
389+
int generate_vap_clctr_stats_key(wifi_mon_stats_args_t *args, char *key_str, size_t key_len);
390+
int generate_vap_provider_stats_key(wifi_mon_stats_config_t *config, char *key_str, size_t key_len);
391+
int execute_vap_stats_api(wifi_mon_collector_element_t *c_elem, wifi_monitor_t *mon_data, unsigned long task_interval_ms);
392+
int copy_vap_stats_from_cache(wifi_mon_provider_element_t *p_elem, void **stats, unsigned int *stat_array_size, wifi_monitor_t *mon_cache);
393+
394+
377395
#endif //_WIFI_MON_H_

source/stats/wifi_stats.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "wifi_monitor.h"
2828
#include "wifi_util.h"
2929

30-
#define WIFI_STATS_NUM 5
30+
#define WIFI_STATS_NUM 6
3131

3232
wifi_mon_stats_descriptor_t g_stats_descriptor[WIFI_STATS_NUM] = {
3333
{
@@ -80,6 +80,16 @@ wifi_mon_stats_descriptor_t g_stats_descriptor[WIFI_STATS_NUM] = {
8080
copy_radio_temperature_stats_from_cache,
8181
NULL,
8282
NULL
83+
},
84+
{
85+
mon_stats_type_vap_stats,
86+
validate_vap_args,
87+
generate_vap_clctr_stats_key,
88+
generate_vap_provider_stats_key,
89+
execute_vap_stats_api,
90+
copy_vap_stats_from_cache,
91+
NULL,
92+
NULL
8393
}
8494
};
8595

source/stats/wifi_stats_assoc_client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ int execute_assoc_client_stats_api(wifi_mon_collector_element_t *c_elem, wifi_mo
381381
sta->updated = true;
382382
sta->dev_stats.cli_Active = true;
383383
sta->dev_stats.cli_SignalStrength = hal_sta->cli_SignalStrength;
384+
sta->timestamp.tv_sec = tv_now.tv_sec;
385+
sta->timestamp.tv_nsec = tv_now.tv_nsec;
384386

385387
if (timespeccmp(&(sta->last_connected_time),
386388
&(mon_data->bssid_data[vap_array_index].last_sta_update_time),

source/stats/wifi_stats_radio_channel.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,18 @@ int execute_radio_channel_api(wifi_mon_collector_element_t *c_elem, wifi_monitor
881881
return RETURN_ERR;
882882
}
883883

884+
885+
// Update Channel Stats cache
886+
if (args->scan_mode == WIFI_RADIO_SCAN_MODE_NONE) {
887+
ret = execute_radio_channel_stats_api(c_elem, mon_data);
888+
if (ret != RETURN_OK) {
889+
wifi_util_error_print(WIFI_MON,
890+
"%s:%d execute_radio_channel_stats_api failed for radio: %d\n",
891+
__func__, __LINE__, args->radio_index);
892+
}
893+
return ret;
894+
}
895+
884896
if (args->scan_mode == WIFI_RADIO_SCAN_MODE_ONCHAN) {
885897
if (get_on_channel_scan_list(radioOperation->band, radioOperation->channelWidth,
886898
radioOperation->channel, channels, &num_channels) != 0) {

0 commit comments

Comments
 (0)