Commit e085d440 authored by Kapil Bhatt's avatar Kapil Bhatt Committed by Anas Nashif
Browse files

drivers: wifi: Reset interface statistics data



[SHEL-2542] When reset command is called this will
reset all statistics including firmware and host.

Signed-off-by: default avatarKapil Bhatt <kapil.bhatt@nordicsemi.no>
parent 37a98bfa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -61,4 +61,6 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev);
void nrf_wifi_set_iface_event_handler(void *os_vif_ctx,
						struct nrf_wifi_umac_event_set_interface *event,
						unsigned int event_len);

int nrf_wifi_stats_reset(const struct device *dev);
#endif /* __ZEPHYR_NET_IF_H__ */
+1 −0
Original line number Diff line number Diff line
@@ -820,6 +820,7 @@ static struct wifi_mgmt_ops nrf_wifi_mgmt_ops = {
	.scan = nrf_wifi_disp_scan_zep,
#ifdef CONFIG_NET_STATISTICS_WIFI
	.get_stats = nrf_wifi_stats_get,
	.reset_stats = nrf_wifi_stats_reset,
#endif /* CONFIG_NET_STATISTICS_WIFI */
#ifdef CONFIG_NRF70_STA_MODE
	.set_power_save = nrf_wifi_set_power_save,
+48 −0
Original line number Diff line number Diff line
@@ -1142,4 +1142,52 @@ unlock:
out:
	return ret;
}

int nrf_wifi_stats_reset(const struct device *dev)
{
	enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL;
	struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL;
	struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL;
	struct nrf_wifi_fmac_dev_ctx_def *def_dev_ctx = NULL;
	int ret = -1;

	if (!dev) {
		LOG_ERR("%s Device not found", __func__);
		goto out;
	}

	vif_ctx_zep = dev->data;
	if (!vif_ctx_zep) {
		LOG_ERR("%s: vif_ctx_zep is NULL", __func__);
		goto out;
	}

	ret = k_mutex_lock(&vif_ctx_zep->vif_lock, K_FOREVER);
	if (ret != 0) {
		LOG_ERR("%s: Failed to lock vif_lock", __func__);
		goto out;
	}

	rpu_ctx_zep = vif_ctx_zep->rpu_ctx_zep;
	if (!rpu_ctx_zep || !rpu_ctx_zep->rpu_ctx) {
		LOG_DBG("%s: rpu_ctx_zep or rpu_ctx is NULL",
			__func__);
		goto unlock;
	}

	status = nrf_wifi_fmac_stats_reset(rpu_ctx_zep->rpu_ctx);
	if (status != NRF_WIFI_STATUS_SUCCESS) {
		LOG_ERR("%s: nrf_wifi_fmac_stats_reset failed", __func__);
		goto unlock;
	}

	def_dev_ctx = wifi_dev_priv(rpu_ctx_zep->rpu_ctx);
	memset(&def_dev_ctx->host_stats, 0, sizeof(struct rpu_host_stats));

	ret = 0;
unlock:
	k_mutex_unlock(&vif_ctx_zep->vif_lock);
out:
	return ret;
}
#endif /* CONFIG_NET_STATISTICS_WIFI */