Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions include/wifi_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ typedef enum {
mon_stats_type_associated_device_stats,
mon_stats_type_radio_diagnostic_stats,
mon_stats_type_radio_temperature,
mon_stats_type_vap_stats,
mon_stats_type_max
} wifi_mon_stats_type_t;

Expand Down Expand Up @@ -1022,6 +1023,7 @@ typedef struct {
bool connection_authorized;
bool rapid_disconnect_flag;
assoc_req_elem_t assoc_frame_data;
struct timespec timestamp;

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

typedef struct {
mac_addr_t bssid;
int time_delta;
int est_mac_rate_down;
int est_mac_rate_up;
int rcpi;
unsigned int time_delta;
unsigned int est_mac_rate_down;
unsigned int est_mac_rate_up;
unsigned int rcpi;
} assoc_sta_link_metrics_data_t;

typedef struct {
Expand Down Expand Up @@ -1417,13 +1419,13 @@ typedef struct {

typedef struct {
mac_addr_t sta_mac;
int bytes_sent;
int bytes_rcvd;
int packets_sent;
int packets_rcvd;
int tx_packtes_errs;
int rx_packtes_errs;
int retrans_cnt;
ULONG bytes_sent;
ULONG bytes_rcvd;
ULONG packets_sent;
ULONG packets_rcvd;
ULONG tx_packtes_errs;
ULONG rx_packtes_errs;
ULONG retrans_cnt;
} assoc_sta_traffic_stats_t;

typedef struct {
Expand Down
206 changes: 170 additions & 36 deletions source/apps/em/wifi_em.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions source/apps/em/wifi_em.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ typedef enum {
em_app_event_type_neighbor_stats,
em_app_event_type_ap_metrics_rad_chan_stats,
em_app_event_type_assoc_dev_stats_periodic,
em_app_event_type_vap_stats_periodic,

em_app_event_type_max
} em_app_event_type_t;
Expand Down
2 changes: 1 addition & 1 deletion source/core/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ OneWifi_SOURCES += $(top_srcdir)/source/core/services/vap_svc.c $(top_srcdir)/s
OneWifi_SOURCES += $(top_srcdir)/source/core/services/vap_svc_mesh_ext.c

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
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
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

OneWifi_SOURCES += $(top_srcdir)/source/stubs/wifi_stubs.c
OneWifi_SOURCES += $(top_srcdir)/source/ccsp/ccsp.c
Expand Down
27 changes: 27 additions & 0 deletions source/core/wifi_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,21 @@ wifi_event_t *create_wifi_monitor_response_event(const void *msg, unsigned int m
}
}
break;
case mon_stats_type_vap_stats:
if (response->stat_array_size > 0) {
event->u.provider_response->stat_pointer = calloc(response->stat_array_size,
sizeof(vap_traffic_stats_t));
if (event->u.provider_response->stat_pointer == NULL) {
wifi_util_error_print(WIFI_CTRL, "%s %d response allocation failed for %d\n",
__FUNCTION__, __LINE__, response->data_type);
free(event->u.provider_response);
event->u.provider_response = NULL;
free(event);
event = NULL;
return NULL;
}
}
break;
default:
wifi_util_error_print(WIFI_CTRL, "%s %d default response type : %d\n", __FUNCTION__,
__LINE__, response->data_type);
Expand Down Expand Up @@ -658,6 +673,18 @@ int copy_msg_to_event(const void *data, unsigned int msg_len, wifi_event_type_t
memcpy(event->u.provider_response->stat_pointer, response->stat_pointer,
(response->stat_array_size * sizeof(radio_data_t)));
break;
case mon_stats_type_vap_stats:
if ((event->u.provider_response->stat_pointer == NULL) ||
(response->stat_pointer == NULL)) {
wifi_util_error_print(WIFI_CTRL,
"%s %d data_type %d stat_pointer is NULL : %p, %p\n", __FUNCTION__,
__LINE__, response->data_type, event->u.provider_response->stat_pointer,
response->stat_pointer);
return RETURN_ERR;
}
memcpy(event->u.provider_response->stat_pointer, response->stat_pointer,
(response->stat_array_size * sizeof(vap_traffic_stats_t)));
break;
default:
wifi_util_error_print(WIFI_CTRL, "%s %d default response type : %d\n", __FUNCTION__,
__LINE__, response->data_type);
Expand Down
1 change: 0 additions & 1 deletion source/stats/wifi_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -4677,7 +4677,6 @@ int provider_execute_task(void *arg)
return RETURN_OK;
}


int coordinator_create_collector_task(wifi_mon_collector_element_t *collector_elem)
{
wifi_monitor_t *mon_data = (wifi_monitor_t *)get_wifi_monitor();
Expand Down
18 changes: 18 additions & 0 deletions source/stats/wifi_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ typedef struct {
wifi_vapstatus_t ap_status;
} ap_params_t;

typedef struct {
ULONG ssid_UnicastBytesSent;
ULONG ssid_UnicastBytesReceived;
ULONG ssid_MulticastBytesSent;
ULONG ssid_MulticastBytesReceived;
ULONG ssid_BroadcastBytesSent;
ULONG ssid_BroadcastBytesReceived;
} vap_traffic_stats_t;

typedef struct {
unsigned char bssid[32];
hash_map_t *sta_map; //of type sta_data_t
Expand All @@ -45,6 +54,7 @@ typedef struct {
struct timespec last_sta_update_time;
ap_params_t ap_params;
ssid_t ssid;
vap_traffic_stats_t vap_traffic;
} bssid_data_t;

#define WPA2_PSK 2
Expand Down Expand Up @@ -374,4 +384,12 @@ int generate_radio_temperature_provider_stats_key(wifi_mon_stats_config_t *confi
int execute_radio_temperature_stats_api(wifi_mon_collector_element_t *c_elem, wifi_monitor_t *mon_data, unsigned long task_interval_ms);
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);

/*Vap stats*/
int validate_vap_args(wifi_mon_stats_args_t *args);
int generate_vap_clctr_stats_key(wifi_mon_stats_args_t *args, char *key_str, size_t key_len);
int generate_vap_provider_stats_key(wifi_mon_stats_config_t *config, char *key_str, size_t key_len);
int execute_vap_stats_api(wifi_mon_collector_element_t *c_elem, wifi_monitor_t *mon_data, unsigned long task_interval_ms);
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);


#endif //_WIFI_MON_H_
12 changes: 11 additions & 1 deletion source/stats/wifi_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "wifi_monitor.h"
#include "wifi_util.h"

#define WIFI_STATS_NUM 5
#define WIFI_STATS_NUM 6

wifi_mon_stats_descriptor_t g_stats_descriptor[WIFI_STATS_NUM] = {
{
Expand Down Expand Up @@ -80,6 +80,16 @@ wifi_mon_stats_descriptor_t g_stats_descriptor[WIFI_STATS_NUM] = {
copy_radio_temperature_stats_from_cache,
NULL,
NULL
},
{
mon_stats_type_vap_stats,
validate_vap_args,
generate_vap_clctr_stats_key,
generate_vap_provider_stats_key,
execute_vap_stats_api,
copy_vap_stats_from_cache,
NULL,
NULL
}
};

Expand Down
2 changes: 2 additions & 0 deletions source/stats/wifi_stats_assoc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ int execute_assoc_client_stats_api(wifi_mon_collector_element_t *c_elem, wifi_mo
sta->updated = true;
sta->dev_stats.cli_Active = true;
sta->dev_stats.cli_SignalStrength = hal_sta->cli_SignalStrength;
sta->timestamp.tv_sec = tv_now.tv_sec;
sta->timestamp.tv_nsec = tv_now.tv_nsec;

if (timespeccmp(&(sta->last_connected_time),
&(mon_data->bssid_data[vap_array_index].last_sta_update_time),
Expand Down
12 changes: 12 additions & 0 deletions source/stats/wifi_stats_radio_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,18 @@ int execute_radio_channel_api(wifi_mon_collector_element_t *c_elem, wifi_monitor
return RETURN_ERR;
}


// Update Channel Stats cache
if (args->scan_mode == WIFI_RADIO_SCAN_MODE_NONE) {
ret = execute_radio_channel_stats_api(c_elem, mon_data);
if (ret != RETURN_OK) {
wifi_util_error_print(WIFI_MON,
"%s:%d execute_radio_channel_stats_api failed for radio: %d\n",
__func__, __LINE__, args->radio_index);
}
return ret;
}

if (args->scan_mode == WIFI_RADIO_SCAN_MODE_ONCHAN) {
if (get_on_channel_scan_list(radioOperation->band, radioOperation->channelWidth,
radioOperation->channel, channels, &num_channels) != 0) {
Expand Down
1 change: 0 additions & 1 deletion source/stats/wifi_stats_radio_diagnostics.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ int execute_radio_diagnostic_stats_api(wifi_mon_collector_element_t *c_elem, wif
}

memset(radioTrafficStats, 0, sizeof(wifi_radioTrafficStats2_t));

if (radioOperation->enable == true) {
ret = get_misc_descriptor()->wifi_getRadioTrafficStats2_fn(args->radio_index, radioTrafficStats);
if (ret != RETURN_OK) {
Expand Down
172 changes: 172 additions & 0 deletions source/stats/wifi_stats_vap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/************************************************************************************
If not stated otherwise in this file or this component's LICENSE file the
following copyright and licenses apply:

Copyright 2018 RDK Management

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "wifi_monitor.h"
#include "wifi_ctrl.h"
#include "wifi_util.h"

int validate_vap_args(wifi_mon_stats_args_t *args)
{
wifi_platform_property_t *wifi_prop = get_wifi_hal_cap_prop();
if (args == NULL) {
wifi_util_error_print(WIFI_MON, "%s:%d input arguments are NULL args : %p\n",__func__,__LINE__, args);
return RETURN_ERR;
}

if (args->vap_index >= wifi_prop->numRadios * MAX_NUM_VAP_PER_RADIO) {
wifi_util_error_print(WIFI_MON,"RDK_LOG_ERROR, %s Input apIndex = %d not found, Out of range\n", __FUNCTION__, args->vap_index);
return RETURN_ERR;
}

if (args->radio_index >= getNumberRadios()) {
wifi_util_error_print(WIFI_MON, "%s:%d invalid radio index : %d\n",__func__,__LINE__, args->radio_index);
return RETURN_ERR;
}

return RETURN_OK;
}

int generate_vap_clctr_stats_key(wifi_mon_stats_args_t *args, char *key_str, size_t key_len)
{
if ((args == NULL) || (key_str == NULL)) {
wifi_util_error_print(WIFI_MON, "%s:%d input arguments are NULL args : %p key = %p\n", __func__, __LINE__, args, key_str);
return RETURN_ERR;
}
memset(key_str, 0, key_len);
snprintf(key_str, key_len, "%02d-%02d", mon_stats_type_vap_stats, args->vap_index);
wifi_util_dbg_print(WIFI_MON, "%s:%d collector stats key: %s\n", __func__, __LINE__, key_str);
return RETURN_OK;
}

int generate_vap_provider_stats_key(wifi_mon_stats_config_t *config, char *key_str, size_t key_len)
{
if ((config == NULL) || (key_str == NULL)) {
wifi_util_error_print(WIFI_MON, "%s:%d input arguments are NULL config : %p key = %p\n", __func__, __LINE__, config, key_str);
return RETURN_ERR;
}
memset(key_str, 0, key_len);
snprintf(key_str, key_len, "%04d-%02d-%02d-%08d", config->inst, mon_stats_type_vap_stats,
config->args.vap_index, config->args.app_info);
wifi_util_dbg_print(WIFI_MON, "%s:%d: provider stats key: %s\n", __func__, __LINE__, key_str);
return RETURN_OK;
}


int execute_vap_stats_api(wifi_mon_collector_element_t *c_elem, wifi_monitor_t *mon_data,
unsigned long task_interval_ms)
{
wifi_mon_stats_args_t *args;
vap_traffic_stats_t *vap_stats;
unsigned int vap_array_index;

if ((c_elem == NULL) || (mon_data == NULL) || (c_elem->args == NULL)) {
wifi_util_error_print(WIFI_MON, "%s:%d invalid arguments\n", __func__, __LINE__);
return RETURN_ERR;
}
args = c_elem->args;
vap_stats = (vap_traffic_stats_t *)calloc(1, sizeof(vap_traffic_stats_t));
if (vap_stats == NULL) {
wifi_util_error_print(WIFI_MON, "%s:%d calloc failed\n", __func__, __LINE__);
return RETURN_ERR;
}

/*
if (wifi_getxxx(args->vap_index, vap_stats) != RETURN_OK) {
wifi_util_error_print(WIFI_MON, "%s:%d wifi_getxxx failed for vap_index %d\n",
__func__, __LINE__, args->vap_index);
free(vap_stats);
return RETURN_ERR;
} */
getVAPArrayIndexFromVAPIndex(args->vap_index, &vap_array_index);

pthread_mutex_lock(&mon_data->data_lock);
memcpy(&mon_data->bssid_data[vap_array_index].vap_traffic, vap_stats, sizeof(vap_traffic_stats_t));
pthread_mutex_unlock(&mon_data->data_lock);
Comment thread
Nikita-Hakai marked this conversation as resolved.

if (c_elem->stats_clctr.is_event_subscribed == true &&
(c_elem->stats_clctr.stats_type_subscribed & 1 << mon_stats_type_vap_stats)) {
vap_traffic_stats_t *copy = (vap_traffic_stats_t *)malloc(sizeof(vap_traffic_stats_t));
if (copy == NULL) {
wifi_util_error_print(WIFI_MON, "%s:%d malloc copy failed\n", __func__, __LINE__);
free(vap_stats);
return RETURN_ERR;
}
memcpy(copy, vap_stats, sizeof(vap_traffic_stats_t));

wifi_provider_response_t *collect_stats = (wifi_provider_response_t *)malloc(sizeof(wifi_provider_response_t));
if (collect_stats == NULL) {
wifi_util_error_print(WIFI_MON, "%s:%d malloc response failed\n", __func__, __LINE__);
free(copy);
free(vap_stats);
return RETURN_ERR;
}
collect_stats->data_type = mon_stats_type_vap_stats;
collect_stats->args.vap_index = args->vap_index;
collect_stats->args.radio_index = args->radio_index;
collect_stats->stat_pointer = copy;
collect_stats->stat_array_size = 1;

wifi_util_dbg_print(WIFI_MON, "%s:%d sending VAP stats for vap_index %d\n", __func__, __LINE__, args->vap_index);
push_monitor_response_event_to_ctrl_queue(collect_stats, sizeof(wifi_provider_response_t),
wifi_event_type_monitor, wifi_event_type_collect_stats, NULL);
free(copy);
free(collect_stats);
}

free(vap_stats);
wifi_util_dbg_print(WIFI_MON, "%s:%d executed VAP stats for vap_index %d\n", __func__, __LINE__, args->vap_index);
return RETURN_OK;
}

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)
{
vap_traffic_stats_t *out;
unsigned int vap_array_index;
if ((p_elem == NULL) || (mon_cache == NULL) || (p_elem->mon_stats_config == NULL)) {
wifi_util_error_print(WIFI_MON, "%s:%d invalid arguments\n", __func__, __LINE__);
return RETURN_ERR;
}

wifi_util_dbg_print(WIFI_MON, "%s:%d copy_vap_stats_from_cache for vap index: %d\n", __func__, __LINE__,
p_elem->mon_stats_config->args.vap_index);

pthread_mutex_lock(&mon_cache->data_lock);
out = calloc(1, sizeof(vap_traffic_stats_t));
if (out == NULL) {
pthread_mutex_unlock(&mon_cache->data_lock);
return RETURN_ERR;
}

getVAPArrayIndexFromVAPIndex(p_elem->mon_stats_config->args.vap_index, &vap_array_index);
memcpy(out, &mon_cache->bssid_data[vap_array_index].vap_traffic, sizeof(vap_traffic_stats_t));
pthread_mutex_unlock(&mon_cache->data_lock);
Comment thread
Nikita-Hakai marked this conversation as resolved.

*stats = out;
*stat_array_size = 1;
return RETURN_OK;
}
Loading
Loading