@@ -1208,9 +1208,7 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats)
1208
1208
enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL ;
1209
1209
struct nrf_wifi_ctx_zep * rpu_ctx_zep = NULL ;
1210
1210
struct nrf_wifi_vif_ctx_zep * vif_ctx_zep = NULL ;
1211
- #ifdef CONFIG_NRF70_RAW_DATA_TX
1212
1211
struct nrf_wifi_sys_fmac_dev_ctx * sys_dev_ctx = NULL ;
1213
- #endif /* CONFIG_NRF70_RAW_DATA_TX */
1214
1212
struct rpu_sys_op_stats stats ;
1215
1213
int ret = -1 ;
1216
1214
@@ -1241,19 +1239,38 @@ int nrf_wifi_stats_get(const struct device *dev, struct net_stats_wifi *zstats)
1241
1239
__func__ );
1242
1240
goto unlock ;
1243
1241
}
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__ );
1249
1245
goto unlock ;
1250
1246
}
1251
1247
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 ));
1252
1253
zstats -> pkts .tx = stats .host .total_tx_pkts ;
1253
1254
zstats -> pkts .rx = stats .host .total_rx_pkts ;
1254
1255
zstats -> errors .tx = stats .host .total_tx_drop_pkts ;
1255
1256
zstats -> errors .rx = stats .host .total_rx_drop_pkts +
1256
1257
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
+
1257
1274
zstats -> bytes .received = stats .fw .umac .interface_data_stats .rx_bytes ;
1258
1275
zstats -> bytes .sent = stats .fw .umac .interface_data_stats .tx_bytes ;
1259
1276
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)
1264
1281
zstats -> multicast .tx = stats .fw .umac .interface_data_stats .tx_multicast_pkt_count ;
1265
1282
zstats -> unicast .rx = stats .fw .umac .interface_data_stats .rx_unicast_pkt_count ;
1266
1283
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 ;
1268
1284
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 */
1273
1285
ret = 0 ;
1274
1286
unlock :
1275
1287
k_mutex_unlock (& vif_ctx_zep -> vif_lock );
0 commit comments