wifi: iwlwifi: mvm: add support for timing measurement
authorKrishnanand Prabhu <krishnanand.prabhu@intel.com>
Mon, 20 Mar 2023 10:33:05 +0000 (12:33 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 22 Mar 2023 12:16:35 +0000 (13:16 +0100)
Add support for timing measurement in extended capabilities, used for
time synchronization.

Signed-off-by: Krishnanand Prabhu <krishnanand.prabhu@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230320122330.001d2b459ece.I15ab8fc214edc35f1f362006a9e1a22b89e7ed8e@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

index 93ca92e..7ee8d24 100644 (file)
@@ -222,19 +222,39 @@ int iwl_mvm_init_fw_regd(struct iwl_mvm *mvm)
        return ret;
 }
 
+/* Each capability added here should also be add to tm_if_types_ext_capa_sta */
 static const u8 he_if_types_ext_capa_sta[] = {
         [0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING,
         [2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT,
         [7] = WLAN_EXT_CAPA8_OPMODE_NOTIF,
 };
 
-static const struct wiphy_iftype_ext_capab he_iftypes_ext_capa[] = {
+static const u8 tm_if_types_ext_capa_sta[] = {
+        [0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING,
+        [2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT |
+              WLAN_EXT_CAPA3_TIMING_MEASUREMENT_SUPPORT,
+        [7] = WLAN_EXT_CAPA8_OPMODE_NOTIF,
+        [9] = WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT,
+};
+
+/* Additional interface types for which extended capabilities are
+ * specified separately
+ */
+static const struct wiphy_iftype_ext_capab add_iftypes_ext_capa[] = {
        {
                .iftype = NL80211_IFTYPE_STATION,
                .extended_capabilities = he_if_types_ext_capa_sta,
                .extended_capabilities_mask = he_if_types_ext_capa_sta,
                .extended_capabilities_len = sizeof(he_if_types_ext_capa_sta),
        },
+       {
+               .iftype = NL80211_IFTYPE_STATION,
+               .extended_capabilities = tm_if_types_ext_capa_sta,
+               .extended_capabilities_mask = tm_if_types_ext_capa_sta,
+               .extended_capabilities_len = sizeof(tm_if_types_ext_capa_sta),
+               /* relevant only if EHT is supported */
+               .eml_capabilities = IEEE80211_EML_CAP_EMLSR_SUPP,
+       },
 };
 
 static int
@@ -562,16 +582,34 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
                                              NL80211_EXT_FEATURE_OCE_PROBE_REQ_DEFERRAL_SUPPRESSION);
        }
 
+       hw->wiphy->iftype_ext_capab = NULL;
+       hw->wiphy->num_iftype_ext_capab = 0;
+
        if (mvm->nvm_data->sku_cap_11ax_enable &&
            !iwlwifi_mod_params.disable_11ax) {
-               hw->wiphy->iftype_ext_capab = he_iftypes_ext_capa;
+               hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa;
                hw->wiphy->num_iftype_ext_capab =
-                       ARRAY_SIZE(he_iftypes_ext_capa);
+                       ARRAY_SIZE(add_iftypes_ext_capa) - 1;
 
                ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
                ieee80211_hw_set(hw, SUPPORTS_ONLY_HE_MULTI_BSSID);
        }
 
+       if (iwl_fw_lookup_cmd_ver(mvm->fw,
+                                 WIDE_ID(DATA_PATH_GROUP,
+                                         WNM_80211V_TIMING_MEASUREMENT_CONFIG_CMD),
+                                 IWL_FW_CMD_VER_UNKNOWN) >= 1) {
+               IWL_DEBUG_INFO(mvm->trans, "Timing measurement supported\n");
+
+               if (!hw->wiphy->iftype_ext_capab) {
+                       hw->wiphy->num_iftype_ext_capab = 1;
+                       hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa +
+                               ARRAY_SIZE(add_iftypes_ext_capa) - 1;
+               } else {
+                       hw->wiphy->iftype_ext_capab = add_iftypes_ext_capa + 1;
+               }
+       }
+
        mvm->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD;
 
 #ifdef CONFIG_PM_SLEEP