Skip to content

Commit

Permalink
[nrf fromlist] wifi_mgmt: Add new API to reset Wi-Fi statistics
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
kapbh authored and rlubos committed Jul 18, 2024
1 parent bdab5cd commit 40ff936
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/zephyr/net/net_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ enum net_request_stats_cmd {
NET_REQUEST_STATS_CMD_GET_PPP,
NET_REQUEST_STATS_CMD_GET_PM,
NET_REQUEST_STATS_CMD_GET_WIFI,
NET_REQUEST_STATS_CMD_RESET_WIFI,
};

/** @endcond */
Expand Down Expand Up @@ -777,6 +778,14 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_PM);
/** @cond INTERNAL_HIDDEN */
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_GET_WIFI);
/** @endcond */

/** Reset Wi-Fi statistics*/
#define NET_REQUEST_STATS_RESET_WIFI \
(_NET_STATS_BASE | NET_REQUEST_STATS_CMD_RESET_WIFI)

/** @cond INTERNAL_HIDDEN */
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI);
/** @endcond */
#endif /* CONFIG_NET_STATISTICS_WIFI */

/**
Expand Down
7 changes: 7 additions & 0 deletions include/zephyr/net/wifi_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,13 @@ struct wifi_mgmt_ops {
* @return 0 if ok, < 0 if error
*/
int (*get_stats)(const struct device *dev, struct net_stats_wifi *stats);
/** Reset Wi-Fi statistics
*
* @param dev Pointer to the device structure for the driver instance.
*
* @return 0 if ok, < 0 if error
*/
int (*reset_stats)(const struct device *dev);
#endif /* CONFIG_NET_STATISTICS_WIFI */
/** Set power save status
*
Expand Down
14 changes: 14 additions & 0 deletions subsys/net/l2/wifi/wifi_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,20 @@ static int wifi_iface_stats(uint32_t mgmt_request, struct net_if *iface,
return wifi_mgmt_api->get_stats(dev, stats);
}
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_GET_WIFI, wifi_iface_stats);

static int wifi_iface_stats_reset(uint32_t mgmt_request, struct net_if *iface,
void *data, size_t len)
{
const struct device *dev = net_if_get_device(iface);
const struct wifi_mgmt_ops *const wifi_mgmt_api = get_wifi_api(iface);

if (wifi_mgmt_api == NULL || wifi_mgmt_api->reset_stats == NULL) {
return -ENOTSUP;
}

return wifi_mgmt_api->reset_stats(dev);
}
NET_MGMT_REGISTER_REQUEST_HANDLER(NET_REQUEST_STATS_RESET_WIFI, wifi_iface_stats_reset);
#endif /* CONFIG_NET_STATISTICS_WIFI */

static int wifi_set_power_save(uint32_t mgmt_request, struct net_if *iface,
Expand Down

0 comments on commit 40ff936

Please sign in to comment.