|
13 | 13 | #include <zephyr/net/conn_mgr/connectivity_wifi_mgmt.h>
|
14 | 14 | #include <airoc_wifi.h>
|
15 | 15 | #include <airoc_whd_hal_common.h>
|
| 16 | +#include <whd_wlioctl.h> |
16 | 17 |
|
17 | 18 | LOG_MODULE_REGISTER(infineon_airoc_wifi, CONFIG_WIFI_LOG_LEVEL);
|
18 | 19 |
|
@@ -760,6 +761,89 @@ static int airoc_mgmt_ap_disable(const struct device *dev)
|
760 | 761 | return 0;
|
761 | 762 | }
|
762 | 763 |
|
| 764 | +static int airoc_iface_status(const struct device *dev, |
| 765 | + struct wifi_iface_status *status) |
| 766 | +{ |
| 767 | + if (airoc_if == NULL) { |
| 768 | + return -ENOTSUP; |
| 769 | + } |
| 770 | + |
| 771 | + struct airoc_wifi_data *data = dev->data; |
| 772 | + whd_result_t result; |
| 773 | + wl_bss_info_t bss_info; |
| 774 | + whd_security_t security_info = 0; |
| 775 | + uint32_t wpa_data_rate_value = 0; |
| 776 | + |
| 777 | + status->iface_mode = (data->is_ap_up ? WIFI_MODE_AP : |
| 778 | + (data->is_sta_connected ? WIFI_MODE_INFRA : |
| 779 | + WIFI_MODE_UNKNOWN)); |
| 780 | + |
| 781 | + uint32_t join_status = whd_wifi_is_ready_to_transceive(airoc_if); |
| 782 | + |
| 783 | + if (join_status == WHD_SUCCESS) { |
| 784 | + status->state = WIFI_STATE_COMPLETED; |
| 785 | + } |
| 786 | + else if (join_status == WHD_JOIN_IN_PROGRESS) { |
| 787 | + status->state = WIFI_STATE_ASSOCIATING; |
| 788 | + } |
| 789 | + else if (join_status == WHD_NOT_KEYED) { |
| 790 | + status->state = WIFI_STATE_AUTHENTICATING; |
| 791 | + } |
| 792 | + else { |
| 793 | + status->state = WIFI_STATE_DISCONNECTED; |
| 794 | + } |
| 795 | + |
| 796 | + result = whd_wifi_get_ap_info(airoc_if, &bss_info, &security_info); |
| 797 | + |
| 798 | + if (result == WHD_SUCCESS) { |
| 799 | + memcpy(&(status->bssid[0]), &(bss_info.BSSID), sizeof(whd_mac_t)); |
| 800 | + |
| 801 | + whd_wifi_get_channel(airoc_if, (int *) &status->channel); |
| 802 | + |
| 803 | + status->band = (status->channel <= CH_MAX_2G_CHANNEL) ? WIFI_FREQ_BAND_2_4_GHZ : WIFI_FREQ_BAND_5_GHZ; |
| 804 | + |
| 805 | + status->rssi = (int) bss_info.RSSI; |
| 806 | + |
| 807 | + status->ssid_len = bss_info.SSID_len; |
| 808 | + strncpy(status->ssid, bss_info.SSID, bss_info.SSID_len); |
| 809 | + |
| 810 | + status->security = convert_whd_security_to_zephyr(security_info); |
| 811 | + |
| 812 | + status->beacon_interval = (unsigned short) bss_info.beacon_period; |
| 813 | + status->dtim_period = (unsigned char) bss_info.dtim_period; |
| 814 | + |
| 815 | + status->twt_capable = false; |
| 816 | + } |
| 817 | + |
| 818 | + whd_wifi_get_ioctl_value(airoc_if, WLC_GET_RATE, &wpa_data_rate_value); |
| 819 | + status->current_phy_tx_rate = wpa_data_rate_value; |
| 820 | + |
| 821 | + /* Unbelievably, this appears to be the only way to determine the phy mode with |
| 822 | + the whd SDK that we're currently using. Note that the logic below is only valid on |
| 823 | + devices that are limited to the 2.4Ghz band. Other versions of the SDK and chip evidently |
| 824 | + allow one to obtain a phy_mode value directly from bss_info */ |
| 825 | + if (wpa_data_rate_value > 54) { |
| 826 | + status->link_mode = WIFI_4; |
| 827 | + } |
| 828 | + else if (wpa_data_rate_value == 6 || |
| 829 | + wpa_data_rate_value == 9 || |
| 830 | + wpa_data_rate_value == 12 || |
| 831 | + wpa_data_rate_value == 18 || |
| 832 | + wpa_data_rate_value == 24 || |
| 833 | + wpa_data_rate_value == 36 || |
| 834 | + wpa_data_rate_value == 48 || |
| 835 | + wpa_data_rate_value == 54) { |
| 836 | + status->link_mode = WIFI_3; |
| 837 | + } |
| 838 | + else { |
| 839 | + status->link_mode = WIFI_1; |
| 840 | + } |
| 841 | + |
| 842 | + return 0; |
| 843 | +} |
| 844 | + |
| 845 | + |
| 846 | + |
763 | 847 | static int airoc_init(const struct device *dev)
|
764 | 848 | {
|
765 | 849 | int ret;
|
@@ -813,6 +897,7 @@ static const struct wifi_mgmt_ops airoc_wifi_mgmt = {
|
813 | 897 | .disconnect = airoc_mgmt_disconnect,
|
814 | 898 | .ap_enable = airoc_mgmt_ap_enable,
|
815 | 899 | .ap_disable = airoc_mgmt_ap_disable,
|
| 900 | + .iface_status = airoc_iface_status, |
816 | 901 | #if defined(CONFIG_NET_STATISTICS_WIFI)
|
817 | 902 | .get_stats = airoc_mgmt_wifi_stats,
|
818 | 903 | #endif
|
|
0 commit comments