@@ -477,14 +477,81 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
477
477
478
478
static int siwx91x_status (const struct device * dev , struct wifi_iface_status * status )
479
479
{
480
+ sl_si91x_rsp_wireless_info_t wlan_info = { };
480
481
struct siwx91x_dev * sidev = dev -> data ;
482
+ sl_wifi_interface_t interface ;
481
483
int32_t rssi = -1 ;
484
+ int ret ;
485
+
486
+ __ASSERT (status , "status cannot be NULL" );
482
487
483
488
memset (status , 0 , sizeof (* status ));
484
489
status -> state = sidev -> state ;
485
- sl_wifi_get_signal_strength (SL_WIFI_CLIENT_INTERFACE , & rssi );
486
- status -> rssi = rssi ;
487
- return 0 ;
490
+
491
+ interface = sl_wifi_get_default_interface ();
492
+ ret = sl_wifi_get_wireless_info (& wlan_info );
493
+ if (ret ) {
494
+ LOG_ERR ("Failed to get the wireless info: 0x%x" , ret );
495
+ return - EIO ;
496
+ }
497
+
498
+ strncpy (status -> ssid , wlan_info .ssid , WIFI_SSID_MAX_LEN );
499
+ status -> ssid_len = strlen (status -> ssid );
500
+ memcpy (status -> bssid , wlan_info .mac_address , WIFI_MAC_ADDR_LEN );
501
+ status -> mfp = WIFI_MFP_UNKNOWN ;
502
+
503
+ if (interface & SL_WIFI_2_4GHZ_INTERFACE ) {
504
+ status -> band = WIFI_FREQ_BAND_2_4_GHZ ;
505
+ }
506
+
507
+ if (FIELD_GET (SIWX91X_INTERFACE_MASK , interface ) == SL_WIFI_CLIENT_INTERFACE ) {
508
+ sl_wifi_listen_interval_t listen_interval = { };
509
+
510
+ status -> link_mode = WIFI_LINK_MODE_UNKNOWN ;
511
+ status -> iface_mode = WIFI_MODE_INFRA ;
512
+ status -> channel = wlan_info .channel_number ;
513
+ sl_wifi_get_signal_strength (SL_WIFI_CLIENT_INTERFACE , & rssi );
514
+ status -> rssi = rssi ;
515
+
516
+ sl_wifi_get_listen_interval (SL_WIFI_CLIENT_INTERFACE , & listen_interval );
517
+ status -> beacon_interval = listen_interval .listen_interval ;
518
+ } else if (FIELD_GET (SIWX91X_INTERFACE_MASK , interface ) == SL_WIFI_AP_INTERFACE ) {
519
+ sl_wifi_ap_configuration_t sl_ap_cfg = { };
520
+
521
+ ret = sl_wifi_get_ap_configuration (SL_WIFI_AP_INTERFACE , & sl_ap_cfg );
522
+ if (ret ) {
523
+ LOG_ERR ("Failed to get the AP configuration: 0x%x" , ret );
524
+ return - EINVAL ;
525
+ }
526
+
527
+ status -> link_mode = WIFI_4 ;
528
+ status -> iface_mode = WIFI_MODE_AP ;
529
+ status -> channel = sl_ap_cfg .channel .channel ;
530
+ status -> beacon_interval = sl_ap_cfg .beacon_interval ;
531
+ status -> dtim_period = sl_ap_cfg .dtim_beacon_count ;
532
+ } else {
533
+ status -> link_mode = WIFI_LINK_MODE_UNKNOWN ;
534
+ status -> iface_mode = WIFI_MODE_UNKNOWN ;
535
+ status -> channel = 0 ;
536
+
537
+ return - EINVAL ;
538
+ }
539
+
540
+ switch (wlan_info .sec_type ) {
541
+ case SL_WIFI_OPEN :
542
+ status -> security = WIFI_SECURITY_TYPE_NONE ;
543
+ break ;
544
+ case SL_WIFI_WPA2 :
545
+ status -> security = WIFI_SECURITY_TYPE_PSK ;
546
+ break ;
547
+ case SL_WIFI_WPA3 :
548
+ status -> security = WIFI_SECURITY_TYPE_SAE ;
549
+ break ;
550
+ default :
551
+ status -> security = WIFI_SECURITY_TYPE_UNKNOWN ;
552
+ }
553
+
554
+ return ret ;
488
555
}
489
556
490
557
static int siwx91x_mode (const struct device * dev , struct wifi_mode_info * mode )
@@ -590,6 +657,35 @@ static void siwx91x_ethernet_init(struct net_if *iface)
590
657
}
591
658
}
592
659
660
+ #if defined(CONFIG_NET_STATISTICS_WIFI )
661
+ static int siwx91x_stats (const struct device * dev , struct net_stats_wifi * stats )
662
+ {
663
+ ARG_UNUSED (dev );
664
+ sl_wifi_interface_t interface ;
665
+ sl_wifi_statistics_t statistics = { };
666
+ int ret ;
667
+
668
+ __ASSERT (stats , "stats cannot be NULL" );
669
+
670
+ interface = sl_wifi_get_default_interface ();
671
+ ret = sl_wifi_get_statistics (FIELD_GET (SIWX91X_INTERFACE_MASK , interface ), & statistics );
672
+ if (ret ) {
673
+ LOG_ERR ("Failed to get stat: 0x%x" , ret );
674
+ return - EINVAL ;
675
+ }
676
+
677
+ stats -> multicast .rx = statistics .mcast_rx_count ;
678
+ stats -> multicast .tx = statistics .mcast_tx_count ;
679
+ stats -> unicast .rx = statistics .ucast_rx_count ;
680
+ stats -> unicast .tx = statistics .ucast_tx_count ;
681
+ stats -> sta_mgmt .beacons_rx = statistics .beacon_rx_count ;
682
+ stats -> sta_mgmt .beacons_miss = statistics .beacon_lost_count ;
683
+ stats -> overrun_count = statistics .overrun_count ;
684
+
685
+ return ret ;
686
+ }
687
+ #endif
688
+
593
689
static void siwx91x_iface_init (struct net_if * iface )
594
690
{
595
691
struct siwx91x_dev * sidev = iface -> if_dev -> dev -> data ;
@@ -633,6 +729,9 @@ static const struct wifi_mgmt_ops siwx91x_mgmt = {
633
729
.ap_sta_disconnect = siwx91x_ap_sta_disconnect ,
634
730
.iface_status = siwx91x_status ,
635
731
.mode = siwx91x_mode ,
732
+ #if defined(CONFIG_NET_STATISTICS_WIFI )
733
+ .get_stats = siwx91x_stats ,
734
+ #endif
636
735
};
637
736
638
737
static const struct net_wifi_mgmt_offload siwx91x_api = {
0 commit comments