Skip to content

RDKBWIFI-401: Add VAP traffic stats collection and fix AP metrics reporting#1030

Open
nefiguclu wants to merge 2 commits intordkcentral:developfrom
nefiguclu:apmetric_response
Open

RDKBWIFI-401: Add VAP traffic stats collection and fix AP metrics reporting#1030
nefiguclu wants to merge 2 commits intordkcentral:developfrom
nefiguclu:apmetric_response

Conversation

@nefiguclu
Copy link
Copy Markdown

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

@nefiguclu nefiguclu requested a review from a team as a code owner April 2, 2026 13:24
@amarnathhullur amarnathhullur requested a review from Copilot April 2, 2026 21:55
@amarnathhullur amarnathhullur added the community contribution Contributions from community. label Apr 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands EasyMesh AP metrics reporting by adding a per-VAP traffic stats collection pipeline, extending AP/BSS metrics payloads (ESP + multicast/broadcast counters), and fixing several AP metrics decode/translate issues so radio/BSS/STA metrics are propagated correctly into the EasyMesh data model.

Changes:

  • Add a new mon_stats_type_vap_stats monitor stats type with a wifi_stats_vap.c collector and corresponding event plumbing.
  • Extend AP metrics encode/decode/translate to include radio metrics, per-AC ESP fields, and multicast/broadcast byte counters; improve VAP lookup by BSSID.
  • Fix multiple AP metrics reporting bugs (e.g., radio_count decode, retrans mapping, receive_other utilization, STA time delta calculation).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
source/webconfig/wifi_webconfig_em_ap_metrics_report.c Sets decoded radio_count after subdoc processing.
source/webconfig/wifi_encoder.c Encodes radio metrics and extends VAP/AP metrics payload (ESP flags/values + multicast/broadcast counters); skips non-AP VAPs.
source/webconfig/wifi_easymesh_translator.c Propagates radio metrics into em_radio_info and maps per-VAP metrics into em_bss_info (BSSID-based lookup, ESP 24-bit unpack).
source/webconfig/wifi_decoder.c Decodes radio metrics and new VAP/AP metrics fields; fixes unicast-bytes-received decode.
source/stats/wifi_stats.c Registers the new mon_stats_type_vap_stats descriptor.
source/stats/wifi_stats_vap.c Adds a new VAP traffic stats collector/cacher implementation.
source/stats/wifi_stats_radio_diagnostics.c Removes stray whitespace.
source/stats/wifi_stats_radio_channel.c Adds early path for WIFI_RADIO_SCAN_MODE_NONE to update channel stats cache.
source/stats/wifi_stats_assoc_client.c Captures per-STA monotonic timestamp for later link-metrics delta computation.
source/stats/wifi_monitor.h Introduces vap_traffic_stats_t, stores it in bssid_data_t, and declares VAP stats APIs.
source/stats/wifi_monitor.c Removes stray whitespace.
source/core/wifi_events.c Adds event allocation/copy support for mon_stats_type_vap_stats.
source/core/Makefile.am Builds and links wifi_stats_vap.c.
source/apps/em/wifi_em.h Adds em_app_event_type_vap_stats_periodic.
source/apps/em/wifi_em.c Adds timestamp wrapper for per-STA measurements, computes time_delta, handles VAP stats responses, and fixes AP/radio metrics mappings.
include/wifi_base.h Adds mon_stats_type_vap_stats, adds STA timestamp field, and updates STA metrics field types.
Comments suppressed due to low confidence (1)

source/webconfig/wifi_encoder.c:3448

  • vap_arr_index is initialized once before the VAP loop and is not reset for each j. If a VAP’s BSSID doesn’t match any vap_reports[k], vap_arr_index can retain the previous iteration’s value and cause the encoder to attach the wrong AP metrics to the current VAP. Reset vap_arr_index = -1 at the start of each j iteration (or immediately before the for (k ...) search) and only use it when a match is found.
        for (int k = 0; k < MAX_NUM_VAP_PER_RADIO; k++) {
            ap_metrics = &radio_report->vap_reports[k];
            if (strncmp(vap->u.bss_info.bssid, ap_metrics->vap_metrics.bssid,
                sizeof(bssid_t)) == 0) {
                    vap_arr_index = k;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/stats/wifi_stats_radio_channel.c Outdated
Comment thread source/apps/em/wifi_em.c
Comment thread source/apps/em/wifi_em.c
Comment thread source/apps/em/wifi_em.c
Comment thread source/apps/em/wifi_em.c
Comment thread source/webconfig/wifi_easymesh_translator.c Outdated
Comment thread source/webconfig/wifi_decoder.c
Comment thread source/webconfig/wifi_decoder.c
@nefiguclu nefiguclu force-pushed the apmetric_response branch from fa3e0cd to cbc65db Compare April 3, 2026 11:35
@nefiguclu nefiguclu force-pushed the apmetric_response branch 2 times, most recently from 708191d to 0f8c45e Compare April 8, 2026 08:22
@nefiguclu
Copy link
Copy Markdown
Author

Hello @amarnathhullur, the reason for the build error is that the unified-wifi-mesh changes were not included. Could you please start the build together with below PR?
rdkcentral/unified-wifi-mesh#635

@amarnathhullur
Copy link
Copy Markdown
Contributor

Hello @amarnathhullur, the reason for the build error is that the unified-wifi-mesh changes were not included. Could you please start the build together with below PR? rdkcentral/unified-wifi-mesh#635

Thanks Nefi, merged the Unified-wifi-mesh change and see that the automated build is working. This change will be further reviewed by OneWifi-maintainers team.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/webconfig/wifi_decoder.c
Comment thread source/webconfig/wifi_decoder.c
Comment thread source/stats/wifi_stats_vap.c
Comment thread source/stats/wifi_stats_vap.c
Comment thread source/apps/em/wifi_em.c Outdated
Comment thread source/webconfig/wifi_easymesh_translator.c Outdated
Comment thread source/stats/wifi_stats_vap.c Outdated
…orting

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
@nefiguclu
Copy link
Copy Markdown
Author

Hi @amarnathhullur, is this PR still waiting for review?

@Nikita-Hakai
Copy link
Copy Markdown
Contributor

Hi @amarnathhullur, is this PR still waiting for review?

Hi @nefiguclu, PR is also under review by Narendra.

@Nikita-Hakai
Copy link
Copy Markdown
Contributor

Nikita-Hakai commented Apr 15, 2026

Internal build success - https://gerrit.teamccp.com/#/c/953897/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community contribution Contributions from community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants