iwlwifi: mvm: add support for responder config command version 7
authorAvraham Stern <avraham.stern@intel.com>
Wed, 2 Oct 2019 10:44:27 +0000 (13:44 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Mon, 23 Dec 2019 09:54:31 +0000 (11:54 +0200)
The new API requires the driver to config the supported frame format
(legacy, HT, VHT etc.).

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/api/location.h
drivers/net/wireless/intel/iwlwifi/mvm/ftm-responder.c

index a51fda4c95885dd0046c51a5ac237e01db64dcfd..a0d6802c2715bd81346abf1bac8243609bd878b0 100644 (file)
@@ -240,7 +240,7 @@ enum iwl_tof_responder_cfg_flags {
 };
 
 /**
- * struct iwl_tof_responder_config_cmd - ToF AP mode (for debug)
+ * struct iwl_tof_responder_config_cmd_v6 - ToF AP mode (for debug)
  * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
  * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
  * @bandwidth: current AP Bandwidth: &enum iwl_tof_bandwidth
@@ -258,7 +258,7 @@ enum iwl_tof_responder_cfg_flags {
  * @bssid: Current AP BSSID
  * @reserved2: reserved
  */
-struct iwl_tof_responder_config_cmd {
+struct iwl_tof_responder_config_cmd_v6 {
        __le32 cmd_valid_fields;
        __le32 responder_cfg_flags;
        u8 bandwidth;
@@ -274,6 +274,42 @@ struct iwl_tof_responder_config_cmd {
        __le16 reserved2;
 } __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_6 */
 
+/**
+ * struct iwl_tof_responder_config_cmd - ToF AP mode (for debug)
+ * @cmd_valid_fields: &iwl_tof_responder_cmd_valid_field
+ * @responder_cfg_flags: &iwl_tof_responder_cfg_flags
+ * @format_bw: bits 0 - 3: &enum iwl_location_frame_format.
+ *             bits 4 - 7: &enum iwl_location_bw.
+ * @rate: current AP rate
+ * @channel_num: current AP Channel
+ * @ctrl_ch_position: coding of the control channel position relative to
+ *     the center frequency, see iwl_mvm_get_ctrl_pos()
+ * @sta_id: index of the AP STA when in AP mode
+ * @reserved1: reserved
+ * @toa_offset: Artificial addition [pSec] for the ToA - to be used for debug
+ *     purposes, simulating station movement by adding various values
+ *     to this field
+ * @common_calib: XVT: common calibration value
+ * @specific_calib: XVT: specific calibration value
+ * @bssid: Current AP BSSID
+ * @reserved2: reserved
+ */
+struct iwl_tof_responder_config_cmd {
+       __le32 cmd_valid_fields;
+       __le32 responder_cfg_flags;
+       u8 format_bw;
+       u8 rate;
+       u8 channel_num;
+       u8 ctrl_ch_position;
+       u8 sta_id;
+       u8 reserved1;
+       __le16 toa_offset;
+       __le16 common_calib;
+       __le16 specific_calib;
+       u8 bssid[ETH_ALEN];
+       __le16 reserved2;
+} __packed; /* TOF_RESPONDER_CONFIG_CMD_API_S_VER_6 */
+
 #define IWL_LCI_CIVIC_IE_MAX_SIZE      400
 
 /**
index 1513b8b4062f7218e8c0238b1686625e1e6c0c71..8345641984094c1d84a82d5bca11e37dd980eba6 100644 (file)
@@ -6,7 +6,7 @@
  * GPL LICENSE SUMMARY
  *
  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 Intel Corporation
+ * Copyright (C) 2018 - 2019 Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of version 2 of the GNU General Public License as
@@ -27,7 +27,7 @@
  * BSD LICENSE
  *
  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 Intel Corporation
+ * Copyright (C) 2018 - 2019 Intel Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #include "mvm.h"
 #include "constants.h"
 
+static int iwl_mvm_ftm_responder_set_bw_v1(struct cfg80211_chan_def *chandef,
+                                          u8 *bw, u8 *ctrl_ch_position)
+{
+       switch (chandef->width) {
+       case NL80211_CHAN_WIDTH_20_NOHT:
+               *bw = IWL_TOF_BW_20_LEGACY;
+               break;
+       case NL80211_CHAN_WIDTH_20:
+               *bw = IWL_TOF_BW_20_HT;
+               break;
+       case NL80211_CHAN_WIDTH_40:
+               *bw = IWL_TOF_BW_40;
+               *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
+               break;
+       case NL80211_CHAN_WIDTH_80:
+               *bw = IWL_TOF_BW_80;
+               *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
+               break;
+       default:
+               return -ENOTSUPP;
+       }
+
+       return 0;
+}
+
+static int iwl_mvm_ftm_responder_set_bw_v2(struct cfg80211_chan_def *chandef,
+                                          u8 *format_bw,
+                                          u8 *ctrl_ch_position)
+{
+       switch (chandef->width) {
+       case NL80211_CHAN_WIDTH_20_NOHT:
+               *format_bw = IWL_LOCATION_FRAME_FORMAT_LEGACY;
+               *format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+               break;
+       case NL80211_CHAN_WIDTH_20:
+               *format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
+               *format_bw |= IWL_LOCATION_BW_20MHZ << LOCATION_BW_POS;
+               break;
+       case NL80211_CHAN_WIDTH_40:
+               *format_bw = IWL_LOCATION_FRAME_FORMAT_HT;
+               *format_bw |= IWL_LOCATION_BW_40MHZ << LOCATION_BW_POS;
+               *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
+               break;
+       case NL80211_CHAN_WIDTH_80:
+               *format_bw = IWL_LOCATION_FRAME_FORMAT_VHT;
+               *format_bw |= IWL_LOCATION_BW_80MHZ << LOCATION_BW_POS;
+               *ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
+               break;
+       default:
+               return -ENOTSUPP;
+       }
+
+       return 0;
+}
+
 static int
 iwl_mvm_ftm_responder_cmd(struct iwl_mvm *mvm,
                          struct ieee80211_vif *vif,
                          struct cfg80211_chan_def *chandef)
 {
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       /*
+        * The command structure is the same for versions 6 and 7, (only the
+        * field interpretation is different), so the same struct can be use
+        * for all cases.
+        */
        struct iwl_tof_responder_config_cmd cmd = {
                .channel_num = chandef->chan->hw_value,
                .cmd_valid_fields =
@@ -76,27 +136,22 @@ iwl_mvm_ftm_responder_cmd(struct iwl_mvm *mvm,
                                    IWL_TOF_RESPONDER_CMD_VALID_STA_ID),
                .sta_id = mvmvif->bcast_sta.sta_id,
        };
+       u8 cmd_ver = iwl_mvm_lookup_cmd_ver(mvm->fw, LOCATION_GROUP,
+                                           TOF_RESPONDER_CONFIG_CMD);
+       int err;
 
        lockdep_assert_held(&mvm->mutex);
 
-       switch (chandef->width) {
-       case NL80211_CHAN_WIDTH_20_NOHT:
-               cmd.bandwidth = IWL_TOF_BW_20_LEGACY;
-               break;
-       case NL80211_CHAN_WIDTH_20:
-               cmd.bandwidth = IWL_TOF_BW_20_HT;
-               break;
-       case NL80211_CHAN_WIDTH_40:
-               cmd.bandwidth = IWL_TOF_BW_40;
-               cmd.ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
-               break;
-       case NL80211_CHAN_WIDTH_80:
-               cmd.bandwidth = IWL_TOF_BW_80;
-               cmd.ctrl_ch_position = iwl_mvm_get_ctrl_pos(chandef);
-               break;
-       default:
-               WARN_ON(1);
-               return -EINVAL;
+       if (cmd_ver == 7)
+               err = iwl_mvm_ftm_responder_set_bw_v2(chandef, &cmd.format_bw,
+                                                     &cmd.ctrl_ch_position);
+       else
+               err = iwl_mvm_ftm_responder_set_bw_v1(chandef, &cmd.format_bw,
+                                                     &cmd.ctrl_ch_position);
+
+       if (err) {
+               IWL_ERR(mvm, "Failed to set responder bandwidth\n");
+               return err;
        }
 
        memcpy(cmd.bssid, vif->addr, ETH_ALEN);