@@ -1210,7 +1210,8 @@ int nrf_wifi_if_set_config_zep(const struct device *dev,
12101210}
12111211
12121212#ifdef CONFIG_NET_STATISTICS_ETHERNET
1213- struct net_stats_eth * nrf_wifi_eth_stats_get (const struct device * dev )
1213+ struct net_stats_eth * nrf_wifi_eth_stats_get_type (const struct device * dev ,
1214+ uint32_t type )
12141215{
12151216 struct nrf_wifi_vif_ctx_zep * vif_ctx_zep = NULL ;
12161217#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
@@ -1222,24 +1223,34 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
12221223 const uint8_t * fw_stats_bytes ;
12231224 size_t i ;
12241225 int vendor_idx = 0 ;
1225- #endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
1226+ const char * * key_ptr ;
1227+ uint32_t * val_ptr ;
1228+ uint32_t val ;
1229+ #endif
12261230
12271231 if (!dev ) {
12281232 LOG_ERR ("%s Device not found" , __func__ );
1229- goto out ;
1233+ goto err ;
12301234 }
12311235
12321236 vif_ctx_zep = dev -> data ;
12331237 if (!vif_ctx_zep ) {
12341238 LOG_ERR ("%s: vif_ctx_zep is NULL" , __func__ );
1235- goto out ;
1239+ goto err ;
1240+ }
1241+
1242+ if (!(type & ETHERNET_STATS_TYPE_VENDOR )) {
1243+ #ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
1244+ vif_ctx_zep -> eth_stats .vendor = NULL ;
1245+ #endif
1246+ goto done ;
12361247 }
12371248
12381249#ifdef CONFIG_NET_STATISTICS_ETHERNET_VENDOR
12391250 rpu_ctx_zep = vif_ctx_zep -> rpu_ctx_zep ;
12401251 if (!rpu_ctx_zep || !rpu_ctx_zep -> rpu_ctx ) {
12411252 LOG_ERR ("%s: rpu_ctx_zep or rpu_ctx is NULL" , __func__ );
1242- goto out ;
1253+ goto err ;
12431254 }
12441255
12451256 memset (& stats , 0 , sizeof (stats ));
@@ -1248,7 +1259,7 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
12481259 & stats );
12491260 if (status != NRF_WIFI_STATUS_SUCCESS ) {
12501261 LOG_ERR ("%s: Failed to get RPU stats" , __func__ );
1251- goto ret ;
1262+ goto done ;
12521263 }
12531264
12541265 /* Treat stats.fw as a blob and divide into uint32_t chunks */
@@ -1257,49 +1268,34 @@ struct net_stats_eth *nrf_wifi_eth_stats_get(const struct device *dev)
12571268 fw_stats_bytes = (const uint8_t * )& stats .fw ;
12581269
12591270 vendor_idx = 0 ;
1260-
12611271 for (i = 0 ; i < num_uint32 && vendor_idx < MAX_VENDOR_STATS - 1 ; i ++ ) {
1262- uint32_t val ;
1263- const char * * key_ptr ;
1264- uint32_t * val_ptr ;
1265-
1266- /* Extract uint32_t value from blob */
1267- memcpy (& val , fw_stats_bytes + i * sizeof (uint32_t ), sizeof (uint32_t ));
1272+ memcpy (& val , fw_stats_bytes + i * sizeof (uint32_t ),
1273+ sizeof (uint32_t ));
12681274
1269- /* Create key name */
1270- snprintk ( vif_ctx_zep -> vendor_key_strings [ vendor_idx ], 16 , "fw_%zu" , i );
1275+ snprintk ( vif_ctx_zep -> vendor_key_strings [ vendor_idx ], 16 ,
1276+ "fw_%zu" , i );
12711277
1272- /* Assign key */
1273- key_ptr = (const char * * )
1274- & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].key ;
1278+ key_ptr = (const char * * ) & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].key ;
12751279 * key_ptr = vif_ctx_zep -> vendor_key_strings [vendor_idx ];
12761280
1277- /* Assign value */
1278- val_ptr = (uint32_t * )
1279- & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].value ;
1281+ val_ptr = (uint32_t * ) & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].value ;
12801282 * val_ptr = val ;
12811283
12821284 vendor_idx ++ ;
12831285 }
12841286
1285- /* Null terminator entry */
1286- {
1287- const char * * key_ptr = (const char * * )
1288- & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].key ;
1289- uint32_t * val_ptr = (uint32_t * )
1290- & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].value ;
1291-
1292- * key_ptr = NULL ;
1293- * val_ptr = 0 ;
1294- }
1287+ key_ptr = (const char * * ) & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].key ;
1288+ val_ptr = (uint32_t * ) & vif_ctx_zep -> eth_stats_vendor_data [vendor_idx ].value ;
1289+ * key_ptr = NULL ;
1290+ * val_ptr = 0 ;
12951291
1296- /* Point to the static vendor data */
12971292 vif_ctx_zep -> eth_stats .vendor = vif_ctx_zep -> eth_stats_vendor_data ;
1293+ #endif
12981294
1299- ret :
1300- #endif /* CONFIG_NET_STATISTICS_ETHERNET_VENDOR */
1295+ done :
13011296 return & vif_ctx_zep -> eth_stats ;
1302- out :
1297+
1298+ err :
13031299 return NULL ;
13041300}
13051301#endif /* CONFIG_NET_STATISTICS_ETHERNET */
0 commit comments