@@ -1208,9 +1208,7 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats)
12081208	enum  nrf_wifi_status  status  =  NRF_WIFI_STATUS_FAIL ;
12091209	struct  nrf_wifi_ctx_zep  * rpu_ctx_zep  =  NULL ;
12101210	struct  nrf_wifi_vif_ctx_zep  * vif_ctx_zep  =  NULL ;
1211- #ifdef  CONFIG_NRF70_RAW_DATA_TX 
12121211	struct  nrf_wifi_sys_fmac_dev_ctx  * sys_dev_ctx  =  NULL ;
1213- #endif  /* CONFIG_NRF70_RAW_DATA_TX */ 
12141212	struct  rpu_sys_op_stats  stats ;
12151213	int  ret  =  -1 ;
12161214
@@ -1241,19 +1239,38 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats)
12411239			__func__ );
12421240		goto unlock ;
12431241	}
1244- 
1245- 	memset (& stats , 0 , sizeof (struct  rpu_sys_op_stats ));
1246- 	status  =  nrf_wifi_sys_fmac_stats_get (rpu_ctx_zep -> rpu_ctx , 0 , & stats );
1247- 	if  (status  !=  NRF_WIFI_STATUS_SUCCESS ) {
1248- 		LOG_ERR ("%s: nrf_wifi_fmac_stats_get failed" , __func__ );
1242+ 	sys_dev_ctx  =  wifi_dev_priv (rpu_ctx_zep -> rpu_ctx );
1243+ 	if  (!sys_dev_ctx ) {
1244+ 		LOG_ERR ("%s: sys_dev_ctx is NULL" , __func__ );
12491245		goto unlock ;
12501246	}
12511247
1248+ 	memset (& stats , 0 , sizeof (struct  rpu_sys_op_stats ));
1249+ 	/* Host statistics */ 
1250+ 	nrf_wifi_osal_mem_cpy (& stats .host ,
1251+ 			      & sys_dev_ctx -> host_stats ,
1252+ 			      sizeof (sys_dev_ctx -> host_stats ));
12521253	zstats -> pkts .tx  =  stats .host .total_tx_pkts ;
12531254	zstats -> pkts .rx  =  stats .host .total_rx_pkts ;
12541255	zstats -> errors .tx  =  stats .host .total_tx_drop_pkts ;
12551256	zstats -> errors .rx  =  stats .host .total_rx_drop_pkts  + 
12561257			stats .fw .umac .interface_data_stats .rx_checksum_error_count ;
1258+ 	zstats -> overrun_count  =  stats .host .total_tx_drop_pkts  +  stats .host .total_rx_drop_pkts ;
1259+ #ifdef  CONFIG_NRF70_RAW_DATA_TX 
1260+ 	zstats -> errors .tx  +=  sys_dev_ctx -> raw_pkt_stats .raw_pkt_send_failure ;
1261+ #endif  /* CONFIG_NRF70_RAW_DATA_TX */ 
1262+ 
1263+ 	/* FMAC statistics */ 
1264+ 	status  =  nrf_wifi_sys_fmac_stats_get (rpu_ctx_zep -> rpu_ctx , 0 , & stats );
1265+ 	if  (status  !=  NRF_WIFI_STATUS_SUCCESS ) {
1266+ 		LOG_WRN ("%s: nrf_wifi_fmac_stats_get failed" , __func__ );
1267+ 		/* Special value to indicate that 
1268+ 		 * statistics are not available. 
1269+ 		 */ 
1270+ 		memset (& stats .fw .umac .interface_data_stats , 0xAA ,
1271+ 		       sizeof (stats .fw .umac .interface_data_stats ));
1272+ 	}
1273+ 
12571274	zstats -> bytes .received  =  stats .fw .umac .interface_data_stats .rx_bytes ;
12581275	zstats -> bytes .sent  =  stats .fw .umac .interface_data_stats .tx_bytes ;
12591276	zstats -> sta_mgmt .beacons_rx  =  stats .fw .umac .interface_data_stats .rx_beacon_success_count ;
@@ -1264,12 +1281,7 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats)
12641281	zstats -> multicast .tx  =  stats .fw .umac .interface_data_stats .tx_multicast_pkt_count ;
12651282	zstats -> unicast .rx    =  stats .fw .umac .interface_data_stats .rx_unicast_pkt_count ;
12661283	zstats -> unicast .tx    =  stats .fw .umac .interface_data_stats .tx_unicast_pkt_count ;
1267- 	zstats -> overrun_count  =  stats .host .total_tx_drop_pkts  +  stats .host .total_rx_drop_pkts ;
12681284
1269- #ifdef  CONFIG_NRF70_RAW_DATA_TX 
1270- 	sys_dev_ctx  =  wifi_dev_priv (rpu_ctx_zep -> rpu_ctx );
1271- 	zstats -> errors .tx  +=  sys_dev_ctx -> raw_pkt_stats .raw_pkt_send_failure ;
1272- #endif  /* CONFIG_NRF70_RAW_DATA_TX */ 
12731285	ret  =  0 ;
12741286unlock :
12751287	k_mutex_unlock (& vif_ctx_zep -> vif_lock );
0 commit comments