1 /* 2 * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: wlan_cfg80211_wifi_pos.c 21 * defines wifi-pos module related driver functions interfacing with linux 22 * kernel 23 */ 24 #include "wlan_cfg80211.h" 25 #include "wlan_objmgr_psoc_obj.h" 26 #include "wlan_cfg80211_wifi_pos.h" 27 #include "wlan_cmn_ieee80211.h" 28 29 #if defined(WIFI_POS_CONVERGED) && defined(WLAN_FEATURE_RTT_11AZ_SUPPORT) 30 31 u8 wlan_extended_caps_iface[WLAN_EXTCAP_IE_MAX_LEN] = {0}; 32 u8 wlan_extended_caps_iface_mask[WLAN_EXTCAP_IE_MAX_LEN] = {0}; 33 34 struct wiphy_iftype_ext_capab iftype_ext_cap; 35 36 #define WLAN_EXT_RANGING_CAP_IDX 11 37 void 38 wlan_wifi_pos_cfg80211_set_wiphy_ext_feature(struct wiphy *wiphy, 39 struct wlan_objmgr_psoc *psoc) 40 { 41 if (wlan_psoc_nif_fw_ext_cap_get(psoc, WLAN_RTT_11AZ_NTB_SUPPORT)) { 42 wlan_extended_caps_iface[WLAN_EXT_RANGING_CAP_IDX] |= 43 WLAN_EXT_CAPA11_NTB_RANGING_RESPONDER; 44 wlan_extended_caps_iface_mask[WLAN_EXT_RANGING_CAP_IDX] |= 45 WLAN_EXT_CAPA11_NTB_RANGING_RESPONDER; 46 } 47 48 if (wlan_psoc_nif_fw_ext2_cap_get(psoc, WLAN_RTT_11AZ_TB_SUPPORT)) { 49 wlan_extended_caps_iface[WLAN_EXT_RANGING_CAP_IDX] |= 50 WLAN_EXT_CAPA11_TB_RANGING_RESPONDER; 51 wlan_extended_caps_iface_mask[WLAN_EXT_RANGING_CAP_IDX] |= 52 WLAN_EXT_CAPA11_TB_RANGING_RESPONDER; 53 } 54 55 iftype_ext_cap.iftype = NL80211_IFTYPE_AP; 56 iftype_ext_cap.extended_capabilities = 57 wlan_extended_caps_iface, 58 iftype_ext_cap.extended_capabilities_mask = 59 wlan_extended_caps_iface_mask, 60 iftype_ext_cap.extended_capabilities_len = 61 ARRAY_SIZE(wlan_extended_caps_iface), 62 63 wiphy->num_iftype_ext_capab = 0; 64 wiphy->iftype_ext_capab = &iftype_ext_cap; 65 wiphy->num_iftype_ext_capab++; 66 } 67 68 #define NUM_BITS_IN_BYTE 8 69 static void 70 wlan_wifi_pos_set_feature_flags(uint8_t *feature_flags, 71 enum qca_wlan_vendor_features feature) 72 { 73 uint32_t index; 74 uint8_t bit_mask; 75 76 index = feature / NUM_BITS_IN_BYTE; 77 bit_mask = 1 << (feature % NUM_BITS_IN_BYTE); 78 feature_flags[index] |= bit_mask; 79 } 80 81 void wlan_wifi_pos_cfg80211_set_features(struct wlan_objmgr_psoc *psoc, 82 uint8_t *feature_flags) 83 { 84 if (wlan_psoc_nif_fw_ext2_cap_get(psoc, 85 WLAN_RTT_11AZ_MAC_PHY_SEC_SUPPORT)) 86 wlan_wifi_pos_set_feature_flags(feature_flags, 87 QCA_WLAN_VENDOR_FEATURE_SECURE_LTF_STA); 88 89 if (wlan_psoc_nif_fw_ext2_cap_get(psoc, 90 WLAN_RTT_11AZ_MAC_SEC_SUPPORT)) 91 wlan_wifi_pos_set_feature_flags(feature_flags, 92 QCA_WLAN_VENDOR_FEATURE_PROT_RANGE_NEGO_AND_MEASURE_STA); 93 } 94 #endif 95