@@ -298,13 +298,78 @@ static int siwx917_scan(const struct device *dev, struct wifi_scan_params *z_sca
298
298
static int siwx917_status (const struct device * dev , struct wifi_iface_status * status )
299
299
{
300
300
struct siwx917_dev * sidev = dev -> data ;
301
+ sl_si91x_rsp_wireless_info_t wlan_info = { };
302
+ int ret ;
301
303
int32_t rssi = -1 ;
302
304
305
+ __ASSERT (status , "status cannot be NULL" );
306
+
303
307
memset (status , 0 , sizeof (* status ));
304
308
status -> state = sidev -> state ;
305
- sl_wifi_get_signal_strength (SL_WIFI_CLIENT_INTERFACE , & rssi );
306
- status -> rssi = rssi ;
307
- return 0 ;
309
+
310
+ ret = sl_wifi_get_wireless_info (& wlan_info );
311
+ if (ret ) {
312
+ LOG_ERR ("Failed to get the wireless info: 0x%x" , ret );
313
+ return - EIO ;
314
+ }
315
+
316
+ strncpy (status -> ssid , wlan_info .ssid , WIFI_SSID_MAX_LEN );
317
+ status -> ssid_len = strlen (status -> ssid );
318
+ memcpy (status -> bssid , wlan_info .mac_address , WIFI_MAC_ADDR_LEN );
319
+ status -> mfp = WIFI_MFP_REQUIRED ;
320
+
321
+ if (FIELD_GET (SL_WIFI_2_4GHZ_INTERFACE , sidev -> interface )) {
322
+ status -> band = WIFI_FREQ_BAND_2_4_GHZ ;
323
+ }
324
+
325
+ if (FIELD_GET (SL_WIFI_CLIENT_INTERFACE , sidev -> interface )) {
326
+ sl_wifi_listen_interval_t listen_interval = { };
327
+
328
+ status -> link_mode = WIFI_LINK_MODE_UNKNOWN ;
329
+ status -> iface_mode = WIFI_MODE_INFRA ;
330
+ status -> channel = wlan_info .channel_number ;
331
+ sl_wifi_get_signal_strength (SL_WIFI_CLIENT_INTERFACE , & rssi );
332
+ status -> rssi = rssi ;
333
+
334
+ sl_wifi_get_listen_interval (SL_WIFI_CLIENT_INTERFACE , & listen_interval );
335
+ status -> beacon_interval = listen_interval .listen_interval ;
336
+ } else if (FIELD_GET (SL_WIFI_AP_INTERFACE , sidev -> interface )) {
337
+ sl_wifi_ap_configuration_t conf = { };
338
+
339
+ ret = sl_wifi_get_ap_configuration (SL_WIFI_AP_INTERFACE , & conf );
340
+ if (ret ) {
341
+ LOG_ERR ("Failed to get the AP configuration: 0x%x" , ret );
342
+ return - EINVAL ;
343
+ }
344
+
345
+ status -> link_mode = WIFI_4 ;
346
+ status -> iface_mode = WIFI_MODE_AP ;
347
+ status -> channel = conf .channel .channel ;
348
+ status -> beacon_interval = conf .beacon_interval ;
349
+ status -> dtim_period = conf .dtim_beacon_count ;
350
+ } else {
351
+ status -> link_mode = WIFI_LINK_MODE_UNKNOWN ;
352
+ status -> iface_mode = WIFI_MODE_UNKNOWN ;
353
+ status -> channel = 0 ;
354
+
355
+ return - EINVAL ;
356
+ }
357
+
358
+ switch (wlan_info .sec_type ) {
359
+ case SL_WIFI_OPEN :
360
+ status -> security = WIFI_SECURITY_TYPE_NONE ;
361
+ break ;
362
+ case SL_WIFI_WPA2 :
363
+ status -> security = WIFI_SECURITY_TYPE_PSK ;
364
+ break ;
365
+ case SL_WIFI_WPA3 :
366
+ status -> security = WIFI_SECURITY_TYPE_SAE ;
367
+ break ;
368
+ default :
369
+ status -> security = WIFI_SECURITY_TYPE_UNKNOWN ;
370
+ }
371
+
372
+ return ret ;
308
373
}
309
374
310
375
#ifdef CONFIG_WIFI_SIWX917_NET_STACK_NATIVE
@@ -545,6 +610,34 @@ static sl_status_t siwx917_on_disconnect(sl_wifi_event_t event, void *data,
545
610
return SL_STATUS_OK ;
546
611
}
547
612
613
+ #if defined(CONFIG_NET_STATISTICS_WIFI )
614
+ static int siwx917_stats (const struct device * dev , struct net_stats_wifi * stats )
615
+ {
616
+ struct siwx917_dev * sidev = dev -> data ;
617
+ sl_wifi_statistics_t statistics = { };
618
+ int ret ;
619
+
620
+ __ASSERT (stats , "stats cannot be NULL" );
621
+
622
+ ret = sl_wifi_get_statistics (FIELD_GET (SIWX917_INTERFACE_MASK , sidev -> interface ),
623
+ & statistics );
624
+ if (ret ) {
625
+ LOG_ERR ("Failed to get stat: 0x%x" , ret );
626
+ return - EINVAL ;
627
+ }
628
+
629
+ stats -> multicast .rx = statistics .mcast_rx_count ;
630
+ stats -> multicast .tx = statistics .mcast_tx_count ;
631
+ stats -> unicast .rx = statistics .ucast_rx_count ;
632
+ stats -> unicast .tx = statistics .ucast_tx_count ;
633
+ stats -> sta_mgmt .beacons_rx = statistics .beacon_rx_count ;
634
+ stats -> sta_mgmt .beacons_miss = statistics .beacon_lost_count ;
635
+ stats -> overrun_count = statistics .overrun_count ;
636
+
637
+ return ret ;
638
+ }
639
+ #endif
640
+
548
641
static void siwx917_iface_init (struct net_if * iface )
549
642
{
550
643
struct siwx917_dev * sidev = iface -> if_dev -> dev -> data ;
@@ -588,6 +681,9 @@ static const struct wifi_mgmt_ops siwx917_mgmt = {
588
681
.ap_disable = siwx917_ap_disable ,
589
682
.ap_sta_disconnect = siwx917_ap_sta_disconnect ,
590
683
.iface_status = siwx917_status ,
684
+ #if defined(CONFIG_NET_STATISTICS_WIFI )
685
+ .get_stats = siwx917_stats ,
686
+ #endif
591
687
};
592
688
593
689
static const struct net_wifi_mgmt_offload siwx917_api = {
0 commit comments