15b9c547cSRui Paulo /* 25b9c547cSRui Paulo * Driver interaction with Linux nl80211/cfg80211 - Capabilities 35b9c547cSRui Paulo * Copyright (c) 2002-2015, Jouni Malinen <j@w1.fi> 45b9c547cSRui Paulo * Copyright (c) 2007, Johannes Berg <johannes@sipsolutions.net> 55b9c547cSRui Paulo * Copyright (c) 2009-2010, Atheros Communications 65b9c547cSRui Paulo * 75b9c547cSRui Paulo * This software may be distributed under the terms of the BSD license. 85b9c547cSRui Paulo * See README for more details. 95b9c547cSRui Paulo */ 105b9c547cSRui Paulo 115b9c547cSRui Paulo #include "includes.h" 125b9c547cSRui Paulo #include <netlink/genl/genl.h> 135b9c547cSRui Paulo 145b9c547cSRui Paulo #include "utils/common.h" 155b9c547cSRui Paulo #include "common/ieee802_11_common.h" 16*85732ac8SCy Schubert #include "common/wpa_common.h" 175b9c547cSRui Paulo #include "common/qca-vendor.h" 185b9c547cSRui Paulo #include "common/qca-vendor-attr.h" 195b9c547cSRui Paulo #include "driver_nl80211.h" 205b9c547cSRui Paulo 215b9c547cSRui Paulo 225b9c547cSRui Paulo static int protocol_feature_handler(struct nl_msg *msg, void *arg) 235b9c547cSRui Paulo { 245b9c547cSRui Paulo u32 *feat = arg; 255b9c547cSRui Paulo struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; 265b9c547cSRui Paulo struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 275b9c547cSRui Paulo 285b9c547cSRui Paulo nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 295b9c547cSRui Paulo genlmsg_attrlen(gnlh, 0), NULL); 305b9c547cSRui Paulo 315b9c547cSRui Paulo if (tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]) 325b9c547cSRui Paulo *feat = nla_get_u32(tb_msg[NL80211_ATTR_PROTOCOL_FEATURES]); 335b9c547cSRui Paulo 345b9c547cSRui Paulo return NL_SKIP; 355b9c547cSRui Paulo } 365b9c547cSRui Paulo 375b9c547cSRui Paulo 385b9c547cSRui Paulo static u32 get_nl80211_protocol_features(struct wpa_driver_nl80211_data *drv) 395b9c547cSRui Paulo { 405b9c547cSRui Paulo u32 feat = 0; 415b9c547cSRui Paulo struct nl_msg *msg; 425b9c547cSRui Paulo 435b9c547cSRui Paulo msg = nlmsg_alloc(); 445b9c547cSRui Paulo if (!msg) 455b9c547cSRui Paulo return 0; 465b9c547cSRui Paulo 475b9c547cSRui Paulo if (!nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_PROTOCOL_FEATURES)) { 485b9c547cSRui Paulo nlmsg_free(msg); 495b9c547cSRui Paulo return 0; 505b9c547cSRui Paulo } 515b9c547cSRui Paulo 525b9c547cSRui Paulo if (send_and_recv_msgs(drv, msg, protocol_feature_handler, &feat) == 0) 535b9c547cSRui Paulo return feat; 545b9c547cSRui Paulo 555b9c547cSRui Paulo return 0; 565b9c547cSRui Paulo } 575b9c547cSRui Paulo 585b9c547cSRui Paulo 595b9c547cSRui Paulo struct wiphy_info_data { 605b9c547cSRui Paulo struct wpa_driver_nl80211_data *drv; 615b9c547cSRui Paulo struct wpa_driver_capa *capa; 625b9c547cSRui Paulo 635b9c547cSRui Paulo unsigned int num_multichan_concurrent; 645b9c547cSRui Paulo 655b9c547cSRui Paulo unsigned int error:1; 665b9c547cSRui Paulo unsigned int device_ap_sme:1; 675b9c547cSRui Paulo unsigned int poll_command_supported:1; 685b9c547cSRui Paulo unsigned int data_tx_status:1; 695b9c547cSRui Paulo unsigned int auth_supported:1; 705b9c547cSRui Paulo unsigned int connect_supported:1; 715b9c547cSRui Paulo unsigned int p2p_go_supported:1; 725b9c547cSRui Paulo unsigned int p2p_client_supported:1; 735b9c547cSRui Paulo unsigned int p2p_go_ctwindow_supported:1; 745b9c547cSRui Paulo unsigned int p2p_concurrent:1; 755b9c547cSRui Paulo unsigned int channel_switch_supported:1; 765b9c547cSRui Paulo unsigned int set_qos_map_supported:1; 775b9c547cSRui Paulo unsigned int have_low_prio_scan:1; 785b9c547cSRui Paulo unsigned int wmm_ac_supported:1; 795b9c547cSRui Paulo unsigned int mac_addr_rand_scan_supported:1; 805b9c547cSRui Paulo unsigned int mac_addr_rand_sched_scan_supported:1; 815b9c547cSRui Paulo }; 825b9c547cSRui Paulo 835b9c547cSRui Paulo 845b9c547cSRui Paulo static unsigned int probe_resp_offload_support(int supp_protocols) 855b9c547cSRui Paulo { 865b9c547cSRui Paulo unsigned int prot = 0; 875b9c547cSRui Paulo 885b9c547cSRui Paulo if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS) 895b9c547cSRui Paulo prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS; 905b9c547cSRui Paulo if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2) 915b9c547cSRui Paulo prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2; 925b9c547cSRui Paulo if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P) 935b9c547cSRui Paulo prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P; 945b9c547cSRui Paulo if (supp_protocols & NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U) 955b9c547cSRui Paulo prot |= WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING; 965b9c547cSRui Paulo 975b9c547cSRui Paulo return prot; 985b9c547cSRui Paulo } 995b9c547cSRui Paulo 1005b9c547cSRui Paulo 1015b9c547cSRui Paulo static void wiphy_info_supported_iftypes(struct wiphy_info_data *info, 1025b9c547cSRui Paulo struct nlattr *tb) 1035b9c547cSRui Paulo { 1045b9c547cSRui Paulo struct nlattr *nl_mode; 1055b9c547cSRui Paulo int i; 1065b9c547cSRui Paulo 1075b9c547cSRui Paulo if (tb == NULL) 1085b9c547cSRui Paulo return; 1095b9c547cSRui Paulo 1105b9c547cSRui Paulo nla_for_each_nested(nl_mode, tb, i) { 1115b9c547cSRui Paulo switch (nla_type(nl_mode)) { 1125b9c547cSRui Paulo case NL80211_IFTYPE_AP: 1135b9c547cSRui Paulo info->capa->flags |= WPA_DRIVER_FLAGS_AP; 1145b9c547cSRui Paulo break; 1155b9c547cSRui Paulo case NL80211_IFTYPE_MESH_POINT: 1165b9c547cSRui Paulo info->capa->flags |= WPA_DRIVER_FLAGS_MESH; 1175b9c547cSRui Paulo break; 1185b9c547cSRui Paulo case NL80211_IFTYPE_ADHOC: 1195b9c547cSRui Paulo info->capa->flags |= WPA_DRIVER_FLAGS_IBSS; 1205b9c547cSRui Paulo break; 1215b9c547cSRui Paulo case NL80211_IFTYPE_P2P_DEVICE: 1225b9c547cSRui Paulo info->capa->flags |= 1235b9c547cSRui Paulo WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE; 1245b9c547cSRui Paulo break; 1255b9c547cSRui Paulo case NL80211_IFTYPE_P2P_GO: 1265b9c547cSRui Paulo info->p2p_go_supported = 1; 1275b9c547cSRui Paulo break; 1285b9c547cSRui Paulo case NL80211_IFTYPE_P2P_CLIENT: 1295b9c547cSRui Paulo info->p2p_client_supported = 1; 1305b9c547cSRui Paulo break; 1315b9c547cSRui Paulo } 1325b9c547cSRui Paulo } 1335b9c547cSRui Paulo } 1345b9c547cSRui Paulo 1355b9c547cSRui Paulo 1365b9c547cSRui Paulo static int wiphy_info_iface_comb_process(struct wiphy_info_data *info, 1375b9c547cSRui Paulo struct nlattr *nl_combi) 1385b9c547cSRui Paulo { 1395b9c547cSRui Paulo struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB]; 1405b9c547cSRui Paulo struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT]; 1415b9c547cSRui Paulo struct nlattr *nl_limit, *nl_mode; 1425b9c547cSRui Paulo int err, rem_limit, rem_mode; 1435b9c547cSRui Paulo int combination_has_p2p = 0, combination_has_mgd = 0; 1445b9c547cSRui Paulo static struct nla_policy 1455b9c547cSRui Paulo iface_combination_policy[NUM_NL80211_IFACE_COMB] = { 1465b9c547cSRui Paulo [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED }, 1475b9c547cSRui Paulo [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 }, 1485b9c547cSRui Paulo [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG }, 1495b9c547cSRui Paulo [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 }, 1505b9c547cSRui Paulo [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 }, 1515b9c547cSRui Paulo }, 1525b9c547cSRui Paulo iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = { 1535b9c547cSRui Paulo [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED }, 1545b9c547cSRui Paulo [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 }, 1555b9c547cSRui Paulo }; 1565b9c547cSRui Paulo 1575b9c547cSRui Paulo err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB, 1585b9c547cSRui Paulo nl_combi, iface_combination_policy); 1595b9c547cSRui Paulo if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] || 1605b9c547cSRui Paulo !tb_comb[NL80211_IFACE_COMB_MAXNUM] || 1615b9c547cSRui Paulo !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) 1625b9c547cSRui Paulo return 0; /* broken combination */ 1635b9c547cSRui Paulo 1645b9c547cSRui Paulo if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) 1655b9c547cSRui Paulo info->capa->flags |= WPA_DRIVER_FLAGS_RADAR; 1665b9c547cSRui Paulo 1675b9c547cSRui Paulo nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], 1685b9c547cSRui Paulo rem_limit) { 1695b9c547cSRui Paulo err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT, 1705b9c547cSRui Paulo nl_limit, iface_limit_policy); 1715b9c547cSRui Paulo if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) 1725b9c547cSRui Paulo return 0; /* broken combination */ 1735b9c547cSRui Paulo 1745b9c547cSRui Paulo nla_for_each_nested(nl_mode, 1755b9c547cSRui Paulo tb_limit[NL80211_IFACE_LIMIT_TYPES], 1765b9c547cSRui Paulo rem_mode) { 1775b9c547cSRui Paulo int ift = nla_type(nl_mode); 1785b9c547cSRui Paulo if (ift == NL80211_IFTYPE_P2P_GO || 1795b9c547cSRui Paulo ift == NL80211_IFTYPE_P2P_CLIENT) 1805b9c547cSRui Paulo combination_has_p2p = 1; 1815b9c547cSRui Paulo if (ift == NL80211_IFTYPE_STATION) 1825b9c547cSRui Paulo combination_has_mgd = 1; 1835b9c547cSRui Paulo } 1845b9c547cSRui Paulo if (combination_has_p2p && combination_has_mgd) 1855b9c547cSRui Paulo break; 1865b9c547cSRui Paulo } 1875b9c547cSRui Paulo 1885b9c547cSRui Paulo if (combination_has_p2p && combination_has_mgd) { 1895b9c547cSRui Paulo unsigned int num_channels = 1905b9c547cSRui Paulo nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]); 1915b9c547cSRui Paulo 1925b9c547cSRui Paulo info->p2p_concurrent = 1; 1935b9c547cSRui Paulo if (info->num_multichan_concurrent < num_channels) 1945b9c547cSRui Paulo info->num_multichan_concurrent = num_channels; 1955b9c547cSRui Paulo } 1965b9c547cSRui Paulo 1975b9c547cSRui Paulo return 0; 1985b9c547cSRui Paulo } 1995b9c547cSRui Paulo 2005b9c547cSRui Paulo 2015b9c547cSRui Paulo static void wiphy_info_iface_comb(struct wiphy_info_data *info, 2025b9c547cSRui Paulo struct nlattr *tb) 2035b9c547cSRui Paulo { 2045b9c547cSRui Paulo struct nlattr *nl_combi; 2055b9c547cSRui Paulo int rem_combi; 2065b9c547cSRui Paulo 2075b9c547cSRui Paulo if (tb == NULL) 2085b9c547cSRui Paulo return; 2095b9c547cSRui Paulo 2105b9c547cSRui Paulo nla_for_each_nested(nl_combi, tb, rem_combi) { 2115b9c547cSRui Paulo if (wiphy_info_iface_comb_process(info, nl_combi) > 0) 2125b9c547cSRui Paulo break; 2135b9c547cSRui Paulo } 2145b9c547cSRui Paulo } 2155b9c547cSRui Paulo 2165b9c547cSRui Paulo 2175b9c547cSRui Paulo static void wiphy_info_supp_cmds(struct wiphy_info_data *info, 2185b9c547cSRui Paulo struct nlattr *tb) 2195b9c547cSRui Paulo { 2205b9c547cSRui Paulo struct nlattr *nl_cmd; 2215b9c547cSRui Paulo int i; 2225b9c547cSRui Paulo 2235b9c547cSRui Paulo if (tb == NULL) 2245b9c547cSRui Paulo return; 2255b9c547cSRui Paulo 2265b9c547cSRui Paulo nla_for_each_nested(nl_cmd, tb, i) { 2275b9c547cSRui Paulo switch (nla_get_u32(nl_cmd)) { 2285b9c547cSRui Paulo case NL80211_CMD_AUTHENTICATE: 2295b9c547cSRui Paulo info->auth_supported = 1; 2305b9c547cSRui Paulo break; 2315b9c547cSRui Paulo case NL80211_CMD_CONNECT: 2325b9c547cSRui Paulo info->connect_supported = 1; 2335b9c547cSRui Paulo break; 2345b9c547cSRui Paulo case NL80211_CMD_START_SCHED_SCAN: 2355b9c547cSRui Paulo info->capa->sched_scan_supported = 1; 2365b9c547cSRui Paulo break; 2375b9c547cSRui Paulo case NL80211_CMD_PROBE_CLIENT: 2385b9c547cSRui Paulo info->poll_command_supported = 1; 2395b9c547cSRui Paulo break; 2405b9c547cSRui Paulo case NL80211_CMD_CHANNEL_SWITCH: 2415b9c547cSRui Paulo info->channel_switch_supported = 1; 2425b9c547cSRui Paulo break; 2435b9c547cSRui Paulo case NL80211_CMD_SET_QOS_MAP: 2445b9c547cSRui Paulo info->set_qos_map_supported = 1; 2455b9c547cSRui Paulo break; 2465b9c547cSRui Paulo } 2475b9c547cSRui Paulo } 2485b9c547cSRui Paulo } 2495b9c547cSRui Paulo 2505b9c547cSRui Paulo 2515b9c547cSRui Paulo static void wiphy_info_cipher_suites(struct wiphy_info_data *info, 2525b9c547cSRui Paulo struct nlattr *tb) 2535b9c547cSRui Paulo { 2545b9c547cSRui Paulo int i, num; 2555b9c547cSRui Paulo u32 *ciphers; 2565b9c547cSRui Paulo 2575b9c547cSRui Paulo if (tb == NULL) 2585b9c547cSRui Paulo return; 2595b9c547cSRui Paulo 2605b9c547cSRui Paulo num = nla_len(tb) / sizeof(u32); 2615b9c547cSRui Paulo ciphers = nla_data(tb); 2625b9c547cSRui Paulo for (i = 0; i < num; i++) { 2635b9c547cSRui Paulo u32 c = ciphers[i]; 2645b9c547cSRui Paulo 2655b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Supported cipher %02x-%02x-%02x:%d", 2665b9c547cSRui Paulo c >> 24, (c >> 16) & 0xff, 2675b9c547cSRui Paulo (c >> 8) & 0xff, c & 0xff); 2685b9c547cSRui Paulo switch (c) { 269*85732ac8SCy Schubert case RSN_CIPHER_SUITE_CCMP_256: 2705b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_CCMP_256; 2715b9c547cSRui Paulo break; 272*85732ac8SCy Schubert case RSN_CIPHER_SUITE_GCMP_256: 2735b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_GCMP_256; 2745b9c547cSRui Paulo break; 275*85732ac8SCy Schubert case RSN_CIPHER_SUITE_CCMP: 2765b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_CCMP; 2775b9c547cSRui Paulo break; 278*85732ac8SCy Schubert case RSN_CIPHER_SUITE_GCMP: 2795b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_GCMP; 2805b9c547cSRui Paulo break; 281*85732ac8SCy Schubert case RSN_CIPHER_SUITE_TKIP: 2825b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_TKIP; 2835b9c547cSRui Paulo break; 284*85732ac8SCy Schubert case RSN_CIPHER_SUITE_WEP104: 2855b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_WEP104; 2865b9c547cSRui Paulo break; 287*85732ac8SCy Schubert case RSN_CIPHER_SUITE_WEP40: 2885b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_WEP40; 2895b9c547cSRui Paulo break; 290*85732ac8SCy Schubert case RSN_CIPHER_SUITE_AES_128_CMAC: 2915b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP; 2925b9c547cSRui Paulo break; 293*85732ac8SCy Schubert case RSN_CIPHER_SUITE_BIP_GMAC_128: 2945b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP_GMAC_128; 2955b9c547cSRui Paulo break; 296*85732ac8SCy Schubert case RSN_CIPHER_SUITE_BIP_GMAC_256: 2975b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP_GMAC_256; 2985b9c547cSRui Paulo break; 299*85732ac8SCy Schubert case RSN_CIPHER_SUITE_BIP_CMAC_256: 3005b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_BIP_CMAC_256; 3015b9c547cSRui Paulo break; 302*85732ac8SCy Schubert case RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED: 3035b9c547cSRui Paulo info->capa->enc |= WPA_DRIVER_CAPA_ENC_GTK_NOT_USED; 3045b9c547cSRui Paulo break; 3055b9c547cSRui Paulo } 3065b9c547cSRui Paulo } 3075b9c547cSRui Paulo } 3085b9c547cSRui Paulo 3095b9c547cSRui Paulo 3105b9c547cSRui Paulo static void wiphy_info_max_roc(struct wpa_driver_capa *capa, 3115b9c547cSRui Paulo struct nlattr *tb) 3125b9c547cSRui Paulo { 3135b9c547cSRui Paulo if (tb) 3145b9c547cSRui Paulo capa->max_remain_on_chan = nla_get_u32(tb); 3155b9c547cSRui Paulo } 3165b9c547cSRui Paulo 3175b9c547cSRui Paulo 3185b9c547cSRui Paulo static void wiphy_info_tdls(struct wpa_driver_capa *capa, struct nlattr *tdls, 3195b9c547cSRui Paulo struct nlattr *ext_setup) 3205b9c547cSRui Paulo { 3215b9c547cSRui Paulo if (tdls == NULL) 3225b9c547cSRui Paulo return; 3235b9c547cSRui Paulo 3245b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: TDLS supported"); 3255b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_TDLS_SUPPORT; 3265b9c547cSRui Paulo 3275b9c547cSRui Paulo if (ext_setup) { 3285b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: TDLS external setup"); 3295b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP; 3305b9c547cSRui Paulo } 3315b9c547cSRui Paulo } 3325b9c547cSRui Paulo 3335b9c547cSRui Paulo 334325151a3SRui Paulo static int ext_feature_isset(const u8 *ext_features, int ext_features_len, 335325151a3SRui Paulo enum nl80211_ext_feature_index ftidx) 336325151a3SRui Paulo { 337325151a3SRui Paulo u8 ft_byte; 338325151a3SRui Paulo 339325151a3SRui Paulo if ((int) ftidx / 8 >= ext_features_len) 340325151a3SRui Paulo return 0; 341325151a3SRui Paulo 342325151a3SRui Paulo ft_byte = ext_features[ftidx / 8]; 343325151a3SRui Paulo return (ft_byte & BIT(ftidx % 8)) != 0; 344325151a3SRui Paulo } 345325151a3SRui Paulo 346325151a3SRui Paulo 347325151a3SRui Paulo static void wiphy_info_ext_feature_flags(struct wiphy_info_data *info, 348325151a3SRui Paulo struct nlattr *tb) 349325151a3SRui Paulo { 350325151a3SRui Paulo struct wpa_driver_capa *capa = info->capa; 351780fb4a2SCy Schubert u8 *ext_features; 352780fb4a2SCy Schubert int len; 353325151a3SRui Paulo 354325151a3SRui Paulo if (tb == NULL) 355325151a3SRui Paulo return; 356325151a3SRui Paulo 357780fb4a2SCy Schubert ext_features = nla_data(tb); 358780fb4a2SCy Schubert len = nla_len(tb); 359780fb4a2SCy Schubert 360780fb4a2SCy Schubert if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_VHT_IBSS)) 361325151a3SRui Paulo capa->flags |= WPA_DRIVER_FLAGS_VHT_IBSS; 362780fb4a2SCy Schubert 363780fb4a2SCy Schubert if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_RRM)) 364780fb4a2SCy Schubert capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_RRM; 365*85732ac8SCy Schubert 366*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, NL80211_EXT_FEATURE_FILS_STA)) 367*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_SUPPORT_FILS; 368*85732ac8SCy Schubert 369*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 370*85732ac8SCy Schubert NL80211_EXT_FEATURE_BEACON_RATE_LEGACY)) 371*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_LEGACY; 372*85732ac8SCy Schubert 373*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 374*85732ac8SCy Schubert NL80211_EXT_FEATURE_BEACON_RATE_HT)) 375*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_HT; 376*85732ac8SCy Schubert 377*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 378*85732ac8SCy Schubert NL80211_EXT_FEATURE_BEACON_RATE_VHT)) 379*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_BEACON_RATE_VHT; 380*85732ac8SCy Schubert 381*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 382*85732ac8SCy Schubert NL80211_EXT_FEATURE_SET_SCAN_DWELL)) 383*85732ac8SCy Schubert capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_SET_SCAN_DWELL; 384*85732ac8SCy Schubert 385*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 386*85732ac8SCy Schubert NL80211_EXT_FEATURE_SCAN_START_TIME) && 387*85732ac8SCy Schubert ext_feature_isset(ext_features, len, 388*85732ac8SCy Schubert NL80211_EXT_FEATURE_BSS_PARENT_TSF) && 389*85732ac8SCy Schubert ext_feature_isset(ext_features, len, 390*85732ac8SCy Schubert NL80211_EXT_FEATURE_SET_SCAN_DWELL)) 391*85732ac8SCy Schubert capa->rrm_flags |= WPA_DRIVER_FLAGS_SUPPORT_BEACON_REPORT; 392*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 393*85732ac8SCy Schubert NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA)) 394*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_MGMT_TX_RANDOM_TA; 395*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 396*85732ac8SCy Schubert NL80211_EXT_FEATURE_MGMT_TX_RANDOM_TA_CONNECTED)) 397*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_MGMT_TX_RANDOM_TA_CONNECTED; 398*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 399*85732ac8SCy Schubert NL80211_EXT_FEATURE_SCHED_SCAN_RELATIVE_RSSI)) 400*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_SCHED_SCAN_RELATIVE_RSSI; 401*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 402*85732ac8SCy Schubert NL80211_EXT_FEATURE_FILS_SK_OFFLOAD)) 403*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_FILS_SK_OFFLOAD; 404*85732ac8SCy Schubert 405*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 406*85732ac8SCy Schubert NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_PSK) && 407*85732ac8SCy Schubert ext_feature_isset(ext_features, len, 408*85732ac8SCy Schubert NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X)) 409*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_4WAY_HANDSHAKE; 410*85732ac8SCy Schubert 411*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 412*85732ac8SCy Schubert NL80211_EXT_FEATURE_MFP_OPTIONAL)) 413*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_MFP_OPTIONAL; 414*85732ac8SCy Schubert 415*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 416*85732ac8SCy Schubert NL80211_EXT_FEATURE_DFS_OFFLOAD)) 417*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_DFS_OFFLOAD; 418*85732ac8SCy Schubert 419*85732ac8SCy Schubert #ifdef CONFIG_MBO 420*85732ac8SCy Schubert if (ext_feature_isset(ext_features, len, 421*85732ac8SCy Schubert NL80211_EXT_FEATURE_FILS_MAX_CHANNEL_TIME) && 422*85732ac8SCy Schubert ext_feature_isset(ext_features, len, 423*85732ac8SCy Schubert NL80211_EXT_FEATURE_ACCEPT_BCAST_PROBE_RESP) && 424*85732ac8SCy Schubert ext_feature_isset(ext_features, len, 425*85732ac8SCy Schubert NL80211_EXT_FEATURE_OCE_PROBE_REQ_HIGH_TX_RATE) && 426*85732ac8SCy Schubert ext_feature_isset( 427*85732ac8SCy Schubert ext_features, len, 428*85732ac8SCy Schubert NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION)) 429*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_OCE_STA; 430*85732ac8SCy Schubert #endif /* CONFIG_MBO */ 431325151a3SRui Paulo } 432325151a3SRui Paulo 433325151a3SRui Paulo 4345b9c547cSRui Paulo static void wiphy_info_feature_flags(struct wiphy_info_data *info, 4355b9c547cSRui Paulo struct nlattr *tb) 4365b9c547cSRui Paulo { 4375b9c547cSRui Paulo u32 flags; 4385b9c547cSRui Paulo struct wpa_driver_capa *capa = info->capa; 4395b9c547cSRui Paulo 4405b9c547cSRui Paulo if (tb == NULL) 4415b9c547cSRui Paulo return; 4425b9c547cSRui Paulo 4435b9c547cSRui Paulo flags = nla_get_u32(tb); 4445b9c547cSRui Paulo 4455b9c547cSRui Paulo if (flags & NL80211_FEATURE_SK_TX_STATUS) 4465b9c547cSRui Paulo info->data_tx_status = 1; 4475b9c547cSRui Paulo 4485b9c547cSRui Paulo if (flags & NL80211_FEATURE_INACTIVITY_TIMER) 4495b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_INACTIVITY_TIMER; 4505b9c547cSRui Paulo 4515b9c547cSRui Paulo if (flags & NL80211_FEATURE_SAE) 4525b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_SAE; 4535b9c547cSRui Paulo 4545b9c547cSRui Paulo if (flags & NL80211_FEATURE_NEED_OBSS_SCAN) 4555b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_OBSS_SCAN; 4565b9c547cSRui Paulo 4575b9c547cSRui Paulo if (flags & NL80211_FEATURE_AP_MODE_CHAN_WIDTH_CHANGE) 4585b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_HT_2040_COEX; 4595b9c547cSRui Paulo 4605b9c547cSRui Paulo if (flags & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) { 4615b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: TDLS channel switch"); 4625b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_TDLS_CHANNEL_SWITCH; 4635b9c547cSRui Paulo } 4645b9c547cSRui Paulo 4655b9c547cSRui Paulo if (flags & NL80211_FEATURE_P2P_GO_CTWIN) 4665b9c547cSRui Paulo info->p2p_go_ctwindow_supported = 1; 4675b9c547cSRui Paulo 4685b9c547cSRui Paulo if (flags & NL80211_FEATURE_LOW_PRIORITY_SCAN) 4695b9c547cSRui Paulo info->have_low_prio_scan = 1; 4705b9c547cSRui Paulo 4715b9c547cSRui Paulo if (flags & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR) 4725b9c547cSRui Paulo info->mac_addr_rand_scan_supported = 1; 4735b9c547cSRui Paulo 4745b9c547cSRui Paulo if (flags & NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR) 4755b9c547cSRui Paulo info->mac_addr_rand_sched_scan_supported = 1; 4765b9c547cSRui Paulo 4775b9c547cSRui Paulo if (flags & NL80211_FEATURE_STATIC_SMPS) 4785b9c547cSRui Paulo capa->smps_modes |= WPA_DRIVER_SMPS_MODE_STATIC; 4795b9c547cSRui Paulo 4805b9c547cSRui Paulo if (flags & NL80211_FEATURE_DYNAMIC_SMPS) 4815b9c547cSRui Paulo capa->smps_modes |= WPA_DRIVER_SMPS_MODE_DYNAMIC; 4825b9c547cSRui Paulo 4835b9c547cSRui Paulo if (flags & NL80211_FEATURE_SUPPORTS_WMM_ADMISSION) 4845b9c547cSRui Paulo info->wmm_ac_supported = 1; 4855b9c547cSRui Paulo 4865b9c547cSRui Paulo if (flags & NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES) 4875b9c547cSRui Paulo capa->rrm_flags |= WPA_DRIVER_FLAGS_DS_PARAM_SET_IE_IN_PROBES; 4885b9c547cSRui Paulo 4895b9c547cSRui Paulo if (flags & NL80211_FEATURE_WFA_TPC_IE_IN_PROBES) 4905b9c547cSRui Paulo capa->rrm_flags |= WPA_DRIVER_FLAGS_WFA_TPC_IE_IN_PROBES; 4915b9c547cSRui Paulo 4925b9c547cSRui Paulo if (flags & NL80211_FEATURE_QUIET) 4935b9c547cSRui Paulo capa->rrm_flags |= WPA_DRIVER_FLAGS_QUIET; 4945b9c547cSRui Paulo 4955b9c547cSRui Paulo if (flags & NL80211_FEATURE_TX_POWER_INSERTION) 4965b9c547cSRui Paulo capa->rrm_flags |= WPA_DRIVER_FLAGS_TX_POWER_INSERTION; 4975b9c547cSRui Paulo 4985b9c547cSRui Paulo if (flags & NL80211_FEATURE_HT_IBSS) 4995b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_HT_IBSS; 500780fb4a2SCy Schubert 501780fb4a2SCy Schubert if (flags & NL80211_FEATURE_FULL_AP_CLIENT_STATE) 502780fb4a2SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_FULL_AP_CLIENT_STATE; 5035b9c547cSRui Paulo } 5045b9c547cSRui Paulo 5055b9c547cSRui Paulo 5065b9c547cSRui Paulo static void wiphy_info_probe_resp_offload(struct wpa_driver_capa *capa, 5075b9c547cSRui Paulo struct nlattr *tb) 5085b9c547cSRui Paulo { 5095b9c547cSRui Paulo u32 protocols; 5105b9c547cSRui Paulo 5115b9c547cSRui Paulo if (tb == NULL) 5125b9c547cSRui Paulo return; 5135b9c547cSRui Paulo 5145b9c547cSRui Paulo protocols = nla_get_u32(tb); 5155b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Supports Probe Response offload in AP " 5165b9c547cSRui Paulo "mode"); 5175b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD; 5185b9c547cSRui Paulo capa->probe_resp_offloads = probe_resp_offload_support(protocols); 5195b9c547cSRui Paulo } 5205b9c547cSRui Paulo 5215b9c547cSRui Paulo 5225b9c547cSRui Paulo static void wiphy_info_wowlan_triggers(struct wpa_driver_capa *capa, 5235b9c547cSRui Paulo struct nlattr *tb) 5245b9c547cSRui Paulo { 5255b9c547cSRui Paulo struct nlattr *triggers[MAX_NL80211_WOWLAN_TRIG + 1]; 5265b9c547cSRui Paulo 5275b9c547cSRui Paulo if (tb == NULL) 5285b9c547cSRui Paulo return; 5295b9c547cSRui Paulo 5305b9c547cSRui Paulo if (nla_parse_nested(triggers, MAX_NL80211_WOWLAN_TRIG, 5315b9c547cSRui Paulo tb, NULL)) 5325b9c547cSRui Paulo return; 5335b9c547cSRui Paulo 5345b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_ANY]) 5355b9c547cSRui Paulo capa->wowlan_triggers.any = 1; 5365b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_DISCONNECT]) 5375b9c547cSRui Paulo capa->wowlan_triggers.disconnect = 1; 5385b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_MAGIC_PKT]) 5395b9c547cSRui Paulo capa->wowlan_triggers.magic_pkt = 1; 5405b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE]) 5415b9c547cSRui Paulo capa->wowlan_triggers.gtk_rekey_failure = 1; 5425b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST]) 5435b9c547cSRui Paulo capa->wowlan_triggers.eap_identity_req = 1; 5445b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE]) 5455b9c547cSRui Paulo capa->wowlan_triggers.four_way_handshake = 1; 5465b9c547cSRui Paulo if (triggers[NL80211_WOWLAN_TRIG_RFKILL_RELEASE]) 5475b9c547cSRui Paulo capa->wowlan_triggers.rfkill_release = 1; 5485b9c547cSRui Paulo } 5495b9c547cSRui Paulo 5505b9c547cSRui Paulo 551780fb4a2SCy Schubert static void wiphy_info_extended_capab(struct wpa_driver_nl80211_data *drv, 552780fb4a2SCy Schubert struct nlattr *tb) 553780fb4a2SCy Schubert { 554780fb4a2SCy Schubert int rem = 0, i; 555780fb4a2SCy Schubert struct nlattr *tb1[NL80211_ATTR_MAX + 1], *attr; 556780fb4a2SCy Schubert 557780fb4a2SCy Schubert if (!tb || drv->num_iface_ext_capa == NL80211_IFTYPE_MAX) 558780fb4a2SCy Schubert return; 559780fb4a2SCy Schubert 560780fb4a2SCy Schubert nla_for_each_nested(attr, tb, rem) { 561780fb4a2SCy Schubert unsigned int len; 562780fb4a2SCy Schubert struct drv_nl80211_ext_capa *capa; 563780fb4a2SCy Schubert 564780fb4a2SCy Schubert nla_parse(tb1, NL80211_ATTR_MAX, nla_data(attr), 565780fb4a2SCy Schubert nla_len(attr), NULL); 566780fb4a2SCy Schubert 567780fb4a2SCy Schubert if (!tb1[NL80211_ATTR_IFTYPE] || 568780fb4a2SCy Schubert !tb1[NL80211_ATTR_EXT_CAPA] || 569780fb4a2SCy Schubert !tb1[NL80211_ATTR_EXT_CAPA_MASK]) 570780fb4a2SCy Schubert continue; 571780fb4a2SCy Schubert 572780fb4a2SCy Schubert capa = &drv->iface_ext_capa[drv->num_iface_ext_capa]; 573780fb4a2SCy Schubert capa->iftype = nla_get_u32(tb1[NL80211_ATTR_IFTYPE]); 574780fb4a2SCy Schubert wpa_printf(MSG_DEBUG, 575780fb4a2SCy Schubert "nl80211: Driver-advertised extended capabilities for interface type %s", 576780fb4a2SCy Schubert nl80211_iftype_str(capa->iftype)); 577780fb4a2SCy Schubert 578780fb4a2SCy Schubert len = nla_len(tb1[NL80211_ATTR_EXT_CAPA]); 579*85732ac8SCy Schubert capa->ext_capa = os_memdup(nla_data(tb1[NL80211_ATTR_EXT_CAPA]), 580*85732ac8SCy Schubert len); 581780fb4a2SCy Schubert if (!capa->ext_capa) 582780fb4a2SCy Schubert goto err; 583780fb4a2SCy Schubert 584780fb4a2SCy Schubert capa->ext_capa_len = len; 585780fb4a2SCy Schubert wpa_hexdump(MSG_DEBUG, "nl80211: Extended capabilities", 586780fb4a2SCy Schubert capa->ext_capa, capa->ext_capa_len); 587780fb4a2SCy Schubert 588780fb4a2SCy Schubert len = nla_len(tb1[NL80211_ATTR_EXT_CAPA_MASK]); 589*85732ac8SCy Schubert capa->ext_capa_mask = 590*85732ac8SCy Schubert os_memdup(nla_data(tb1[NL80211_ATTR_EXT_CAPA_MASK]), 591*85732ac8SCy Schubert len); 592780fb4a2SCy Schubert if (!capa->ext_capa_mask) 593780fb4a2SCy Schubert goto err; 594780fb4a2SCy Schubert 595780fb4a2SCy Schubert wpa_hexdump(MSG_DEBUG, "nl80211: Extended capabilities mask", 596780fb4a2SCy Schubert capa->ext_capa_mask, capa->ext_capa_len); 597780fb4a2SCy Schubert 598780fb4a2SCy Schubert drv->num_iface_ext_capa++; 599780fb4a2SCy Schubert if (drv->num_iface_ext_capa == NL80211_IFTYPE_MAX) 600780fb4a2SCy Schubert break; 601780fb4a2SCy Schubert } 602780fb4a2SCy Schubert 603780fb4a2SCy Schubert return; 604780fb4a2SCy Schubert 605780fb4a2SCy Schubert err: 606780fb4a2SCy Schubert /* Cleanup allocated memory on error */ 607780fb4a2SCy Schubert for (i = 0; i < NL80211_IFTYPE_MAX; i++) { 608780fb4a2SCy Schubert os_free(drv->iface_ext_capa[i].ext_capa); 609780fb4a2SCy Schubert drv->iface_ext_capa[i].ext_capa = NULL; 610780fb4a2SCy Schubert os_free(drv->iface_ext_capa[i].ext_capa_mask); 611780fb4a2SCy Schubert drv->iface_ext_capa[i].ext_capa_mask = NULL; 612780fb4a2SCy Schubert drv->iface_ext_capa[i].ext_capa_len = 0; 613780fb4a2SCy Schubert } 614780fb4a2SCy Schubert drv->num_iface_ext_capa = 0; 615780fb4a2SCy Schubert } 616780fb4a2SCy Schubert 617780fb4a2SCy Schubert 6185b9c547cSRui Paulo static int wiphy_info_handler(struct nl_msg *msg, void *arg) 6195b9c547cSRui Paulo { 6205b9c547cSRui Paulo struct nlattr *tb[NL80211_ATTR_MAX + 1]; 6215b9c547cSRui Paulo struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 6225b9c547cSRui Paulo struct wiphy_info_data *info = arg; 6235b9c547cSRui Paulo struct wpa_driver_capa *capa = info->capa; 6245b9c547cSRui Paulo struct wpa_driver_nl80211_data *drv = info->drv; 6255b9c547cSRui Paulo 6265b9c547cSRui Paulo nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 6275b9c547cSRui Paulo genlmsg_attrlen(gnlh, 0), NULL); 6285b9c547cSRui Paulo 629780fb4a2SCy Schubert if (tb[NL80211_ATTR_WIPHY]) 630780fb4a2SCy Schubert drv->wiphy_idx = nla_get_u32(tb[NL80211_ATTR_WIPHY]); 631780fb4a2SCy Schubert 6325b9c547cSRui Paulo if (tb[NL80211_ATTR_WIPHY_NAME]) 6335b9c547cSRui Paulo os_strlcpy(drv->phyname, 6345b9c547cSRui Paulo nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]), 6355b9c547cSRui Paulo sizeof(drv->phyname)); 6365b9c547cSRui Paulo if (tb[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]) 6375b9c547cSRui Paulo capa->max_scan_ssids = 6385b9c547cSRui Paulo nla_get_u8(tb[NL80211_ATTR_MAX_NUM_SCAN_SSIDS]); 6395b9c547cSRui Paulo 6405b9c547cSRui Paulo if (tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS]) 6415b9c547cSRui Paulo capa->max_sched_scan_ssids = 6425b9c547cSRui Paulo nla_get_u8(tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_SSIDS]); 6435b9c547cSRui Paulo 644780fb4a2SCy Schubert if (tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS] && 645780fb4a2SCy Schubert tb[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL] && 646780fb4a2SCy Schubert tb[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]) { 647780fb4a2SCy Schubert capa->max_sched_scan_plans = 648780fb4a2SCy Schubert nla_get_u32(tb[NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS]); 649780fb4a2SCy Schubert 650780fb4a2SCy Schubert capa->max_sched_scan_plan_interval = 651780fb4a2SCy Schubert nla_get_u32(tb[NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL]); 652780fb4a2SCy Schubert 653780fb4a2SCy Schubert capa->max_sched_scan_plan_iterations = 654780fb4a2SCy Schubert nla_get_u32(tb[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]); 655780fb4a2SCy Schubert } 656780fb4a2SCy Schubert 6575b9c547cSRui Paulo if (tb[NL80211_ATTR_MAX_MATCH_SETS]) 6585b9c547cSRui Paulo capa->max_match_sets = 6595b9c547cSRui Paulo nla_get_u8(tb[NL80211_ATTR_MAX_MATCH_SETS]); 6605b9c547cSRui Paulo 6615b9c547cSRui Paulo if (tb[NL80211_ATTR_MAC_ACL_MAX]) 6625b9c547cSRui Paulo capa->max_acl_mac_addrs = 6635b9c547cSRui Paulo nla_get_u8(tb[NL80211_ATTR_MAC_ACL_MAX]); 6645b9c547cSRui Paulo 6655b9c547cSRui Paulo wiphy_info_supported_iftypes(info, tb[NL80211_ATTR_SUPPORTED_IFTYPES]); 6665b9c547cSRui Paulo wiphy_info_iface_comb(info, tb[NL80211_ATTR_INTERFACE_COMBINATIONS]); 6675b9c547cSRui Paulo wiphy_info_supp_cmds(info, tb[NL80211_ATTR_SUPPORTED_COMMANDS]); 6685b9c547cSRui Paulo wiphy_info_cipher_suites(info, tb[NL80211_ATTR_CIPHER_SUITES]); 6695b9c547cSRui Paulo 6705b9c547cSRui Paulo if (tb[NL80211_ATTR_OFFCHANNEL_TX_OK]) { 6715b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Using driver-based " 6725b9c547cSRui Paulo "off-channel TX"); 6735b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_OFFCHANNEL_TX; 6745b9c547cSRui Paulo } 6755b9c547cSRui Paulo 6765b9c547cSRui Paulo if (tb[NL80211_ATTR_ROAM_SUPPORT]) { 6775b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Using driver-based roaming"); 6785b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_BSS_SELECTION; 6795b9c547cSRui Paulo } 6805b9c547cSRui Paulo 6815b9c547cSRui Paulo wiphy_info_max_roc(capa, 6825b9c547cSRui Paulo tb[NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION]); 6835b9c547cSRui Paulo 6845b9c547cSRui Paulo if (tb[NL80211_ATTR_SUPPORT_AP_UAPSD]) 6855b9c547cSRui Paulo capa->flags |= WPA_DRIVER_FLAGS_AP_UAPSD; 6865b9c547cSRui Paulo 6875b9c547cSRui Paulo wiphy_info_tdls(capa, tb[NL80211_ATTR_TDLS_SUPPORT], 6885b9c547cSRui Paulo tb[NL80211_ATTR_TDLS_EXTERNAL_SETUP]); 6895b9c547cSRui Paulo 6905b9c547cSRui Paulo if (tb[NL80211_ATTR_DEVICE_AP_SME]) 6915b9c547cSRui Paulo info->device_ap_sme = 1; 6925b9c547cSRui Paulo 6935b9c547cSRui Paulo wiphy_info_feature_flags(info, tb[NL80211_ATTR_FEATURE_FLAGS]); 694325151a3SRui Paulo wiphy_info_ext_feature_flags(info, tb[NL80211_ATTR_EXT_FEATURES]); 6955b9c547cSRui Paulo wiphy_info_probe_resp_offload(capa, 6965b9c547cSRui Paulo tb[NL80211_ATTR_PROBE_RESP_OFFLOAD]); 6975b9c547cSRui Paulo 6985b9c547cSRui Paulo if (tb[NL80211_ATTR_EXT_CAPA] && tb[NL80211_ATTR_EXT_CAPA_MASK] && 6995b9c547cSRui Paulo drv->extended_capa == NULL) { 7005b9c547cSRui Paulo drv->extended_capa = 7015b9c547cSRui Paulo os_malloc(nla_len(tb[NL80211_ATTR_EXT_CAPA])); 7025b9c547cSRui Paulo if (drv->extended_capa) { 7035b9c547cSRui Paulo os_memcpy(drv->extended_capa, 7045b9c547cSRui Paulo nla_data(tb[NL80211_ATTR_EXT_CAPA]), 7055b9c547cSRui Paulo nla_len(tb[NL80211_ATTR_EXT_CAPA])); 7065b9c547cSRui Paulo drv->extended_capa_len = 7075b9c547cSRui Paulo nla_len(tb[NL80211_ATTR_EXT_CAPA]); 708780fb4a2SCy Schubert wpa_hexdump(MSG_DEBUG, 709780fb4a2SCy Schubert "nl80211: Driver-advertised extended capabilities (default)", 710780fb4a2SCy Schubert drv->extended_capa, drv->extended_capa_len); 7115b9c547cSRui Paulo } 7125b9c547cSRui Paulo drv->extended_capa_mask = 7135b9c547cSRui Paulo os_malloc(nla_len(tb[NL80211_ATTR_EXT_CAPA_MASK])); 7145b9c547cSRui Paulo if (drv->extended_capa_mask) { 7155b9c547cSRui Paulo os_memcpy(drv->extended_capa_mask, 7165b9c547cSRui Paulo nla_data(tb[NL80211_ATTR_EXT_CAPA_MASK]), 7175b9c547cSRui Paulo nla_len(tb[NL80211_ATTR_EXT_CAPA_MASK])); 718780fb4a2SCy Schubert wpa_hexdump(MSG_DEBUG, 719780fb4a2SCy Schubert "nl80211: Driver-advertised extended capabilities mask (default)", 720780fb4a2SCy Schubert drv->extended_capa_mask, 721780fb4a2SCy Schubert drv->extended_capa_len); 7225b9c547cSRui Paulo } else { 7235b9c547cSRui Paulo os_free(drv->extended_capa); 7245b9c547cSRui Paulo drv->extended_capa = NULL; 7255b9c547cSRui Paulo drv->extended_capa_len = 0; 7265b9c547cSRui Paulo } 7275b9c547cSRui Paulo } 7285b9c547cSRui Paulo 729780fb4a2SCy Schubert wiphy_info_extended_capab(drv, tb[NL80211_ATTR_IFTYPE_EXT_CAPA]); 730780fb4a2SCy Schubert 7315b9c547cSRui Paulo if (tb[NL80211_ATTR_VENDOR_DATA]) { 7325b9c547cSRui Paulo struct nlattr *nl; 7335b9c547cSRui Paulo int rem; 7345b9c547cSRui Paulo 7355b9c547cSRui Paulo nla_for_each_nested(nl, tb[NL80211_ATTR_VENDOR_DATA], rem) { 7365b9c547cSRui Paulo struct nl80211_vendor_cmd_info *vinfo; 7375b9c547cSRui Paulo if (nla_len(nl) != sizeof(*vinfo)) { 7385b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Unexpected vendor data info"); 7395b9c547cSRui Paulo continue; 7405b9c547cSRui Paulo } 7415b9c547cSRui Paulo vinfo = nla_data(nl); 742325151a3SRui Paulo if (vinfo->vendor_id == OUI_QCA) { 7435b9c547cSRui Paulo switch (vinfo->subcmd) { 7445b9c547cSRui Paulo case QCA_NL80211_VENDOR_SUBCMD_TEST: 7455b9c547cSRui Paulo drv->vendor_cmd_test_avail = 1; 7465b9c547cSRui Paulo break; 747780fb4a2SCy Schubert #ifdef CONFIG_DRIVER_NL80211_QCA 7485b9c547cSRui Paulo case QCA_NL80211_VENDOR_SUBCMD_ROAMING: 7495b9c547cSRui Paulo drv->roaming_vendor_cmd_avail = 1; 7505b9c547cSRui Paulo break; 7515b9c547cSRui Paulo case QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY: 7525b9c547cSRui Paulo drv->dfs_vendor_cmd_avail = 1; 7535b9c547cSRui Paulo break; 7545b9c547cSRui Paulo case QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES: 7555b9c547cSRui Paulo drv->get_features_vendor_cmd_avail = 1; 7565b9c547cSRui Paulo break; 757325151a3SRui Paulo case QCA_NL80211_VENDOR_SUBCMD_GET_PREFERRED_FREQ_LIST: 758325151a3SRui Paulo drv->get_pref_freq_list = 1; 7595b9c547cSRui Paulo break; 760325151a3SRui Paulo case QCA_NL80211_VENDOR_SUBCMD_SET_PROBABLE_OPER_CHANNEL: 761325151a3SRui Paulo drv->set_prob_oper_freq = 1; 762325151a3SRui Paulo break; 763325151a3SRui Paulo case QCA_NL80211_VENDOR_SUBCMD_DO_ACS: 764325151a3SRui Paulo drv->capa.flags |= 765325151a3SRui Paulo WPA_DRIVER_FLAGS_ACS_OFFLOAD; 766325151a3SRui Paulo break; 767325151a3SRui Paulo case QCA_NL80211_VENDOR_SUBCMD_SETBAND: 768325151a3SRui Paulo drv->setband_vendor_cmd_avail = 1; 769325151a3SRui Paulo break; 770780fb4a2SCy Schubert case QCA_NL80211_VENDOR_SUBCMD_TRIGGER_SCAN: 771780fb4a2SCy Schubert drv->scan_vendor_cmd_avail = 1; 772780fb4a2SCy Schubert break; 773780fb4a2SCy Schubert case QCA_NL80211_VENDOR_SUBCMD_SET_WIFI_CONFIGURATION: 774780fb4a2SCy Schubert drv->set_wifi_conf_vendor_cmd_avail = 1; 775780fb4a2SCy Schubert break; 776*85732ac8SCy Schubert case QCA_NL80211_VENDOR_SUBCMD_GET_HE_CAPABILITIES: 777*85732ac8SCy Schubert drv->he_capab_vendor_cmd_avail = 1; 778*85732ac8SCy Schubert break; 779*85732ac8SCy Schubert case QCA_NL80211_VENDOR_SUBCMD_FETCH_BSS_TRANSITION_STATUS: 780*85732ac8SCy Schubert drv->fetch_bss_trans_status = 1; 781*85732ac8SCy Schubert break; 782*85732ac8SCy Schubert case QCA_NL80211_VENDOR_SUBCMD_ROAM: 783*85732ac8SCy Schubert drv->roam_vendor_cmd_avail = 1; 784*85732ac8SCy Schubert break; 785780fb4a2SCy Schubert #endif /* CONFIG_DRIVER_NL80211_QCA */ 786325151a3SRui Paulo } 7875b9c547cSRui Paulo } 7885b9c547cSRui Paulo 7895b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Supported vendor command: vendor_id=0x%x subcmd=%u", 7905b9c547cSRui Paulo vinfo->vendor_id, vinfo->subcmd); 7915b9c547cSRui Paulo } 7925b9c547cSRui Paulo } 7935b9c547cSRui Paulo 7945b9c547cSRui Paulo if (tb[NL80211_ATTR_VENDOR_EVENTS]) { 7955b9c547cSRui Paulo struct nlattr *nl; 7965b9c547cSRui Paulo int rem; 7975b9c547cSRui Paulo 7985b9c547cSRui Paulo nla_for_each_nested(nl, tb[NL80211_ATTR_VENDOR_EVENTS], rem) { 7995b9c547cSRui Paulo struct nl80211_vendor_cmd_info *vinfo; 8005b9c547cSRui Paulo if (nla_len(nl) != sizeof(*vinfo)) { 8015b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Unexpected vendor data info"); 8025b9c547cSRui Paulo continue; 8035b9c547cSRui Paulo } 8045b9c547cSRui Paulo vinfo = nla_data(nl); 8055b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Supported vendor event: vendor_id=0x%x subcmd=%u", 8065b9c547cSRui Paulo vinfo->vendor_id, vinfo->subcmd); 8075b9c547cSRui Paulo } 8085b9c547cSRui Paulo } 8095b9c547cSRui Paulo 8105b9c547cSRui Paulo wiphy_info_wowlan_triggers(capa, 8115b9c547cSRui Paulo tb[NL80211_ATTR_WOWLAN_TRIGGERS_SUPPORTED]); 8125b9c547cSRui Paulo 8135b9c547cSRui Paulo if (tb[NL80211_ATTR_MAX_AP_ASSOC_STA]) 8145b9c547cSRui Paulo capa->max_stations = 8155b9c547cSRui Paulo nla_get_u32(tb[NL80211_ATTR_MAX_AP_ASSOC_STA]); 8165b9c547cSRui Paulo 817780fb4a2SCy Schubert if (tb[NL80211_ATTR_MAX_CSA_COUNTERS]) 818780fb4a2SCy Schubert capa->max_csa_counters = 819780fb4a2SCy Schubert nla_get_u8(tb[NL80211_ATTR_MAX_CSA_COUNTERS]); 820780fb4a2SCy Schubert 821*85732ac8SCy Schubert if (tb[NL80211_ATTR_WIPHY_SELF_MANAGED_REG]) 822*85732ac8SCy Schubert capa->flags |= WPA_DRIVER_FLAGS_SELF_MANAGED_REGULATORY; 823*85732ac8SCy Schubert 8245b9c547cSRui Paulo return NL_SKIP; 8255b9c547cSRui Paulo } 8265b9c547cSRui Paulo 8275b9c547cSRui Paulo 8285b9c547cSRui Paulo static int wpa_driver_nl80211_get_info(struct wpa_driver_nl80211_data *drv, 8295b9c547cSRui Paulo struct wiphy_info_data *info) 8305b9c547cSRui Paulo { 8315b9c547cSRui Paulo u32 feat; 8325b9c547cSRui Paulo struct nl_msg *msg; 8335b9c547cSRui Paulo int flags = 0; 8345b9c547cSRui Paulo 8355b9c547cSRui Paulo os_memset(info, 0, sizeof(*info)); 8365b9c547cSRui Paulo info->capa = &drv->capa; 8375b9c547cSRui Paulo info->drv = drv; 8385b9c547cSRui Paulo 8395b9c547cSRui Paulo feat = get_nl80211_protocol_features(drv); 8405b9c547cSRui Paulo if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP) 8415b9c547cSRui Paulo flags = NLM_F_DUMP; 8425b9c547cSRui Paulo msg = nl80211_cmd_msg(drv->first_bss, flags, NL80211_CMD_GET_WIPHY); 8435b9c547cSRui Paulo if (!msg || nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP)) { 8445b9c547cSRui Paulo nlmsg_free(msg); 8455b9c547cSRui Paulo return -1; 8465b9c547cSRui Paulo } 8475b9c547cSRui Paulo 8485b9c547cSRui Paulo if (send_and_recv_msgs(drv, msg, wiphy_info_handler, info)) 8495b9c547cSRui Paulo return -1; 8505b9c547cSRui Paulo 8515b9c547cSRui Paulo if (info->auth_supported) 8525b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_SME; 8535b9c547cSRui Paulo else if (!info->connect_supported) { 8545b9c547cSRui Paulo wpa_printf(MSG_INFO, "nl80211: Driver does not support " 8555b9c547cSRui Paulo "authentication/association or connect commands"); 8565b9c547cSRui Paulo info->error = 1; 8575b9c547cSRui Paulo } 8585b9c547cSRui Paulo 8595b9c547cSRui Paulo if (info->p2p_go_supported && info->p2p_client_supported) 8605b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CAPABLE; 8615b9c547cSRui Paulo if (info->p2p_concurrent) { 8625b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Use separate P2P group " 8635b9c547cSRui Paulo "interface (driver advertised support)"); 8645b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_CONCURRENT; 8655b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_MGMT_AND_NON_P2P; 8665b9c547cSRui Paulo } 8675b9c547cSRui Paulo if (info->num_multichan_concurrent > 1) { 8685b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Enable multi-channel " 8695b9c547cSRui Paulo "concurrent (driver advertised support)"); 8705b9c547cSRui Paulo drv->capa.num_multichan_concurrent = 8715b9c547cSRui Paulo info->num_multichan_concurrent; 8725b9c547cSRui Paulo } 8735b9c547cSRui Paulo if (drv->capa.flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) 8745b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: use P2P_DEVICE support"); 8755b9c547cSRui Paulo 8765b9c547cSRui Paulo /* default to 5000 since early versions of mac80211 don't set it */ 8775b9c547cSRui Paulo if (!drv->capa.max_remain_on_chan) 8785b9c547cSRui Paulo drv->capa.max_remain_on_chan = 5000; 8795b9c547cSRui Paulo 8805b9c547cSRui Paulo drv->capa.wmm_ac_supported = info->wmm_ac_supported; 8815b9c547cSRui Paulo 8825b9c547cSRui Paulo drv->capa.mac_addr_rand_sched_scan_supported = 8835b9c547cSRui Paulo info->mac_addr_rand_sched_scan_supported; 8845b9c547cSRui Paulo drv->capa.mac_addr_rand_scan_supported = 8855b9c547cSRui Paulo info->mac_addr_rand_scan_supported; 8865b9c547cSRui Paulo 887780fb4a2SCy Schubert if (info->channel_switch_supported) { 888780fb4a2SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_AP_CSA; 889780fb4a2SCy Schubert if (!drv->capa.max_csa_counters) 890780fb4a2SCy Schubert drv->capa.max_csa_counters = 1; 891780fb4a2SCy Schubert } 892780fb4a2SCy Schubert 893780fb4a2SCy Schubert if (!drv->capa.max_sched_scan_plans) { 894780fb4a2SCy Schubert drv->capa.max_sched_scan_plans = 1; 895780fb4a2SCy Schubert drv->capa.max_sched_scan_plan_interval = UINT32_MAX; 896780fb4a2SCy Schubert drv->capa.max_sched_scan_plan_iterations = 0; 897780fb4a2SCy Schubert } 898780fb4a2SCy Schubert 8995b9c547cSRui Paulo return 0; 9005b9c547cSRui Paulo } 9015b9c547cSRui Paulo 9025b9c547cSRui Paulo 903780fb4a2SCy Schubert #ifdef CONFIG_DRIVER_NL80211_QCA 904780fb4a2SCy Schubert 9055b9c547cSRui Paulo static int dfs_info_handler(struct nl_msg *msg, void *arg) 9065b9c547cSRui Paulo { 9075b9c547cSRui Paulo struct nlattr *tb[NL80211_ATTR_MAX + 1]; 9085b9c547cSRui Paulo struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 9095b9c547cSRui Paulo int *dfs_capability_ptr = arg; 9105b9c547cSRui Paulo 9115b9c547cSRui Paulo nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 9125b9c547cSRui Paulo genlmsg_attrlen(gnlh, 0), NULL); 9135b9c547cSRui Paulo 9145b9c547cSRui Paulo if (tb[NL80211_ATTR_VENDOR_DATA]) { 9155b9c547cSRui Paulo struct nlattr *nl_vend = tb[NL80211_ATTR_VENDOR_DATA]; 9165b9c547cSRui Paulo struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_MAX + 1]; 9175b9c547cSRui Paulo 9185b9c547cSRui Paulo nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_MAX, 9195b9c547cSRui Paulo nla_data(nl_vend), nla_len(nl_vend), NULL); 9205b9c547cSRui Paulo 9215b9c547cSRui Paulo if (tb_vendor[QCA_WLAN_VENDOR_ATTR_DFS]) { 9225b9c547cSRui Paulo u32 val; 9235b9c547cSRui Paulo val = nla_get_u32(tb_vendor[QCA_WLAN_VENDOR_ATTR_DFS]); 9245b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: DFS offload capability: %u", 9255b9c547cSRui Paulo val); 9265b9c547cSRui Paulo *dfs_capability_ptr = val; 9275b9c547cSRui Paulo } 9285b9c547cSRui Paulo } 9295b9c547cSRui Paulo 9305b9c547cSRui Paulo return NL_SKIP; 9315b9c547cSRui Paulo } 9325b9c547cSRui Paulo 9335b9c547cSRui Paulo 9345b9c547cSRui Paulo static void qca_nl80211_check_dfs_capa(struct wpa_driver_nl80211_data *drv) 9355b9c547cSRui Paulo { 9365b9c547cSRui Paulo struct nl_msg *msg; 9375b9c547cSRui Paulo int dfs_capability = 0; 9385b9c547cSRui Paulo int ret; 9395b9c547cSRui Paulo 9405b9c547cSRui Paulo if (!drv->dfs_vendor_cmd_avail) 9415b9c547cSRui Paulo return; 9425b9c547cSRui Paulo 9435b9c547cSRui Paulo if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || 9445b9c547cSRui Paulo nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) || 9455b9c547cSRui Paulo nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, 9465b9c547cSRui Paulo QCA_NL80211_VENDOR_SUBCMD_DFS_CAPABILITY)) { 9475b9c547cSRui Paulo nlmsg_free(msg); 9485b9c547cSRui Paulo return; 9495b9c547cSRui Paulo } 9505b9c547cSRui Paulo 9515b9c547cSRui Paulo ret = send_and_recv_msgs(drv, msg, dfs_info_handler, &dfs_capability); 9525b9c547cSRui Paulo if (!ret && dfs_capability) 9535b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_DFS_OFFLOAD; 9545b9c547cSRui Paulo } 9555b9c547cSRui Paulo 9565b9c547cSRui Paulo 957*85732ac8SCy Schubert static int qca_nl80211_he_capab_handler(struct nl_msg *msg, void *arg) 958*85732ac8SCy Schubert { 959*85732ac8SCy Schubert struct nlattr *tb[NL80211_ATTR_MAX + 1]; 960*85732ac8SCy Schubert struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 961*85732ac8SCy Schubert struct he_capabilities *he_capab = arg; 962*85732ac8SCy Schubert struct nlattr *nl_vend; 963*85732ac8SCy Schubert struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_MAX + 1]; 964*85732ac8SCy Schubert size_t len; 965*85732ac8SCy Schubert 966*85732ac8SCy Schubert nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 967*85732ac8SCy Schubert genlmsg_attrlen(gnlh, 0), NULL); 968*85732ac8SCy Schubert 969*85732ac8SCy Schubert if (!tb[NL80211_ATTR_VENDOR_DATA]) 970*85732ac8SCy Schubert return NL_SKIP; 971*85732ac8SCy Schubert 972*85732ac8SCy Schubert nl_vend = tb[NL80211_ATTR_VENDOR_DATA]; 973*85732ac8SCy Schubert nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_HE_CAPABILITIES_MAX, 974*85732ac8SCy Schubert nla_data(nl_vend), nla_len(nl_vend), NULL); 975*85732ac8SCy Schubert 976*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_HE_SUPPORTED]) { 977*85732ac8SCy Schubert u8 he_supported; 978*85732ac8SCy Schubert 979*85732ac8SCy Schubert he_supported = nla_get_u8( 980*85732ac8SCy Schubert tb_vendor[QCA_WLAN_VENDOR_ATTR_HE_SUPPORTED]); 981*85732ac8SCy Schubert wpa_printf(MSG_DEBUG, "nl80211: HE capabilities supported: %u", 982*85732ac8SCy Schubert he_supported); 983*85732ac8SCy Schubert he_capab->he_supported = he_supported; 984*85732ac8SCy Schubert if (!he_supported) 985*85732ac8SCy Schubert return NL_SKIP; 986*85732ac8SCy Schubert } 987*85732ac8SCy Schubert 988*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_PHY_CAPAB]) { 989*85732ac8SCy Schubert len = nla_len(tb_vendor[QCA_WLAN_VENDOR_ATTR_PHY_CAPAB]); 990*85732ac8SCy Schubert 991*85732ac8SCy Schubert if (len > sizeof(he_capab->phy_cap)) 992*85732ac8SCy Schubert len = sizeof(he_capab->phy_cap); 993*85732ac8SCy Schubert os_memcpy(he_capab->phy_cap, 994*85732ac8SCy Schubert nla_data(tb_vendor[QCA_WLAN_VENDOR_ATTR_PHY_CAPAB]), 995*85732ac8SCy Schubert len); 996*85732ac8SCy Schubert } 997*85732ac8SCy Schubert 998*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_MAC_CAPAB]) 999*85732ac8SCy Schubert he_capab->mac_cap = 1000*85732ac8SCy Schubert nla_get_u32(tb_vendor[QCA_WLAN_VENDOR_ATTR_MAC_CAPAB]); 1001*85732ac8SCy Schubert 1002*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_HE_MCS]) 1003*85732ac8SCy Schubert he_capab->mcs = 1004*85732ac8SCy Schubert nla_get_u32(tb_vendor[QCA_WLAN_VENDOR_ATTR_HE_MCS]); 1005*85732ac8SCy Schubert 1006*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_NUM_SS]) 1007*85732ac8SCy Schubert he_capab->ppet.numss_m1 = 1008*85732ac8SCy Schubert nla_get_u32(tb_vendor[QCA_WLAN_VENDOR_ATTR_NUM_SS]); 1009*85732ac8SCy Schubert 1010*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_RU_IDX_MASK]) 1011*85732ac8SCy Schubert he_capab->ppet.ru_count = 1012*85732ac8SCy Schubert nla_get_u32(tb_vendor[QCA_WLAN_VENDOR_ATTR_RU_IDX_MASK]); 1013*85732ac8SCy Schubert 1014*85732ac8SCy Schubert if (tb_vendor[QCA_WLAN_VENDOR_ATTR_PPE_THRESHOLD]) { 1015*85732ac8SCy Schubert len = nla_len(tb_vendor[QCA_WLAN_VENDOR_ATTR_PPE_THRESHOLD]); 1016*85732ac8SCy Schubert 1017*85732ac8SCy Schubert if (len > sizeof(he_capab->ppet.ppet16_ppet8_ru3_ru0)) 1018*85732ac8SCy Schubert len = sizeof(he_capab->ppet.ppet16_ppet8_ru3_ru0); 1019*85732ac8SCy Schubert os_memcpy(he_capab->ppet.ppet16_ppet8_ru3_ru0, 1020*85732ac8SCy Schubert nla_data(tb_vendor[QCA_WLAN_VENDOR_ATTR_PPE_THRESHOLD]), 1021*85732ac8SCy Schubert len); 1022*85732ac8SCy Schubert } 1023*85732ac8SCy Schubert 1024*85732ac8SCy Schubert return NL_SKIP; 1025*85732ac8SCy Schubert } 1026*85732ac8SCy Schubert 1027*85732ac8SCy Schubert 1028*85732ac8SCy Schubert static void qca_nl80211_check_he_capab(struct wpa_driver_nl80211_data *drv) 1029*85732ac8SCy Schubert { 1030*85732ac8SCy Schubert struct nl_msg *msg; 1031*85732ac8SCy Schubert int ret; 1032*85732ac8SCy Schubert 1033*85732ac8SCy Schubert if (!drv->he_capab_vendor_cmd_avail) 1034*85732ac8SCy Schubert return; 1035*85732ac8SCy Schubert 1036*85732ac8SCy Schubert if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || 1037*85732ac8SCy Schubert nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) || 1038*85732ac8SCy Schubert nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, 1039*85732ac8SCy Schubert QCA_NL80211_VENDOR_SUBCMD_GET_HE_CAPABILITIES)) { 1040*85732ac8SCy Schubert nlmsg_free(msg); 1041*85732ac8SCy Schubert return; 1042*85732ac8SCy Schubert } 1043*85732ac8SCy Schubert 1044*85732ac8SCy Schubert ret = send_and_recv_msgs(drv, msg, qca_nl80211_he_capab_handler, 1045*85732ac8SCy Schubert &drv->he_capab); 1046*85732ac8SCy Schubert if (!ret && drv->he_capab.he_supported) 1047*85732ac8SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_HE_CAPABILITIES; 1048*85732ac8SCy Schubert } 1049*85732ac8SCy Schubert 1050*85732ac8SCy Schubert 10515b9c547cSRui Paulo struct features_info { 10525b9c547cSRui Paulo u8 *flags; 10535b9c547cSRui Paulo size_t flags_len; 1054325151a3SRui Paulo struct wpa_driver_capa *capa; 10555b9c547cSRui Paulo }; 10565b9c547cSRui Paulo 10575b9c547cSRui Paulo 10585b9c547cSRui Paulo static int features_info_handler(struct nl_msg *msg, void *arg) 10595b9c547cSRui Paulo { 10605b9c547cSRui Paulo struct nlattr *tb[NL80211_ATTR_MAX + 1]; 10615b9c547cSRui Paulo struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 10625b9c547cSRui Paulo struct features_info *info = arg; 10635b9c547cSRui Paulo struct nlattr *nl_vend, *attr; 10645b9c547cSRui Paulo 10655b9c547cSRui Paulo nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 10665b9c547cSRui Paulo genlmsg_attrlen(gnlh, 0), NULL); 10675b9c547cSRui Paulo 10685b9c547cSRui Paulo nl_vend = tb[NL80211_ATTR_VENDOR_DATA]; 10695b9c547cSRui Paulo if (nl_vend) { 10705b9c547cSRui Paulo struct nlattr *tb_vendor[QCA_WLAN_VENDOR_ATTR_MAX + 1]; 10715b9c547cSRui Paulo 10725b9c547cSRui Paulo nla_parse(tb_vendor, QCA_WLAN_VENDOR_ATTR_MAX, 10735b9c547cSRui Paulo nla_data(nl_vend), nla_len(nl_vend), NULL); 10745b9c547cSRui Paulo 10755b9c547cSRui Paulo attr = tb_vendor[QCA_WLAN_VENDOR_ATTR_FEATURE_FLAGS]; 10765b9c547cSRui Paulo if (attr) { 1077780fb4a2SCy Schubert int len = nla_len(attr); 1078780fb4a2SCy Schubert info->flags = os_malloc(len); 1079780fb4a2SCy Schubert if (info->flags != NULL) { 1080780fb4a2SCy Schubert os_memcpy(info->flags, nla_data(attr), len); 1081780fb4a2SCy Schubert info->flags_len = len; 1082780fb4a2SCy Schubert } 10835b9c547cSRui Paulo } 1084325151a3SRui Paulo attr = tb_vendor[QCA_WLAN_VENDOR_ATTR_CONCURRENCY_CAPA]; 1085325151a3SRui Paulo if (attr) 1086325151a3SRui Paulo info->capa->conc_capab = nla_get_u32(attr); 1087325151a3SRui Paulo 1088325151a3SRui Paulo attr = tb_vendor[ 1089325151a3SRui Paulo QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_2_4_BAND]; 1090325151a3SRui Paulo if (attr) 1091325151a3SRui Paulo info->capa->max_conc_chan_2_4 = nla_get_u32(attr); 1092325151a3SRui Paulo 1093325151a3SRui Paulo attr = tb_vendor[ 1094325151a3SRui Paulo QCA_WLAN_VENDOR_ATTR_MAX_CONCURRENT_CHANNELS_5_0_BAND]; 1095325151a3SRui Paulo if (attr) 1096325151a3SRui Paulo info->capa->max_conc_chan_5_0 = nla_get_u32(attr); 10975b9c547cSRui Paulo } 10985b9c547cSRui Paulo 10995b9c547cSRui Paulo return NL_SKIP; 11005b9c547cSRui Paulo } 11015b9c547cSRui Paulo 11025b9c547cSRui Paulo 11035b9c547cSRui Paulo static int check_feature(enum qca_wlan_vendor_features feature, 11045b9c547cSRui Paulo struct features_info *info) 11055b9c547cSRui Paulo { 11065b9c547cSRui Paulo size_t idx = feature / 8; 11075b9c547cSRui Paulo 11085b9c547cSRui Paulo return (idx < info->flags_len) && 11095b9c547cSRui Paulo (info->flags[idx] & BIT(feature % 8)); 11105b9c547cSRui Paulo } 11115b9c547cSRui Paulo 11125b9c547cSRui Paulo 11135b9c547cSRui Paulo static void qca_nl80211_get_features(struct wpa_driver_nl80211_data *drv) 11145b9c547cSRui Paulo { 11155b9c547cSRui Paulo struct nl_msg *msg; 11165b9c547cSRui Paulo struct features_info info; 11175b9c547cSRui Paulo int ret; 11185b9c547cSRui Paulo 11195b9c547cSRui Paulo if (!drv->get_features_vendor_cmd_avail) 11205b9c547cSRui Paulo return; 11215b9c547cSRui Paulo 11225b9c547cSRui Paulo if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || 11235b9c547cSRui Paulo nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_QCA) || 11245b9c547cSRui Paulo nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, 11255b9c547cSRui Paulo QCA_NL80211_VENDOR_SUBCMD_GET_FEATURES)) { 11265b9c547cSRui Paulo nlmsg_free(msg); 11275b9c547cSRui Paulo return; 11285b9c547cSRui Paulo } 11295b9c547cSRui Paulo 11305b9c547cSRui Paulo os_memset(&info, 0, sizeof(info)); 1131325151a3SRui Paulo info.capa = &drv->capa; 11325b9c547cSRui Paulo ret = send_and_recv_msgs(drv, msg, features_info_handler, &info); 11335b9c547cSRui Paulo if (ret || !info.flags) 11345b9c547cSRui Paulo return; 11355b9c547cSRui Paulo 11365b9c547cSRui Paulo if (check_feature(QCA_WLAN_VENDOR_FEATURE_KEY_MGMT_OFFLOAD, &info)) 11375b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD; 1138325151a3SRui Paulo 1139325151a3SRui Paulo if (check_feature(QCA_WLAN_VENDOR_FEATURE_SUPPORT_HW_MODE_ANY, &info)) 1140325151a3SRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_SUPPORT_HW_MODE_ANY; 1141780fb4a2SCy Schubert 1142780fb4a2SCy Schubert if (check_feature(QCA_WLAN_VENDOR_FEATURE_OFFCHANNEL_SIMULTANEOUS, 1143780fb4a2SCy Schubert &info)) 1144780fb4a2SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS; 1145780fb4a2SCy Schubert if (check_feature(QCA_WLAN_VENDOR_FEATURE_P2P_LISTEN_OFFLOAD, &info)) 1146780fb4a2SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_P2P_LISTEN_OFFLOAD; 1147*85732ac8SCy Schubert if (check_feature(QCA_WLAN_VENDOR_FEATURE_OCE_STA, &info)) 1148*85732ac8SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_OCE_STA; 1149*85732ac8SCy Schubert if (check_feature(QCA_WLAN_VENDOR_FEATURE_OCE_AP, &info)) 1150*85732ac8SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_OCE_AP; 1151*85732ac8SCy Schubert if (check_feature(QCA_WLAN_VENDOR_FEATURE_OCE_STA_CFON, &info)) 1152*85732ac8SCy Schubert drv->capa.flags |= WPA_DRIVER_FLAGS_OCE_STA_CFON; 1153780fb4a2SCy Schubert os_free(info.flags); 11545b9c547cSRui Paulo } 11555b9c547cSRui Paulo 1156780fb4a2SCy Schubert #endif /* CONFIG_DRIVER_NL80211_QCA */ 1157780fb4a2SCy Schubert 11585b9c547cSRui Paulo 11595b9c547cSRui Paulo int wpa_driver_nl80211_capa(struct wpa_driver_nl80211_data *drv) 11605b9c547cSRui Paulo { 11615b9c547cSRui Paulo struct wiphy_info_data info; 11625b9c547cSRui Paulo if (wpa_driver_nl80211_get_info(drv, &info)) 11635b9c547cSRui Paulo return -1; 11645b9c547cSRui Paulo 11655b9c547cSRui Paulo if (info.error) 11665b9c547cSRui Paulo return -1; 11675b9c547cSRui Paulo 11685b9c547cSRui Paulo drv->has_capability = 1; 11695b9c547cSRui Paulo drv->capa.key_mgmt = WPA_DRIVER_CAPA_KEY_MGMT_WPA | 11705b9c547cSRui Paulo WPA_DRIVER_CAPA_KEY_MGMT_WPA_PSK | 11715b9c547cSRui Paulo WPA_DRIVER_CAPA_KEY_MGMT_WPA2 | 11725b9c547cSRui Paulo WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK | 11735b9c547cSRui Paulo WPA_DRIVER_CAPA_KEY_MGMT_SUITE_B | 1174*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_SUITE_B_192 | 1175*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_OWE | 1176*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_DPP; 1177*85732ac8SCy Schubert 1178*85732ac8SCy Schubert if (drv->capa.flags & WPA_DRIVER_FLAGS_SME) 1179*85732ac8SCy Schubert drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA256 | 1180*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA384 | 1181*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_FT_FILS_SHA256 | 1182*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_FT_FILS_SHA384; 1183*85732ac8SCy Schubert else if (drv->capa.flags & WPA_DRIVER_FLAGS_FILS_SK_OFFLOAD) 1184*85732ac8SCy Schubert drv->capa.key_mgmt |= WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA256 | 1185*85732ac8SCy Schubert WPA_DRIVER_CAPA_KEY_MGMT_FILS_SHA384; 1186*85732ac8SCy Schubert 11875b9c547cSRui Paulo drv->capa.auth = WPA_DRIVER_AUTH_OPEN | 11885b9c547cSRui Paulo WPA_DRIVER_AUTH_SHARED | 11895b9c547cSRui Paulo WPA_DRIVER_AUTH_LEAP; 11905b9c547cSRui Paulo 11915b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_SANE_ERROR_CODES; 11925b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE; 11935b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_EAPOL_TX_STATUS; 11945b9c547cSRui Paulo 11955b9c547cSRui Paulo /* 11965b9c547cSRui Paulo * As all cfg80211 drivers must support cases where the AP interface is 11975b9c547cSRui Paulo * removed without the knowledge of wpa_supplicant/hostapd, e.g., in 11985b9c547cSRui Paulo * case that the user space daemon has crashed, they must be able to 11995b9c547cSRui Paulo * cleanup all stations and key entries in the AP tear down flow. Thus, 12005b9c547cSRui Paulo * this flag can/should always be set for cfg80211 drivers. 12015b9c547cSRui Paulo */ 12025b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_AP_TEARDOWN_SUPPORT; 12035b9c547cSRui Paulo 12045b9c547cSRui Paulo if (!info.device_ap_sme) { 12055b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS; 12065b9c547cSRui Paulo 12075b9c547cSRui Paulo /* 12085b9c547cSRui Paulo * No AP SME is currently assumed to also indicate no AP MLME 12095b9c547cSRui Paulo * in the driver/firmware. 12105b9c547cSRui Paulo */ 12115b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_AP_MLME; 12125b9c547cSRui Paulo } 12135b9c547cSRui Paulo 12145b9c547cSRui Paulo drv->device_ap_sme = info.device_ap_sme; 12155b9c547cSRui Paulo drv->poll_command_supported = info.poll_command_supported; 12165b9c547cSRui Paulo drv->data_tx_status = info.data_tx_status; 12175b9c547cSRui Paulo drv->p2p_go_ctwindow_supported = info.p2p_go_ctwindow_supported; 12185b9c547cSRui Paulo if (info.set_qos_map_supported) 12195b9c547cSRui Paulo drv->capa.flags |= WPA_DRIVER_FLAGS_QOS_MAPPING; 12205b9c547cSRui Paulo drv->have_low_prio_scan = info.have_low_prio_scan; 12215b9c547cSRui Paulo 12225b9c547cSRui Paulo /* 12235b9c547cSRui Paulo * If poll command and tx status are supported, mac80211 is new enough 12245b9c547cSRui Paulo * to have everything we need to not need monitor interfaces. 12255b9c547cSRui Paulo */ 1226780fb4a2SCy Schubert drv->use_monitor = !info.device_ap_sme && 1227780fb4a2SCy Schubert (!info.poll_command_supported || !info.data_tx_status); 12285b9c547cSRui Paulo 12295b9c547cSRui Paulo /* 12305b9c547cSRui Paulo * If we aren't going to use monitor interfaces, but the 12315b9c547cSRui Paulo * driver doesn't support data TX status, we won't get TX 12325b9c547cSRui Paulo * status for EAPOL frames. 12335b9c547cSRui Paulo */ 12345b9c547cSRui Paulo if (!drv->use_monitor && !info.data_tx_status) 12355b9c547cSRui Paulo drv->capa.flags &= ~WPA_DRIVER_FLAGS_EAPOL_TX_STATUS; 12365b9c547cSRui Paulo 1237780fb4a2SCy Schubert #ifdef CONFIG_DRIVER_NL80211_QCA 1238*85732ac8SCy Schubert if (!(info.capa->flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)) 12395b9c547cSRui Paulo qca_nl80211_check_dfs_capa(drv); 12405b9c547cSRui Paulo qca_nl80211_get_features(drv); 1241*85732ac8SCy Schubert qca_nl80211_check_he_capab(drv); 12425b9c547cSRui Paulo 1243780fb4a2SCy Schubert /* 1244780fb4a2SCy Schubert * To enable offchannel simultaneous support in wpa_supplicant, the 1245780fb4a2SCy Schubert * underlying driver needs to support the same along with offchannel TX. 1246780fb4a2SCy Schubert * Offchannel TX support is needed since remain_on_channel and 1247780fb4a2SCy Schubert * action_tx use some common data structures and hence cannot be 1248780fb4a2SCy Schubert * scheduled simultaneously. 1249780fb4a2SCy Schubert */ 1250780fb4a2SCy Schubert if (!(drv->capa.flags & WPA_DRIVER_FLAGS_OFFCHANNEL_TX)) 1251780fb4a2SCy Schubert drv->capa.flags &= ~WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS; 1252780fb4a2SCy Schubert #endif /* CONFIG_DRIVER_NL80211_QCA */ 1253780fb4a2SCy Schubert 12545b9c547cSRui Paulo return 0; 12555b9c547cSRui Paulo } 12565b9c547cSRui Paulo 12575b9c547cSRui Paulo 12585b9c547cSRui Paulo struct phy_info_arg { 12595b9c547cSRui Paulo u16 *num_modes; 12605b9c547cSRui Paulo struct hostapd_hw_modes *modes; 12615b9c547cSRui Paulo int last_mode, last_chan_idx; 1262780fb4a2SCy Schubert int failed; 1263*85732ac8SCy Schubert u8 dfs_domain; 12645b9c547cSRui Paulo }; 12655b9c547cSRui Paulo 12665b9c547cSRui Paulo static void phy_info_ht_capa(struct hostapd_hw_modes *mode, struct nlattr *capa, 12675b9c547cSRui Paulo struct nlattr *ampdu_factor, 12685b9c547cSRui Paulo struct nlattr *ampdu_density, 12695b9c547cSRui Paulo struct nlattr *mcs_set) 12705b9c547cSRui Paulo { 12715b9c547cSRui Paulo if (capa) 12725b9c547cSRui Paulo mode->ht_capab = nla_get_u16(capa); 12735b9c547cSRui Paulo 12745b9c547cSRui Paulo if (ampdu_factor) 12755b9c547cSRui Paulo mode->a_mpdu_params |= nla_get_u8(ampdu_factor) & 0x03; 12765b9c547cSRui Paulo 12775b9c547cSRui Paulo if (ampdu_density) 12785b9c547cSRui Paulo mode->a_mpdu_params |= nla_get_u8(ampdu_density) << 2; 12795b9c547cSRui Paulo 12805b9c547cSRui Paulo if (mcs_set && nla_len(mcs_set) >= 16) { 12815b9c547cSRui Paulo u8 *mcs; 12825b9c547cSRui Paulo mcs = nla_data(mcs_set); 12835b9c547cSRui Paulo os_memcpy(mode->mcs_set, mcs, 16); 12845b9c547cSRui Paulo } 12855b9c547cSRui Paulo } 12865b9c547cSRui Paulo 12875b9c547cSRui Paulo 12885b9c547cSRui Paulo static void phy_info_vht_capa(struct hostapd_hw_modes *mode, 12895b9c547cSRui Paulo struct nlattr *capa, 12905b9c547cSRui Paulo struct nlattr *mcs_set) 12915b9c547cSRui Paulo { 12925b9c547cSRui Paulo if (capa) 12935b9c547cSRui Paulo mode->vht_capab = nla_get_u32(capa); 12945b9c547cSRui Paulo 12955b9c547cSRui Paulo if (mcs_set && nla_len(mcs_set) >= 8) { 12965b9c547cSRui Paulo u8 *mcs; 12975b9c547cSRui Paulo mcs = nla_data(mcs_set); 12985b9c547cSRui Paulo os_memcpy(mode->vht_mcs_set, mcs, 8); 12995b9c547cSRui Paulo } 13005b9c547cSRui Paulo } 13015b9c547cSRui Paulo 13025b9c547cSRui Paulo 13035b9c547cSRui Paulo static void phy_info_freq(struct hostapd_hw_modes *mode, 13045b9c547cSRui Paulo struct hostapd_channel_data *chan, 13055b9c547cSRui Paulo struct nlattr *tb_freq[]) 13065b9c547cSRui Paulo { 13075b9c547cSRui Paulo u8 channel; 13085b9c547cSRui Paulo chan->freq = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_FREQ]); 13095b9c547cSRui Paulo chan->flag = 0; 13105b9c547cSRui Paulo chan->dfs_cac_ms = 0; 13115b9c547cSRui Paulo if (ieee80211_freq_to_chan(chan->freq, &channel) != NUM_HOSTAPD_MODES) 13125b9c547cSRui Paulo chan->chan = channel; 13135b9c547cSRui Paulo 13145b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) 13155b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_DISABLED; 13165b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_NO_IR]) 13175b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_NO_IR; 13185b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) 13195b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_RADAR; 13205b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_INDOOR_ONLY]) 13215b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_INDOOR_ONLY; 13225b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_GO_CONCURRENT]) 13235b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_GO_CONCURRENT; 13245b9c547cSRui Paulo 13255b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]) { 13265b9c547cSRui Paulo enum nl80211_dfs_state state = 13275b9c547cSRui Paulo nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_DFS_STATE]); 13285b9c547cSRui Paulo 13295b9c547cSRui Paulo switch (state) { 13305b9c547cSRui Paulo case NL80211_DFS_USABLE: 13315b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_DFS_USABLE; 13325b9c547cSRui Paulo break; 13335b9c547cSRui Paulo case NL80211_DFS_AVAILABLE: 13345b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_DFS_AVAILABLE; 13355b9c547cSRui Paulo break; 13365b9c547cSRui Paulo case NL80211_DFS_UNAVAILABLE: 13375b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_DFS_UNAVAILABLE; 13385b9c547cSRui Paulo break; 13395b9c547cSRui Paulo } 13405b9c547cSRui Paulo } 13415b9c547cSRui Paulo 13425b9c547cSRui Paulo if (tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]) { 13435b9c547cSRui Paulo chan->dfs_cac_ms = nla_get_u32( 13445b9c547cSRui Paulo tb_freq[NL80211_FREQUENCY_ATTR_DFS_CAC_TIME]); 13455b9c547cSRui Paulo } 13465b9c547cSRui Paulo } 13475b9c547cSRui Paulo 13485b9c547cSRui Paulo 13495b9c547cSRui Paulo static int phy_info_freqs(struct phy_info_arg *phy_info, 13505b9c547cSRui Paulo struct hostapd_hw_modes *mode, struct nlattr *tb) 13515b9c547cSRui Paulo { 13525b9c547cSRui Paulo static struct nla_policy freq_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { 13535b9c547cSRui Paulo [NL80211_FREQUENCY_ATTR_FREQ] = { .type = NLA_U32 }, 13545b9c547cSRui Paulo [NL80211_FREQUENCY_ATTR_DISABLED] = { .type = NLA_FLAG }, 13555b9c547cSRui Paulo [NL80211_FREQUENCY_ATTR_NO_IR] = { .type = NLA_FLAG }, 13565b9c547cSRui Paulo [NL80211_FREQUENCY_ATTR_RADAR] = { .type = NLA_FLAG }, 13575b9c547cSRui Paulo [NL80211_FREQUENCY_ATTR_MAX_TX_POWER] = { .type = NLA_U32 }, 13585b9c547cSRui Paulo [NL80211_FREQUENCY_ATTR_DFS_STATE] = { .type = NLA_U32 }, 13595b9c547cSRui Paulo }; 13605b9c547cSRui Paulo int new_channels = 0; 13615b9c547cSRui Paulo struct hostapd_channel_data *channel; 13625b9c547cSRui Paulo struct nlattr *tb_freq[NL80211_FREQUENCY_ATTR_MAX + 1]; 13635b9c547cSRui Paulo struct nlattr *nl_freq; 13645b9c547cSRui Paulo int rem_freq, idx; 13655b9c547cSRui Paulo 13665b9c547cSRui Paulo if (tb == NULL) 13675b9c547cSRui Paulo return NL_OK; 13685b9c547cSRui Paulo 13695b9c547cSRui Paulo nla_for_each_nested(nl_freq, tb, rem_freq) { 13705b9c547cSRui Paulo nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, 13715b9c547cSRui Paulo nla_data(nl_freq), nla_len(nl_freq), freq_policy); 13725b9c547cSRui Paulo if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ]) 13735b9c547cSRui Paulo continue; 13745b9c547cSRui Paulo new_channels++; 13755b9c547cSRui Paulo } 13765b9c547cSRui Paulo 13775b9c547cSRui Paulo channel = os_realloc_array(mode->channels, 13785b9c547cSRui Paulo mode->num_channels + new_channels, 13795b9c547cSRui Paulo sizeof(struct hostapd_channel_data)); 13805b9c547cSRui Paulo if (!channel) 1381780fb4a2SCy Schubert return NL_STOP; 13825b9c547cSRui Paulo 13835b9c547cSRui Paulo mode->channels = channel; 13845b9c547cSRui Paulo mode->num_channels += new_channels; 13855b9c547cSRui Paulo 13865b9c547cSRui Paulo idx = phy_info->last_chan_idx; 13875b9c547cSRui Paulo 13885b9c547cSRui Paulo nla_for_each_nested(nl_freq, tb, rem_freq) { 13895b9c547cSRui Paulo nla_parse(tb_freq, NL80211_FREQUENCY_ATTR_MAX, 13905b9c547cSRui Paulo nla_data(nl_freq), nla_len(nl_freq), freq_policy); 13915b9c547cSRui Paulo if (!tb_freq[NL80211_FREQUENCY_ATTR_FREQ]) 13925b9c547cSRui Paulo continue; 13935b9c547cSRui Paulo phy_info_freq(mode, &mode->channels[idx], tb_freq); 13945b9c547cSRui Paulo idx++; 13955b9c547cSRui Paulo } 13965b9c547cSRui Paulo phy_info->last_chan_idx = idx; 13975b9c547cSRui Paulo 13985b9c547cSRui Paulo return NL_OK; 13995b9c547cSRui Paulo } 14005b9c547cSRui Paulo 14015b9c547cSRui Paulo 14025b9c547cSRui Paulo static int phy_info_rates(struct hostapd_hw_modes *mode, struct nlattr *tb) 14035b9c547cSRui Paulo { 14045b9c547cSRui Paulo static struct nla_policy rate_policy[NL80211_BITRATE_ATTR_MAX + 1] = { 14055b9c547cSRui Paulo [NL80211_BITRATE_ATTR_RATE] = { .type = NLA_U32 }, 14065b9c547cSRui Paulo [NL80211_BITRATE_ATTR_2GHZ_SHORTPREAMBLE] = 14075b9c547cSRui Paulo { .type = NLA_FLAG }, 14085b9c547cSRui Paulo }; 14095b9c547cSRui Paulo struct nlattr *tb_rate[NL80211_BITRATE_ATTR_MAX + 1]; 14105b9c547cSRui Paulo struct nlattr *nl_rate; 14115b9c547cSRui Paulo int rem_rate, idx; 14125b9c547cSRui Paulo 14135b9c547cSRui Paulo if (tb == NULL) 14145b9c547cSRui Paulo return NL_OK; 14155b9c547cSRui Paulo 14165b9c547cSRui Paulo nla_for_each_nested(nl_rate, tb, rem_rate) { 14175b9c547cSRui Paulo nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, 14185b9c547cSRui Paulo nla_data(nl_rate), nla_len(nl_rate), 14195b9c547cSRui Paulo rate_policy); 14205b9c547cSRui Paulo if (!tb_rate[NL80211_BITRATE_ATTR_RATE]) 14215b9c547cSRui Paulo continue; 14225b9c547cSRui Paulo mode->num_rates++; 14235b9c547cSRui Paulo } 14245b9c547cSRui Paulo 14255b9c547cSRui Paulo mode->rates = os_calloc(mode->num_rates, sizeof(int)); 14265b9c547cSRui Paulo if (!mode->rates) 1427780fb4a2SCy Schubert return NL_STOP; 14285b9c547cSRui Paulo 14295b9c547cSRui Paulo idx = 0; 14305b9c547cSRui Paulo 14315b9c547cSRui Paulo nla_for_each_nested(nl_rate, tb, rem_rate) { 14325b9c547cSRui Paulo nla_parse(tb_rate, NL80211_BITRATE_ATTR_MAX, 14335b9c547cSRui Paulo nla_data(nl_rate), nla_len(nl_rate), 14345b9c547cSRui Paulo rate_policy); 14355b9c547cSRui Paulo if (!tb_rate[NL80211_BITRATE_ATTR_RATE]) 14365b9c547cSRui Paulo continue; 14375b9c547cSRui Paulo mode->rates[idx] = nla_get_u32( 14385b9c547cSRui Paulo tb_rate[NL80211_BITRATE_ATTR_RATE]); 14395b9c547cSRui Paulo idx++; 14405b9c547cSRui Paulo } 14415b9c547cSRui Paulo 14425b9c547cSRui Paulo return NL_OK; 14435b9c547cSRui Paulo } 14445b9c547cSRui Paulo 14455b9c547cSRui Paulo 14465b9c547cSRui Paulo static int phy_info_band(struct phy_info_arg *phy_info, struct nlattr *nl_band) 14475b9c547cSRui Paulo { 14485b9c547cSRui Paulo struct nlattr *tb_band[NL80211_BAND_ATTR_MAX + 1]; 14495b9c547cSRui Paulo struct hostapd_hw_modes *mode; 14505b9c547cSRui Paulo int ret; 14515b9c547cSRui Paulo 14525b9c547cSRui Paulo if (phy_info->last_mode != nl_band->nla_type) { 14535b9c547cSRui Paulo mode = os_realloc_array(phy_info->modes, 14545b9c547cSRui Paulo *phy_info->num_modes + 1, 14555b9c547cSRui Paulo sizeof(*mode)); 1456780fb4a2SCy Schubert if (!mode) { 1457780fb4a2SCy Schubert phy_info->failed = 1; 1458780fb4a2SCy Schubert return NL_STOP; 1459780fb4a2SCy Schubert } 14605b9c547cSRui Paulo phy_info->modes = mode; 14615b9c547cSRui Paulo 14625b9c547cSRui Paulo mode = &phy_info->modes[*(phy_info->num_modes)]; 14635b9c547cSRui Paulo os_memset(mode, 0, sizeof(*mode)); 14645b9c547cSRui Paulo mode->mode = NUM_HOSTAPD_MODES; 14655b9c547cSRui Paulo mode->flags = HOSTAPD_MODE_FLAG_HT_INFO_KNOWN | 14665b9c547cSRui Paulo HOSTAPD_MODE_FLAG_VHT_INFO_KNOWN; 14675b9c547cSRui Paulo 14685b9c547cSRui Paulo /* 14695b9c547cSRui Paulo * Unsupported VHT MCS stream is defined as value 3, so the VHT 14705b9c547cSRui Paulo * MCS RX/TX map must be initialized with 0xffff to mark all 8 14715b9c547cSRui Paulo * possible streams as unsupported. This will be overridden if 14725b9c547cSRui Paulo * driver advertises VHT support. 14735b9c547cSRui Paulo */ 14745b9c547cSRui Paulo mode->vht_mcs_set[0] = 0xff; 14755b9c547cSRui Paulo mode->vht_mcs_set[1] = 0xff; 14765b9c547cSRui Paulo mode->vht_mcs_set[4] = 0xff; 14775b9c547cSRui Paulo mode->vht_mcs_set[5] = 0xff; 14785b9c547cSRui Paulo 14795b9c547cSRui Paulo *(phy_info->num_modes) += 1; 14805b9c547cSRui Paulo phy_info->last_mode = nl_band->nla_type; 14815b9c547cSRui Paulo phy_info->last_chan_idx = 0; 14825b9c547cSRui Paulo } else 14835b9c547cSRui Paulo mode = &phy_info->modes[*(phy_info->num_modes) - 1]; 14845b9c547cSRui Paulo 14855b9c547cSRui Paulo nla_parse(tb_band, NL80211_BAND_ATTR_MAX, nla_data(nl_band), 14865b9c547cSRui Paulo nla_len(nl_band), NULL); 14875b9c547cSRui Paulo 14885b9c547cSRui Paulo phy_info_ht_capa(mode, tb_band[NL80211_BAND_ATTR_HT_CAPA], 14895b9c547cSRui Paulo tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR], 14905b9c547cSRui Paulo tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY], 14915b9c547cSRui Paulo tb_band[NL80211_BAND_ATTR_HT_MCS_SET]); 14925b9c547cSRui Paulo phy_info_vht_capa(mode, tb_band[NL80211_BAND_ATTR_VHT_CAPA], 14935b9c547cSRui Paulo tb_band[NL80211_BAND_ATTR_VHT_MCS_SET]); 14945b9c547cSRui Paulo ret = phy_info_freqs(phy_info, mode, tb_band[NL80211_BAND_ATTR_FREQS]); 1495780fb4a2SCy Schubert if (ret == NL_OK) 14965b9c547cSRui Paulo ret = phy_info_rates(mode, tb_band[NL80211_BAND_ATTR_RATES]); 1497780fb4a2SCy Schubert if (ret != NL_OK) { 1498780fb4a2SCy Schubert phy_info->failed = 1; 14995b9c547cSRui Paulo return ret; 1500780fb4a2SCy Schubert } 15015b9c547cSRui Paulo 15025b9c547cSRui Paulo return NL_OK; 15035b9c547cSRui Paulo } 15045b9c547cSRui Paulo 15055b9c547cSRui Paulo 15065b9c547cSRui Paulo static int phy_info_handler(struct nl_msg *msg, void *arg) 15075b9c547cSRui Paulo { 15085b9c547cSRui Paulo struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; 15095b9c547cSRui Paulo struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 15105b9c547cSRui Paulo struct phy_info_arg *phy_info = arg; 15115b9c547cSRui Paulo struct nlattr *nl_band; 15125b9c547cSRui Paulo int rem_band; 15135b9c547cSRui Paulo 15145b9c547cSRui Paulo nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 15155b9c547cSRui Paulo genlmsg_attrlen(gnlh, 0), NULL); 15165b9c547cSRui Paulo 15175b9c547cSRui Paulo if (!tb_msg[NL80211_ATTR_WIPHY_BANDS]) 15185b9c547cSRui Paulo return NL_SKIP; 15195b9c547cSRui Paulo 15205b9c547cSRui Paulo nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) 15215b9c547cSRui Paulo { 15225b9c547cSRui Paulo int res = phy_info_band(phy_info, nl_band); 15235b9c547cSRui Paulo if (res != NL_OK) 15245b9c547cSRui Paulo return res; 15255b9c547cSRui Paulo } 15265b9c547cSRui Paulo 15275b9c547cSRui Paulo return NL_SKIP; 15285b9c547cSRui Paulo } 15295b9c547cSRui Paulo 15305b9c547cSRui Paulo 15315b9c547cSRui Paulo static struct hostapd_hw_modes * 15325b9c547cSRui Paulo wpa_driver_nl80211_postprocess_modes(struct hostapd_hw_modes *modes, 15335b9c547cSRui Paulo u16 *num_modes) 15345b9c547cSRui Paulo { 15355b9c547cSRui Paulo u16 m; 15365b9c547cSRui Paulo struct hostapd_hw_modes *mode11g = NULL, *nmodes, *mode; 15375b9c547cSRui Paulo int i, mode11g_idx = -1; 15385b9c547cSRui Paulo 15395b9c547cSRui Paulo /* heuristic to set up modes */ 15405b9c547cSRui Paulo for (m = 0; m < *num_modes; m++) { 15415b9c547cSRui Paulo if (!modes[m].num_channels) 15425b9c547cSRui Paulo continue; 15435b9c547cSRui Paulo if (modes[m].channels[0].freq < 4000) { 15445b9c547cSRui Paulo modes[m].mode = HOSTAPD_MODE_IEEE80211B; 15455b9c547cSRui Paulo for (i = 0; i < modes[m].num_rates; i++) { 15465b9c547cSRui Paulo if (modes[m].rates[i] > 200) { 15475b9c547cSRui Paulo modes[m].mode = HOSTAPD_MODE_IEEE80211G; 15485b9c547cSRui Paulo break; 15495b9c547cSRui Paulo } 15505b9c547cSRui Paulo } 15515b9c547cSRui Paulo } else if (modes[m].channels[0].freq > 50000) 15525b9c547cSRui Paulo modes[m].mode = HOSTAPD_MODE_IEEE80211AD; 15535b9c547cSRui Paulo else 15545b9c547cSRui Paulo modes[m].mode = HOSTAPD_MODE_IEEE80211A; 15555b9c547cSRui Paulo } 15565b9c547cSRui Paulo 15575b9c547cSRui Paulo /* If only 802.11g mode is included, use it to construct matching 15585b9c547cSRui Paulo * 802.11b mode data. */ 15595b9c547cSRui Paulo 15605b9c547cSRui Paulo for (m = 0; m < *num_modes; m++) { 15615b9c547cSRui Paulo if (modes[m].mode == HOSTAPD_MODE_IEEE80211B) 15625b9c547cSRui Paulo return modes; /* 802.11b already included */ 15635b9c547cSRui Paulo if (modes[m].mode == HOSTAPD_MODE_IEEE80211G) 15645b9c547cSRui Paulo mode11g_idx = m; 15655b9c547cSRui Paulo } 15665b9c547cSRui Paulo 15675b9c547cSRui Paulo if (mode11g_idx < 0) 15685b9c547cSRui Paulo return modes; /* 2.4 GHz band not supported at all */ 15695b9c547cSRui Paulo 15705b9c547cSRui Paulo nmodes = os_realloc_array(modes, *num_modes + 1, sizeof(*nmodes)); 15715b9c547cSRui Paulo if (nmodes == NULL) 15725b9c547cSRui Paulo return modes; /* Could not add 802.11b mode */ 15735b9c547cSRui Paulo 15745b9c547cSRui Paulo mode = &nmodes[*num_modes]; 15755b9c547cSRui Paulo os_memset(mode, 0, sizeof(*mode)); 15765b9c547cSRui Paulo (*num_modes)++; 15775b9c547cSRui Paulo modes = nmodes; 15785b9c547cSRui Paulo 15795b9c547cSRui Paulo mode->mode = HOSTAPD_MODE_IEEE80211B; 15805b9c547cSRui Paulo 15815b9c547cSRui Paulo mode11g = &modes[mode11g_idx]; 15825b9c547cSRui Paulo mode->num_channels = mode11g->num_channels; 1583*85732ac8SCy Schubert mode->channels = os_memdup(mode11g->channels, 1584*85732ac8SCy Schubert mode11g->num_channels * 15855b9c547cSRui Paulo sizeof(struct hostapd_channel_data)); 15865b9c547cSRui Paulo if (mode->channels == NULL) { 15875b9c547cSRui Paulo (*num_modes)--; 15885b9c547cSRui Paulo return modes; /* Could not add 802.11b mode */ 15895b9c547cSRui Paulo } 15905b9c547cSRui Paulo 15915b9c547cSRui Paulo mode->num_rates = 0; 15925b9c547cSRui Paulo mode->rates = os_malloc(4 * sizeof(int)); 15935b9c547cSRui Paulo if (mode->rates == NULL) { 15945b9c547cSRui Paulo os_free(mode->channels); 15955b9c547cSRui Paulo (*num_modes)--; 15965b9c547cSRui Paulo return modes; /* Could not add 802.11b mode */ 15975b9c547cSRui Paulo } 15985b9c547cSRui Paulo 15995b9c547cSRui Paulo for (i = 0; i < mode11g->num_rates; i++) { 16005b9c547cSRui Paulo if (mode11g->rates[i] != 10 && mode11g->rates[i] != 20 && 16015b9c547cSRui Paulo mode11g->rates[i] != 55 && mode11g->rates[i] != 110) 16025b9c547cSRui Paulo continue; 16035b9c547cSRui Paulo mode->rates[mode->num_rates] = mode11g->rates[i]; 16045b9c547cSRui Paulo mode->num_rates++; 16055b9c547cSRui Paulo if (mode->num_rates == 4) 16065b9c547cSRui Paulo break; 16075b9c547cSRui Paulo } 16085b9c547cSRui Paulo 16095b9c547cSRui Paulo if (mode->num_rates == 0) { 16105b9c547cSRui Paulo os_free(mode->channels); 16115b9c547cSRui Paulo os_free(mode->rates); 16125b9c547cSRui Paulo (*num_modes)--; 16135b9c547cSRui Paulo return modes; /* No 802.11b rates */ 16145b9c547cSRui Paulo } 16155b9c547cSRui Paulo 16165b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Added 802.11b mode based on 802.11g " 16175b9c547cSRui Paulo "information"); 16185b9c547cSRui Paulo 16195b9c547cSRui Paulo return modes; 16205b9c547cSRui Paulo } 16215b9c547cSRui Paulo 16225b9c547cSRui Paulo 16235b9c547cSRui Paulo static void nl80211_set_ht40_mode(struct hostapd_hw_modes *mode, int start, 16245b9c547cSRui Paulo int end) 16255b9c547cSRui Paulo { 16265b9c547cSRui Paulo int c; 16275b9c547cSRui Paulo 16285b9c547cSRui Paulo for (c = 0; c < mode->num_channels; c++) { 16295b9c547cSRui Paulo struct hostapd_channel_data *chan = &mode->channels[c]; 16305b9c547cSRui Paulo if (chan->freq - 10 >= start && chan->freq + 10 <= end) 16315b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_HT40; 16325b9c547cSRui Paulo } 16335b9c547cSRui Paulo } 16345b9c547cSRui Paulo 16355b9c547cSRui Paulo 16365b9c547cSRui Paulo static void nl80211_set_ht40_mode_sec(struct hostapd_hw_modes *mode, int start, 16375b9c547cSRui Paulo int end) 16385b9c547cSRui Paulo { 16395b9c547cSRui Paulo int c; 16405b9c547cSRui Paulo 16415b9c547cSRui Paulo for (c = 0; c < mode->num_channels; c++) { 16425b9c547cSRui Paulo struct hostapd_channel_data *chan = &mode->channels[c]; 16435b9c547cSRui Paulo if (!(chan->flag & HOSTAPD_CHAN_HT40)) 16445b9c547cSRui Paulo continue; 16455b9c547cSRui Paulo if (chan->freq - 30 >= start && chan->freq - 10 <= end) 16465b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_HT40MINUS; 16475b9c547cSRui Paulo if (chan->freq + 10 >= start && chan->freq + 30 <= end) 16485b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_HT40PLUS; 16495b9c547cSRui Paulo } 16505b9c547cSRui Paulo } 16515b9c547cSRui Paulo 16525b9c547cSRui Paulo 16535b9c547cSRui Paulo static void nl80211_reg_rule_max_eirp(u32 start, u32 end, u32 max_eirp, 16545b9c547cSRui Paulo struct phy_info_arg *results) 16555b9c547cSRui Paulo { 16565b9c547cSRui Paulo u16 m; 16575b9c547cSRui Paulo 16585b9c547cSRui Paulo for (m = 0; m < *results->num_modes; m++) { 16595b9c547cSRui Paulo int c; 16605b9c547cSRui Paulo struct hostapd_hw_modes *mode = &results->modes[m]; 16615b9c547cSRui Paulo 16625b9c547cSRui Paulo for (c = 0; c < mode->num_channels; c++) { 16635b9c547cSRui Paulo struct hostapd_channel_data *chan = &mode->channels[c]; 16645b9c547cSRui Paulo if ((u32) chan->freq - 10 >= start && 16655b9c547cSRui Paulo (u32) chan->freq + 10 <= end) 16665b9c547cSRui Paulo chan->max_tx_power = max_eirp; 16675b9c547cSRui Paulo } 16685b9c547cSRui Paulo } 16695b9c547cSRui Paulo } 16705b9c547cSRui Paulo 16715b9c547cSRui Paulo 16725b9c547cSRui Paulo static void nl80211_reg_rule_ht40(u32 start, u32 end, 16735b9c547cSRui Paulo struct phy_info_arg *results) 16745b9c547cSRui Paulo { 16755b9c547cSRui Paulo u16 m; 16765b9c547cSRui Paulo 16775b9c547cSRui Paulo for (m = 0; m < *results->num_modes; m++) { 16785b9c547cSRui Paulo if (!(results->modes[m].ht_capab & 16795b9c547cSRui Paulo HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) 16805b9c547cSRui Paulo continue; 16815b9c547cSRui Paulo nl80211_set_ht40_mode(&results->modes[m], start, end); 16825b9c547cSRui Paulo } 16835b9c547cSRui Paulo } 16845b9c547cSRui Paulo 16855b9c547cSRui Paulo 16865b9c547cSRui Paulo static void nl80211_reg_rule_sec(struct nlattr *tb[], 16875b9c547cSRui Paulo struct phy_info_arg *results) 16885b9c547cSRui Paulo { 16895b9c547cSRui Paulo u32 start, end, max_bw; 16905b9c547cSRui Paulo u16 m; 16915b9c547cSRui Paulo 16925b9c547cSRui Paulo if (tb[NL80211_ATTR_FREQ_RANGE_START] == NULL || 16935b9c547cSRui Paulo tb[NL80211_ATTR_FREQ_RANGE_END] == NULL || 16945b9c547cSRui Paulo tb[NL80211_ATTR_FREQ_RANGE_MAX_BW] == NULL) 16955b9c547cSRui Paulo return; 16965b9c547cSRui Paulo 16975b9c547cSRui Paulo start = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]) / 1000; 16985b9c547cSRui Paulo end = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]) / 1000; 16995b9c547cSRui Paulo max_bw = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]) / 1000; 17005b9c547cSRui Paulo 17015b9c547cSRui Paulo if (max_bw < 20) 17025b9c547cSRui Paulo return; 17035b9c547cSRui Paulo 17045b9c547cSRui Paulo for (m = 0; m < *results->num_modes; m++) { 17055b9c547cSRui Paulo if (!(results->modes[m].ht_capab & 17065b9c547cSRui Paulo HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) 17075b9c547cSRui Paulo continue; 17085b9c547cSRui Paulo nl80211_set_ht40_mode_sec(&results->modes[m], start, end); 17095b9c547cSRui Paulo } 17105b9c547cSRui Paulo } 17115b9c547cSRui Paulo 17125b9c547cSRui Paulo 17135b9c547cSRui Paulo static void nl80211_set_vht_mode(struct hostapd_hw_modes *mode, int start, 1714780fb4a2SCy Schubert int end, int max_bw) 17155b9c547cSRui Paulo { 17165b9c547cSRui Paulo int c; 17175b9c547cSRui Paulo 17185b9c547cSRui Paulo for (c = 0; c < mode->num_channels; c++) { 17195b9c547cSRui Paulo struct hostapd_channel_data *chan = &mode->channels[c]; 17205b9c547cSRui Paulo if (chan->freq - 10 >= start && chan->freq + 70 <= end) 17215b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_VHT_10_70; 17225b9c547cSRui Paulo 17235b9c547cSRui Paulo if (chan->freq - 30 >= start && chan->freq + 50 <= end) 17245b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_VHT_30_50; 17255b9c547cSRui Paulo 17265b9c547cSRui Paulo if (chan->freq - 50 >= start && chan->freq + 30 <= end) 17275b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_VHT_50_30; 17285b9c547cSRui Paulo 17295b9c547cSRui Paulo if (chan->freq - 70 >= start && chan->freq + 10 <= end) 17305b9c547cSRui Paulo chan->flag |= HOSTAPD_CHAN_VHT_70_10; 1731780fb4a2SCy Schubert 1732780fb4a2SCy Schubert if (max_bw >= 160) { 1733780fb4a2SCy Schubert if (chan->freq - 10 >= start && chan->freq + 150 <= end) 1734780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_10_150; 1735780fb4a2SCy Schubert 1736780fb4a2SCy Schubert if (chan->freq - 30 >= start && chan->freq + 130 <= end) 1737780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_30_130; 1738780fb4a2SCy Schubert 1739780fb4a2SCy Schubert if (chan->freq - 50 >= start && chan->freq + 110 <= end) 1740780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_50_110; 1741780fb4a2SCy Schubert 1742780fb4a2SCy Schubert if (chan->freq - 70 >= start && chan->freq + 90 <= end) 1743780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_70_90; 1744780fb4a2SCy Schubert 1745780fb4a2SCy Schubert if (chan->freq - 90 >= start && chan->freq + 70 <= end) 1746780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_90_70; 1747780fb4a2SCy Schubert 1748780fb4a2SCy Schubert if (chan->freq - 110 >= start && chan->freq + 50 <= end) 1749780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_110_50; 1750780fb4a2SCy Schubert 1751780fb4a2SCy Schubert if (chan->freq - 130 >= start && chan->freq + 30 <= end) 1752780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_130_30; 1753780fb4a2SCy Schubert 1754780fb4a2SCy Schubert if (chan->freq - 150 >= start && chan->freq + 10 <= end) 1755780fb4a2SCy Schubert chan->flag |= HOSTAPD_CHAN_VHT_150_10; 1756780fb4a2SCy Schubert } 17575b9c547cSRui Paulo } 17585b9c547cSRui Paulo } 17595b9c547cSRui Paulo 17605b9c547cSRui Paulo 17615b9c547cSRui Paulo static void nl80211_reg_rule_vht(struct nlattr *tb[], 17625b9c547cSRui Paulo struct phy_info_arg *results) 17635b9c547cSRui Paulo { 17645b9c547cSRui Paulo u32 start, end, max_bw; 17655b9c547cSRui Paulo u16 m; 17665b9c547cSRui Paulo 17675b9c547cSRui Paulo if (tb[NL80211_ATTR_FREQ_RANGE_START] == NULL || 17685b9c547cSRui Paulo tb[NL80211_ATTR_FREQ_RANGE_END] == NULL || 17695b9c547cSRui Paulo tb[NL80211_ATTR_FREQ_RANGE_MAX_BW] == NULL) 17705b9c547cSRui Paulo return; 17715b9c547cSRui Paulo 17725b9c547cSRui Paulo start = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_START]) / 1000; 17735b9c547cSRui Paulo end = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_END]) / 1000; 17745b9c547cSRui Paulo max_bw = nla_get_u32(tb[NL80211_ATTR_FREQ_RANGE_MAX_BW]) / 1000; 17755b9c547cSRui Paulo 17765b9c547cSRui Paulo if (max_bw < 80) 17775b9c547cSRui Paulo return; 17785b9c547cSRui Paulo 17795b9c547cSRui Paulo for (m = 0; m < *results->num_modes; m++) { 17805b9c547cSRui Paulo if (!(results->modes[m].ht_capab & 17815b9c547cSRui Paulo HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) 17825b9c547cSRui Paulo continue; 17835b9c547cSRui Paulo /* TODO: use a real VHT support indication */ 17845b9c547cSRui Paulo if (!results->modes[m].vht_capab) 17855b9c547cSRui Paulo continue; 17865b9c547cSRui Paulo 1787780fb4a2SCy Schubert nl80211_set_vht_mode(&results->modes[m], start, end, max_bw); 17885b9c547cSRui Paulo } 17895b9c547cSRui Paulo } 17905b9c547cSRui Paulo 17915b9c547cSRui Paulo 1792*85732ac8SCy Schubert static void nl80211_set_dfs_domain(enum nl80211_dfs_regions region, 1793*85732ac8SCy Schubert u8 *dfs_domain) 1794*85732ac8SCy Schubert { 1795*85732ac8SCy Schubert if (region == NL80211_DFS_FCC) 1796*85732ac8SCy Schubert *dfs_domain = HOSTAPD_DFS_REGION_FCC; 1797*85732ac8SCy Schubert else if (region == NL80211_DFS_ETSI) 1798*85732ac8SCy Schubert *dfs_domain = HOSTAPD_DFS_REGION_ETSI; 1799*85732ac8SCy Schubert else if (region == NL80211_DFS_JP) 1800*85732ac8SCy Schubert *dfs_domain = HOSTAPD_DFS_REGION_JP; 1801*85732ac8SCy Schubert else 1802*85732ac8SCy Schubert *dfs_domain = 0; 1803*85732ac8SCy Schubert } 1804*85732ac8SCy Schubert 1805*85732ac8SCy Schubert 18065b9c547cSRui Paulo static const char * dfs_domain_name(enum nl80211_dfs_regions region) 18075b9c547cSRui Paulo { 18085b9c547cSRui Paulo switch (region) { 18095b9c547cSRui Paulo case NL80211_DFS_UNSET: 18105b9c547cSRui Paulo return "DFS-UNSET"; 18115b9c547cSRui Paulo case NL80211_DFS_FCC: 18125b9c547cSRui Paulo return "DFS-FCC"; 18135b9c547cSRui Paulo case NL80211_DFS_ETSI: 18145b9c547cSRui Paulo return "DFS-ETSI"; 18155b9c547cSRui Paulo case NL80211_DFS_JP: 18165b9c547cSRui Paulo return "DFS-JP"; 18175b9c547cSRui Paulo default: 18185b9c547cSRui Paulo return "DFS-invalid"; 18195b9c547cSRui Paulo } 18205b9c547cSRui Paulo } 18215b9c547cSRui Paulo 18225b9c547cSRui Paulo 18235b9c547cSRui Paulo static int nl80211_get_reg(struct nl_msg *msg, void *arg) 18245b9c547cSRui Paulo { 18255b9c547cSRui Paulo struct phy_info_arg *results = arg; 18265b9c547cSRui Paulo struct nlattr *tb_msg[NL80211_ATTR_MAX + 1]; 18275b9c547cSRui Paulo struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); 18285b9c547cSRui Paulo struct nlattr *nl_rule; 18295b9c547cSRui Paulo struct nlattr *tb_rule[NL80211_FREQUENCY_ATTR_MAX + 1]; 18305b9c547cSRui Paulo int rem_rule; 18315b9c547cSRui Paulo static struct nla_policy reg_policy[NL80211_FREQUENCY_ATTR_MAX + 1] = { 18325b9c547cSRui Paulo [NL80211_ATTR_REG_RULE_FLAGS] = { .type = NLA_U32 }, 18335b9c547cSRui Paulo [NL80211_ATTR_FREQ_RANGE_START] = { .type = NLA_U32 }, 18345b9c547cSRui Paulo [NL80211_ATTR_FREQ_RANGE_END] = { .type = NLA_U32 }, 18355b9c547cSRui Paulo [NL80211_ATTR_FREQ_RANGE_MAX_BW] = { .type = NLA_U32 }, 18365b9c547cSRui Paulo [NL80211_ATTR_POWER_RULE_MAX_ANT_GAIN] = { .type = NLA_U32 }, 18375b9c547cSRui Paulo [NL80211_ATTR_POWER_RULE_MAX_EIRP] = { .type = NLA_U32 }, 18385b9c547cSRui Paulo }; 18395b9c547cSRui Paulo 18405b9c547cSRui Paulo nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), 18415b9c547cSRui Paulo genlmsg_attrlen(gnlh, 0), NULL); 18425b9c547cSRui Paulo if (!tb_msg[NL80211_ATTR_REG_ALPHA2] || 18435b9c547cSRui Paulo !tb_msg[NL80211_ATTR_REG_RULES]) { 18445b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: No regulatory information " 18455b9c547cSRui Paulo "available"); 18465b9c547cSRui Paulo return NL_SKIP; 18475b9c547cSRui Paulo } 18485b9c547cSRui Paulo 18495b9c547cSRui Paulo if (tb_msg[NL80211_ATTR_DFS_REGION]) { 18505b9c547cSRui Paulo enum nl80211_dfs_regions dfs_domain; 18515b9c547cSRui Paulo dfs_domain = nla_get_u8(tb_msg[NL80211_ATTR_DFS_REGION]); 1852*85732ac8SCy Schubert nl80211_set_dfs_domain(dfs_domain, &results->dfs_domain); 18535b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Regulatory information - country=%s (%s)", 18545b9c547cSRui Paulo (char *) nla_data(tb_msg[NL80211_ATTR_REG_ALPHA2]), 18555b9c547cSRui Paulo dfs_domain_name(dfs_domain)); 18565b9c547cSRui Paulo } else { 18575b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: Regulatory information - country=%s", 18585b9c547cSRui Paulo (char *) nla_data(tb_msg[NL80211_ATTR_REG_ALPHA2])); 18595b9c547cSRui Paulo } 18605b9c547cSRui Paulo 18615b9c547cSRui Paulo nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule) 18625b9c547cSRui Paulo { 18635b9c547cSRui Paulo u32 start, end, max_eirp = 0, max_bw = 0, flags = 0; 18645b9c547cSRui Paulo nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX, 18655b9c547cSRui Paulo nla_data(nl_rule), nla_len(nl_rule), reg_policy); 18665b9c547cSRui Paulo if (tb_rule[NL80211_ATTR_FREQ_RANGE_START] == NULL || 18675b9c547cSRui Paulo tb_rule[NL80211_ATTR_FREQ_RANGE_END] == NULL) 18685b9c547cSRui Paulo continue; 18695b9c547cSRui Paulo start = nla_get_u32(tb_rule[NL80211_ATTR_FREQ_RANGE_START]) / 1000; 18705b9c547cSRui Paulo end = nla_get_u32(tb_rule[NL80211_ATTR_FREQ_RANGE_END]) / 1000; 18715b9c547cSRui Paulo if (tb_rule[NL80211_ATTR_POWER_RULE_MAX_EIRP]) 18725b9c547cSRui Paulo max_eirp = nla_get_u32(tb_rule[NL80211_ATTR_POWER_RULE_MAX_EIRP]) / 100; 18735b9c547cSRui Paulo if (tb_rule[NL80211_ATTR_FREQ_RANGE_MAX_BW]) 18745b9c547cSRui Paulo max_bw = nla_get_u32(tb_rule[NL80211_ATTR_FREQ_RANGE_MAX_BW]) / 1000; 18755b9c547cSRui Paulo if (tb_rule[NL80211_ATTR_REG_RULE_FLAGS]) 18765b9c547cSRui Paulo flags = nla_get_u32(tb_rule[NL80211_ATTR_REG_RULE_FLAGS]); 18775b9c547cSRui Paulo 18785b9c547cSRui Paulo wpa_printf(MSG_DEBUG, "nl80211: %u-%u @ %u MHz %u mBm%s%s%s%s%s%s%s%s", 18795b9c547cSRui Paulo start, end, max_bw, max_eirp, 18805b9c547cSRui Paulo flags & NL80211_RRF_NO_OFDM ? " (no OFDM)" : "", 18815b9c547cSRui Paulo flags & NL80211_RRF_NO_CCK ? " (no CCK)" : "", 18825b9c547cSRui Paulo flags & NL80211_RRF_NO_INDOOR ? " (no indoor)" : "", 18835b9c547cSRui Paulo flags & NL80211_RRF_NO_OUTDOOR ? " (no outdoor)" : 18845b9c547cSRui Paulo "", 18855b9c547cSRui Paulo flags & NL80211_RRF_DFS ? " (DFS)" : "", 18865b9c547cSRui Paulo flags & NL80211_RRF_PTP_ONLY ? " (PTP only)" : "", 18875b9c547cSRui Paulo flags & NL80211_RRF_PTMP_ONLY ? " (PTMP only)" : "", 18885b9c547cSRui Paulo flags & NL80211_RRF_NO_IR ? " (no IR)" : ""); 18895b9c547cSRui Paulo if (max_bw >= 40) 18905b9c547cSRui Paulo nl80211_reg_rule_ht40(start, end, results); 18915b9c547cSRui Paulo if (tb_rule[NL80211_ATTR_POWER_RULE_MAX_EIRP]) 18925b9c547cSRui Paulo nl80211_reg_rule_max_eirp(start, end, max_eirp, 18935b9c547cSRui Paulo results); 18945b9c547cSRui Paulo } 18955b9c547cSRui Paulo 18965b9c547cSRui Paulo nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule) 18975b9c547cSRui Paulo { 18985b9c547cSRui Paulo nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX, 18995b9c547cSRui Paulo nla_data(nl_rule), nla_len(nl_rule), reg_policy); 19005b9c547cSRui Paulo nl80211_reg_rule_sec(tb_rule, results); 19015b9c547cSRui Paulo } 19025b9c547cSRui Paulo 19035b9c547cSRui Paulo nla_for_each_nested(nl_rule, tb_msg[NL80211_ATTR_REG_RULES], rem_rule) 19045b9c547cSRui Paulo { 19055b9c547cSRui Paulo nla_parse(tb_rule, NL80211_FREQUENCY_ATTR_MAX, 19065b9c547cSRui Paulo nla_data(nl_rule), nla_len(nl_rule), reg_policy); 19075b9c547cSRui Paulo nl80211_reg_rule_vht(tb_rule, results); 19085b9c547cSRui Paulo } 19095b9c547cSRui Paulo 19105b9c547cSRui Paulo return NL_SKIP; 19115b9c547cSRui Paulo } 19125b9c547cSRui Paulo 19135b9c547cSRui Paulo 19145b9c547cSRui Paulo static int nl80211_set_regulatory_flags(struct wpa_driver_nl80211_data *drv, 19155b9c547cSRui Paulo struct phy_info_arg *results) 19165b9c547cSRui Paulo { 19175b9c547cSRui Paulo struct nl_msg *msg; 19185b9c547cSRui Paulo 19195b9c547cSRui Paulo msg = nlmsg_alloc(); 19205b9c547cSRui Paulo if (!msg) 19215b9c547cSRui Paulo return -ENOMEM; 19225b9c547cSRui Paulo 19235b9c547cSRui Paulo nl80211_cmd(drv, msg, 0, NL80211_CMD_GET_REG); 1924*85732ac8SCy Schubert if (drv->capa.flags & WPA_DRIVER_FLAGS_SELF_MANAGED_REGULATORY) { 1925*85732ac8SCy Schubert if (nla_put_u32(msg, NL80211_ATTR_WIPHY, drv->wiphy_idx)) { 1926*85732ac8SCy Schubert nlmsg_free(msg); 1927*85732ac8SCy Schubert return -1; 1928*85732ac8SCy Schubert } 1929*85732ac8SCy Schubert } 1930*85732ac8SCy Schubert 19315b9c547cSRui Paulo return send_and_recv_msgs(drv, msg, nl80211_get_reg, results); 19325b9c547cSRui Paulo } 19335b9c547cSRui Paulo 19345b9c547cSRui Paulo 19355b9c547cSRui Paulo struct hostapd_hw_modes * 1936*85732ac8SCy Schubert nl80211_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags, 1937*85732ac8SCy Schubert u8 *dfs_domain) 19385b9c547cSRui Paulo { 19395b9c547cSRui Paulo u32 feat; 19405b9c547cSRui Paulo struct i802_bss *bss = priv; 19415b9c547cSRui Paulo struct wpa_driver_nl80211_data *drv = bss->drv; 19425b9c547cSRui Paulo int nl_flags = 0; 19435b9c547cSRui Paulo struct nl_msg *msg; 19445b9c547cSRui Paulo struct phy_info_arg result = { 19455b9c547cSRui Paulo .num_modes = num_modes, 19465b9c547cSRui Paulo .modes = NULL, 19475b9c547cSRui Paulo .last_mode = -1, 1948780fb4a2SCy Schubert .failed = 0, 1949*85732ac8SCy Schubert .dfs_domain = 0, 19505b9c547cSRui Paulo }; 19515b9c547cSRui Paulo 19525b9c547cSRui Paulo *num_modes = 0; 19535b9c547cSRui Paulo *flags = 0; 1954*85732ac8SCy Schubert *dfs_domain = 0; 19555b9c547cSRui Paulo 19565b9c547cSRui Paulo feat = get_nl80211_protocol_features(drv); 19575b9c547cSRui Paulo if (feat & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP) 19585b9c547cSRui Paulo nl_flags = NLM_F_DUMP; 19595b9c547cSRui Paulo if (!(msg = nl80211_cmd_msg(bss, nl_flags, NL80211_CMD_GET_WIPHY)) || 19605b9c547cSRui Paulo nla_put_flag(msg, NL80211_ATTR_SPLIT_WIPHY_DUMP)) { 19615b9c547cSRui Paulo nlmsg_free(msg); 19625b9c547cSRui Paulo return NULL; 19635b9c547cSRui Paulo } 19645b9c547cSRui Paulo 19655b9c547cSRui Paulo if (send_and_recv_msgs(drv, msg, phy_info_handler, &result) == 0) { 19665b9c547cSRui Paulo nl80211_set_regulatory_flags(drv, &result); 1967780fb4a2SCy Schubert if (result.failed) { 1968780fb4a2SCy Schubert int i; 1969780fb4a2SCy Schubert 1970780fb4a2SCy Schubert for (i = 0; result.modes && i < *num_modes; i++) { 1971780fb4a2SCy Schubert os_free(result.modes[i].channels); 1972780fb4a2SCy Schubert os_free(result.modes[i].rates); 1973780fb4a2SCy Schubert } 1974780fb4a2SCy Schubert os_free(result.modes); 1975*85732ac8SCy Schubert *num_modes = 0; 1976780fb4a2SCy Schubert return NULL; 1977780fb4a2SCy Schubert } 1978*85732ac8SCy Schubert 1979*85732ac8SCy Schubert *dfs_domain = result.dfs_domain; 1980*85732ac8SCy Schubert 19815b9c547cSRui Paulo return wpa_driver_nl80211_postprocess_modes(result.modes, 19825b9c547cSRui Paulo num_modes); 19835b9c547cSRui Paulo } 19845b9c547cSRui Paulo 19855b9c547cSRui Paulo return NULL; 19865b9c547cSRui Paulo } 1987