@@ -462,13 +462,80 @@ static int siwx91x_scan(const struct device *dev, struct wifi_scan_params *z_sca
462
462
static int siwx91x_status (const struct device * dev , struct wifi_iface_status * status )
463
463
{
464
464
struct siwx91x_dev * sidev = dev -> data ;
465
+ sl_wifi_interface_t interface ;
466
+ sl_si91x_rsp_wireless_info_t wlan_info = { };
467
+ int ret ;
465
468
int32_t rssi = -1 ;
466
469
470
+ __ASSERT (status , "status cannot be NULL" );
471
+
467
472
memset (status , 0 , sizeof (* status ));
468
473
status -> state = sidev -> state ;
469
- sl_wifi_get_signal_strength (SL_WIFI_CLIENT_INTERFACE , & rssi );
470
- status -> rssi = rssi ;
471
- return 0 ;
474
+
475
+ interface = sl_wifi_get_default_interface ();
476
+ ret = sl_wifi_get_wireless_info (& wlan_info );
477
+ if (ret ) {
478
+ LOG_ERR ("Failed to get the wireless info: 0x%x" , ret );
479
+ return - EIO ;
480
+ }
481
+
482
+ strncpy (status -> ssid , wlan_info .ssid , WIFI_SSID_MAX_LEN );
483
+ status -> ssid_len = strlen (status -> ssid );
484
+ memcpy (status -> bssid , wlan_info .mac_address , WIFI_MAC_ADDR_LEN );
485
+ status -> mfp = WIFI_MFP_REQUIRED ;
486
+
487
+ if (FIELD_GET (SL_WIFI_2_4GHZ_INTERFACE , interface )) {
488
+ status -> band = WIFI_FREQ_BAND_2_4_GHZ ;
489
+ }
490
+
491
+ if (FIELD_GET (SL_WIFI_CLIENT_INTERFACE , interface )) {
492
+ sl_wifi_listen_interval_t listen_interval = { };
493
+
494
+ status -> link_mode = WIFI_LINK_MODE_UNKNOWN ;
495
+ status -> iface_mode = WIFI_MODE_INFRA ;
496
+ status -> channel = wlan_info .channel_number ;
497
+ sl_wifi_get_signal_strength (SL_WIFI_CLIENT_INTERFACE , & rssi );
498
+ status -> rssi = rssi ;
499
+
500
+ sl_wifi_get_listen_interval (SL_WIFI_CLIENT_INTERFACE , & listen_interval );
501
+ status -> beacon_interval = listen_interval .listen_interval ;
502
+ } else if (FIELD_GET (SL_WIFI_AP_INTERFACE , interface )) {
503
+ sl_wifi_ap_configuration_t conf = { };
504
+
505
+ ret = sl_wifi_get_ap_configuration (SL_WIFI_AP_INTERFACE , & conf );
506
+ if (ret ) {
507
+ LOG_ERR ("Failed to get the AP configuration: 0x%x" , ret );
508
+ return - EINVAL ;
509
+ }
510
+
511
+ status -> link_mode = WIFI_4 ;
512
+ status -> iface_mode = WIFI_MODE_AP ;
513
+ status -> channel = conf .channel .channel ;
514
+ status -> beacon_interval = conf .beacon_interval ;
515
+ status -> dtim_period = conf .dtim_beacon_count ;
516
+ } else {
517
+ status -> link_mode = WIFI_LINK_MODE_UNKNOWN ;
518
+ status -> iface_mode = WIFI_MODE_UNKNOWN ;
519
+ status -> channel = 0 ;
520
+
521
+ return - EINVAL ;
522
+ }
523
+
524
+ switch (wlan_info .sec_type ) {
525
+ case SL_WIFI_OPEN :
526
+ status -> security = WIFI_SECURITY_TYPE_NONE ;
527
+ break ;
528
+ case SL_WIFI_WPA2 :
529
+ status -> security = WIFI_SECURITY_TYPE_PSK ;
530
+ break ;
531
+ case SL_WIFI_WPA3 :
532
+ status -> security = WIFI_SECURITY_TYPE_SAE ;
533
+ break ;
534
+ default :
535
+ status -> security = WIFI_SECURITY_TYPE_UNKNOWN ;
536
+ }
537
+
538
+ return ret ;
472
539
}
473
540
474
541
#ifdef CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_NATIVE
@@ -548,6 +615,35 @@ static void siwx91x_ethernet_init(struct net_if *iface)
548
615
}
549
616
}
550
617
618
+ #if defined(CONFIG_NET_STATISTICS_WIFI )
619
+ static int siwx91x_stats (const struct device * dev , struct net_stats_wifi * stats )
620
+ {
621
+ ARG_UNUSED (dev );
622
+ sl_wifi_interface_t interface ;
623
+ sl_wifi_statistics_t statistics = { };
624
+ int ret ;
625
+
626
+ __ASSERT (stats , "stats cannot be NULL" );
627
+
628
+ interface = sl_wifi_get_default_interface ();
629
+ ret = sl_wifi_get_statistics (FIELD_GET (SIWX91X_INTERFACE_MASK , interface ), & statistics );
630
+ if (ret ) {
631
+ LOG_ERR ("Failed to get stat: 0x%x" , ret );
632
+ return - EINVAL ;
633
+ }
634
+
635
+ stats -> multicast .rx = statistics .mcast_rx_count ;
636
+ stats -> multicast .tx = statistics .mcast_tx_count ;
637
+ stats -> unicast .rx = statistics .ucast_rx_count ;
638
+ stats -> unicast .tx = statistics .ucast_tx_count ;
639
+ stats -> sta_mgmt .beacons_rx = statistics .beacon_rx_count ;
640
+ stats -> sta_mgmt .beacons_miss = statistics .beacon_lost_count ;
641
+ stats -> overrun_count = statistics .overrun_count ;
642
+
643
+ return ret ;
644
+ }
645
+ #endif
646
+
551
647
static void siwx91x_iface_init (struct net_if * iface )
552
648
{
553
649
struct siwx91x_dev * sidev = iface -> if_dev -> dev -> data ;
@@ -593,6 +689,9 @@ static const struct wifi_mgmt_ops siwx91x_mgmt = {
593
689
.ap_disable = siwx91x_ap_disable ,
594
690
.ap_sta_disconnect = siwx91x_ap_sta_disconnect ,
595
691
.iface_status = siwx91x_status ,
692
+ #if defined(CONFIG_NET_STATISTICS_WIFI )
693
+ .get_stats = siwx91x_stats ,
694
+ #endif
596
695
};
597
696
598
697
static const struct net_wifi_mgmt_offload siwx91x_api = {
0 commit comments