Skip to content

Commit 40ff936

Browse files
kapbhrlubos
authored andcommitted
[nrf fromlist] wifi_mgmt: Add new API to reset Wi-Fi statistics
Upstream PR: zephyrproject-rtos/zephyr#75768 Add a new offload API to reset Wi-Fi statistics from the Wi-Fi driver. Signed-off-by: Kapil Bhatt <[email protected]>
1 parent bdab5cd commit 40ff936

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

include/zephyr/net/net_stats.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@ enum net_request_stats_cmd {
648648
NET_REQUEST_STATS_CMD_GET_PPP,
649649
NET_REQUEST_STATS_CMD_GET_PM,
650650
NET_REQUEST_STATS_CMD_GET_WIFI,
651+
NET_REQUEST_STATS_CMD_RESET_WIFI,
651652
};
652653

653654
/** @endcond */
@@ -777,6 +778,14 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_PM);
777778
/** @cond INTERNAL_HIDDEN */
778779
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_WIFI);
779780
/** @endcond */
781+
782+
/** Reset Wi-Fi statistics*/
783+
#define NET_REQUEST_STATS_RESET_WIFI \
784+
(_NET_STATS_BASE | NET_REQUEST_STATS_CMD_RESET_WIFI)
785+
786+
/** @cond INTERNAL_HIDDEN */
787+
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI);
788+
/** @endcond */
780789
#endif /* CONFIG_NET_STATISTICS_WIFI */
781790

782791
/**

include/zephyr/net/wifi_mgmt.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,13 @@ struct wifi_mgmt_ops {
863863
* @return 0 if ok, < 0 if error
864864
*/
865865
int (*get_stats)(const struct device *dev, struct net_stats_wifi *stats);
866+
/** Reset Wi-Fi statistics
867+
*
868+
* @param dev Pointer to the device structure for the driver instance.
869+
*
870+
* @return 0 if ok, < 0 if error
871+
*/
872+
int (*reset_stats)(const struct device *dev);
866873
#endif /* CONFIG_NET_STATISTICS_WIFI */
867874
/** Set power save status
868875
*

subsys/net/l2/wifi/wifi_mgmt.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,20 @@ static int wifi_iface_stats(uint32_t mgmt_request, struct net_if *iface,
515515
return wifi_mgmt_api->get_stats(dev, stats);
516516
}
517517
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_WIFI, wifi_iface_stats);
518+
519+
static int wifi_iface_stats_reset(uint32_t mgmt_request, struct net_if *iface,
520+
void *data, size_t len)
521+
{
522+
const struct device *dev = net_if_get_device(iface);
523+
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);
524+
525+
if (wifi_mgmt_api == NULL || wifi_mgmt_api->reset_stats == NULL) {
526+
return -ENOTSUP;
527+
}
528+
529+
return wifi_mgmt_api->reset_stats(dev);
530+
}
531+
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI, wifi_iface_stats_reset);
518532
#endif /* CONFIG_NET_STATISTICS_WIFI */
519533

520534
static int wifi_set_power_save(uint32_t mgmt_request, struct net_if *iface,

0 commit comments

Comments
 (0)