Blame SOURCES/0012-Revert-iwlwifi-mvm-support-FTM-initiator.patch

deb259
From 41894a94e16d1db4a08db235fe74040e7870d201 Mon Sep 17 00:00:00 2001
deb259
From: Eugene Syromiatnikov <esyr@redhat.com>
deb259
Date: Thu, 25 Jul 2019 13:53:34 +0200
deb259
Subject: [PATCH 6/7] Revert "iwlwifi: mvm: support FTM initiator"
deb259
deb259
This reverts commit fc36ffda326706b21f70a4aff0c77d9bc94c4f0a.
deb259
---
deb259
 .../net/wireless/intel/iwlwifi/fw/api/location.h   |  10 +-
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/Makefile    |   3 +-
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/constants.h |   1 -
deb259
 .../net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 459 ---------------------
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c  |  56 +--
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h       |  16 -
deb259
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c       |   7 -
deb259
 include/linux/ieee80211.h                          |   2 -
deb259
 8 files changed, 4 insertions(+), 550 deletions(-)
deb259
 delete mode 100644 drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
deb259
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/fw/api/location.h
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/fw/api/location.h	2019-07-25 13:55:50.467603040 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/fw/api/location.h	2019-07-25 13:56:03.737424284 +0200
deb259
@@ -7,7 +7,6 @@
deb259
  *
deb259
  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
deb259
  * Copyright (C) 2018 Intel Corporation
deb259
- * Copyright (C) 2019 Intel Corporation
deb259
  *
deb259
  * This program is free software; you can redistribute it and/or modify
deb259
  * it under the terms of version 2 of the GNU General Public License as
deb259
@@ -29,7 +28,6 @@
deb259
  *
deb259
  * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
deb259
  * Copyright (C) 2018 Intel Corporation
deb259
- * Copyright (C) 2019 Intel Corporation
deb259
  * All rights reserved.
deb259
  *
deb259
  * Redistribution and use in source and binary forms, with or without
deb259
@@ -405,10 +403,7 @@
deb259
  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A: use antenna A fo TX ACKs during FTM
deb259
  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B: use antenna B fo TX ACKs during FTM
deb259
  * @IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C: use antenna C fo TX ACKs during FTM
deb259
- * @IWL_TOF_INITIATOR_FLAGS_SPECIFIC_CALIB: use the specific calib value from
deb259
- *	the range request command
deb259
- * @IWL_TOF_INITIATOR_FLAGS_COMMON_CALIB: use the common calib value from the
deb259
- *	ragne request command
deb259
+ * @IWL_TOF_INITIATOR_FLAGS_MINDELTA_NO_PREF: no preference for minDeltaFTM
deb259
  */
deb259
 enum iwl_tof_initiator_flags {
deb259
 	IWL_TOF_INITIATOR_FLAGS_FAST_ALGO_DISABLED = BIT(0),
deb259
@@ -418,8 +413,7 @@
deb259
 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_A = BIT(4),
deb259
 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_B = BIT(5),
deb259
 	IWL_TOF_INITIATOR_FLAGS_TX_CHAIN_SEL_C = BIT(6),
deb259
-	IWL_TOF_INITIATOR_FLAGS_SPECIFIC_CALIB = BIT(15),
deb259
-	IWL_TOF_INITIATOR_FLAGS_COMMON_CALIB   = BIT(16),
deb259
+	IWL_TOF_INITIATOR_FLAGS_MINDELTA_NO_PREF = BIT(7),
deb259
 }; /* LOCATION_RANGE_REQ_CMD_API_S_VER_5 */
deb259
 
deb259
 #define IWL_MVM_TOF_MAX_APS 5
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/Makefile
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/Makefile	2019-06-27 14:54:04.131678361 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/Makefile	2019-07-25 13:56:03.737424284 +0200
deb259
@@ -4,8 +4,7 @@
deb259
 iwlmvm-y += utils.o rx.o rxmq.o tx.o binding.o quota.o sta.o sf.o
deb259
 iwlmvm-y += scan.o time-event.o rs.o rs-fw.o
deb259
 iwlmvm-y += power.o coex.o
deb259
-iwlmvm-y += tt.o offloading.o tdls.o
deb259
-iwlmvm-y += ftm-responder.o ftm-initiator.o
deb259
+iwlmvm-y += tt.o offloading.o tdls.o ftm-responder.o
deb259
 iwlmvm-$(CONFIG_IWLWIFI_DEBUGFS) += debugfs.o debugfs-vif.o
deb259
 iwlmvm-$(CONFIG_IWLWIFI_LEDS) += led.o
deb259
 iwlmvm-$(CONFIG_PM) += d3.o
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/constants.h
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/constants.h	2019-06-27 14:54:04.132678349 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/constants.h	2019-07-25 13:56:03.737424284 +0200
deb259
@@ -65,7 +65,6 @@
deb259
 #define __MVM_CONSTANTS_H
deb259
 
deb259
 #include <linux/ieee80211.h>
deb259
-#include "fw-api.h"
deb259
 
deb259
 #define IWL_MVM_UAPSD_NOAGG_BSSIDS_NUM		20
deb259
 
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c	2019-07-25 13:55:50.468603026 +0200
deb259
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
deb259
@@ -1,459 +0,0 @@
deb259
-/******************************************************************************
deb259
- *
deb259
- * This file is provided under a dual BSD/GPLv2 license.  When using or
deb259
- * redistributing this file, you may do so under either license.
deb259
- *
deb259
- * GPL LICENSE SUMMARY
deb259
- *
deb259
- * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
deb259
- * Copyright (C) 2018 Intel Corporation
deb259
- * Copyright (C) 2019 Intel Corporation
deb259
- *
deb259
- * This program is free software; you can redistribute it and/or modify
deb259
- * it under the terms of version 2 of the GNU General Public License as
deb259
- * published by the Free Software Foundation.
deb259
- *
deb259
- * This program is distributed in the hope that it will be useful, but
deb259
- * WITHOUT ANY WARRANTY; without even the implied warranty of
deb259
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
deb259
- * General Public License for more details.
deb259
- *
deb259
- * The full GNU General Public License is included in this distribution
deb259
- * in the file called COPYING.
deb259
- *
deb259
- * Contact Information:
deb259
- * Intel Linux Wireless <linuxwifi@intel.com>
deb259
- * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
deb259
- *
deb259
- * BSD LICENSE
deb259
- *
deb259
- * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
deb259
- * Copyright (C) 2018 Intel Corporation
deb259
- * Copyright (C) 2019 Intel Corporation
deb259
- * All rights reserved.
deb259
- *
deb259
- * Redistribution and use in source and binary forms, with or without
deb259
- * modification, are permitted provided that the following conditions
deb259
- * are met:
deb259
- *
deb259
- *  * Redistributions of source code must retain the above copyright
deb259
- *    notice, this list of conditions and the following disclaimer.
deb259
- *  * Redistributions in binary form must reproduce the above copyright
deb259
- *    notice, this list of conditions and the following disclaimer in
deb259
- *    the documentation and/or other materials provided with the
deb259
- *    distribution.
deb259
- *  * Neither the name Intel Corporation nor the names of its
deb259
- *    contributors may be used to endorse or promote products derived
deb259
- *    from this software without specific prior written permission.
deb259
- *
deb259
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
deb259
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
deb259
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
deb259
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
deb259
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
deb259
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
deb259
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
deb259
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
deb259
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
deb259
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
deb259
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
deb259
- *
deb259
- *****************************************************************************/
deb259
-#include <linux/etherdevice.h>
deb259
-#include <linux/math64.h>
deb259
-#include <net/cfg80211.h>
deb259
-#include "mvm.h"
deb259
-#include "iwl-io.h"
deb259
-#include "iwl-prph.h"
deb259
-#include "constants.h"
deb259
-
deb259
-struct iwl_mvm_loc_entry {
deb259
-	struct list_head list;
deb259
-	u8 addr[ETH_ALEN];
deb259
-	u8 lci_len, civic_len;
deb259
-	u8 buf[];
deb259
-};
deb259
-
deb259
-static void iwl_mvm_ftm_reset(struct iwl_mvm *mvm)
deb259
-{
deb259
-	struct iwl_mvm_loc_entry *e, *t;
deb259
-
deb259
-	mvm->ftm_initiator.req = NULL;
deb259
-	mvm->ftm_initiator.req_wdev = NULL;
deb259
-	memset(mvm->ftm_initiator.responses, 0,
deb259
-	       sizeof(mvm->ftm_initiator.responses));
deb259
-	list_for_each_entry_safe(e, t, &mvm->ftm_initiator.loc_list, list) {
deb259
-		list_del(&e->list);
deb259
-		kfree(e);
deb259
-	}
deb259
-}
deb259
-
deb259
-void iwl_mvm_ftm_restart(struct iwl_mvm *mvm)
deb259
-{
deb259
-	struct cfg80211_pmsr_result result = {
deb259
-		.status = NL80211_PMSR_STATUS_FAILURE,
deb259
-		.final = 1,
deb259
-		.host_time = ktime_get_boot_ns(),
deb259
-		.type = NL80211_PMSR_TYPE_FTM,
deb259
-	};
deb259
-	int i;
deb259
-
deb259
-	lockdep_assert_held(&mvm->mutex);
deb259
-
deb259
-	if (!mvm->ftm_initiator.req)
deb259
-		return;
deb259
-
deb259
-	for (i = 0; i < mvm->ftm_initiator.req->n_peers; i++) {
deb259
-		memcpy(result.addr, mvm->ftm_initiator.req->peers[i].addr,
deb259
-		       ETH_ALEN);
deb259
-		result.ftm.burst_index = mvm->ftm_initiator.responses[i];
deb259
-
deb259
-		cfg80211_pmsr_report(mvm->ftm_initiator.req_wdev,
deb259
-				     mvm->ftm_initiator.req,
deb259
-				     &result, GFP_KERNEL);
deb259
-	}
deb259
-
deb259
-	cfg80211_pmsr_complete(mvm->ftm_initiator.req_wdev,
deb259
-			       mvm->ftm_initiator.req, GFP_KERNEL);
deb259
-	iwl_mvm_ftm_reset(mvm);
deb259
-}
deb259
-
deb259
-static int
deb259
-iwl_ftm_range_request_status_to_err(enum iwl_tof_range_request_status s)
deb259
-{
deb259
-	switch (s) {
deb259
-	case IWL_TOF_RANGE_REQUEST_STATUS_SUCCESS:
deb259
-		return 0;
deb259
-	case IWL_TOF_RANGE_REQUEST_STATUS_BUSY:
deb259
-		return -EBUSY;
deb259
-	default:
deb259
-		WARN_ON_ONCE(1);
deb259
-		return -EIO;
deb259
-	}
deb259
-}
deb259
-
deb259
-int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
deb259
-		      struct cfg80211_pmsr_request *req)
deb259
-{
deb259
-	struct iwl_tof_range_req_cmd cmd = {
deb259
-		.request_id = req->cookie,
deb259
-		.req_timeout = DIV_ROUND_UP(req->timeout, 100),
deb259
-		.num_of_ap = req->n_peers,
deb259
-		/*
deb259
-		 * We treat it always as random, since if not we'll
deb259
-		 * have filled our local address there instead.
deb259
-		 */
deb259
-		.macaddr_random = 1,
deb259
-	};
deb259
-	struct iwl_host_cmd hcmd = {
deb259
-		.id = iwl_cmd_id(TOF_RANGE_REQ_CMD, LOCATION_GROUP, 0),
deb259
-		.data[0] = &cmd,
deb259
-		.len[0] = sizeof(cmd),
deb259
-		.dataflags[0] = IWL_HCMD_DFL_DUP,
deb259
-	};
deb259
-	u32 status = 0;
deb259
-	int err, i;
deb259
-
deb259
-	/* use maximum for "no timeout" or bigger than what we can do */
deb259
-	if (!req->timeout || req->timeout > 255 * 100)
deb259
-		cmd.req_timeout = 255;
deb259
-
deb259
-	lockdep_assert_held(&mvm->mutex);
deb259
-
deb259
-	if (mvm->ftm_initiator.req)
deb259
-		return -EBUSY;
deb259
-
deb259
-	memcpy(cmd.macaddr_template, req->mac_addr, ETH_ALEN);
deb259
-	for (i = 0; i < ETH_ALEN; i++)
deb259
-		cmd.macaddr_mask[i] = ~req->mac_addr_mask[i];
deb259
-
deb259
-	for (i = 0; i < cmd.num_of_ap; i++) {
deb259
-		struct cfg80211_pmsr_request_peer *peer = &req->peers[i];
deb259
-		struct iwl_tof_range_req_ap_entry *cmd_target = &cmd.ap[i];
deb259
-		u32 freq = peer->chandef.chan->center_freq;
deb259
-
deb259
-		cmd_target->channel_num = ieee80211_frequency_to_channel(freq);
deb259
-		switch (peer->chandef.width) {
deb259
-		case NL80211_CHAN_WIDTH_20_NOHT:
deb259
-			cmd_target->bandwidth = IWL_TOF_BW_20_LEGACY;
deb259
-			break;
deb259
-		case NL80211_CHAN_WIDTH_20:
deb259
-			cmd_target->bandwidth = IWL_TOF_BW_20_HT;
deb259
-			break;
deb259
-		case NL80211_CHAN_WIDTH_40:
deb259
-			cmd_target->bandwidth = IWL_TOF_BW_40;
deb259
-			break;
deb259
-		case NL80211_CHAN_WIDTH_80:
deb259
-			cmd_target->bandwidth = IWL_TOF_BW_80;
deb259
-			break;
deb259
-		default:
deb259
-			IWL_ERR(mvm, "Unsupported BW in FTM request (%d)\n",
deb259
-				peer->chandef.width);
deb259
-			return -EINVAL;
deb259
-		}
deb259
-		cmd_target->ctrl_ch_position =
deb259
-			(peer->chandef.width > NL80211_CHAN_WIDTH_20) ?
deb259
-			iwl_mvm_get_ctrl_pos(&peer->chandef) : 0;
deb259
-
deb259
-		memcpy(cmd_target->bssid, peer->addr, ETH_ALEN);
deb259
-		cmd_target->measure_type = 0; /* regular two-sided FTM */
deb259
-		cmd_target->num_of_bursts = peer->ftm.num_bursts_exp;
deb259
-		cmd_target->burst_period =
deb259
-			cpu_to_le16(peer->ftm.burst_period);
deb259
-		cmd_target->samples_per_burst = peer->ftm.ftms_per_burst;
deb259
-		cmd_target->retries_per_sample = peer->ftm.ftmr_retries;
deb259
-		cmd_target->asap_mode = peer->ftm.asap;
deb259
-		cmd_target->enable_dyn_ack = IWL_MVM_FTM_INITIATOR_DYNACK;
deb259
-
deb259
-		if (peer->ftm.request_lci)
deb259
-			cmd_target->location_req |= IWL_TOF_LOC_LCI;
deb259
-		if (peer->ftm.request_civicloc)
deb259
-			cmd_target->location_req |= IWL_TOF_LOC_CIVIC;
deb259
-
deb259
-		cmd_target->algo_type = IWL_MVM_FTM_INITIATOR_ALGO;
deb259
-	}
deb259
-
deb259
-	if (vif->bss_conf.assoc)
deb259
-		memcpy(cmd.range_req_bssid, vif->bss_conf.bssid, ETH_ALEN);
deb259
-	else
deb259
-		eth_broadcast_addr(cmd.range_req_bssid);
deb259
-
deb259
-	err = iwl_mvm_send_cmd_status(mvm, &hcmd, &status);
deb259
-	if (!err && status) {
deb259
-		IWL_ERR(mvm, "FTM range request command failure, status: %u\n",
deb259
-			status);
deb259
-		err = iwl_ftm_range_request_status_to_err(status);
deb259
-	}
deb259
-
deb259
-	if (!err) {
deb259
-		mvm->ftm_initiator.req = req;
deb259
-		mvm->ftm_initiator.req_wdev = ieee80211_vif_to_wdev(vif);
deb259
-	}
deb259
-
deb259
-	return err;
deb259
-}
deb259
-
deb259
-void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req)
deb259
-{
deb259
-	struct iwl_tof_range_abort_cmd cmd = {
deb259
-		.request_id = req->cookie,
deb259
-	};
deb259
-
deb259
-	lockdep_assert_held(&mvm->mutex);
deb259
-
deb259
-	if (req != mvm->ftm_initiator.req)
deb259
-		return;
deb259
-
deb259
-	if (iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_RANGE_ABORT_CMD,
deb259
-						 LOCATION_GROUP, 0),
deb259
-				 0, sizeof(cmd), &cmd))
deb259
-		IWL_ERR(mvm, "failed to abort FTM process\n");
deb259
-}
deb259
-
deb259
-static int iwl_mvm_ftm_find_peer(struct cfg80211_pmsr_request *req,
deb259
-				 const u8 *addr)
deb259
-{
deb259
-	int i;
deb259
-
deb259
-	for (i = 0; i < req->n_peers; i++) {
deb259
-		struct cfg80211_pmsr_request_peer *peer = &req->peers[i];
deb259
-
deb259
-		if (ether_addr_equal_unaligned(peer->addr, addr))
deb259
-			return i;
deb259
-	}
deb259
-
deb259
-	return -ENOENT;
deb259
-}
deb259
-
deb259
-static u64 iwl_mvm_ftm_get_host_time(struct iwl_mvm *mvm, __le32 fw_gp2_ts)
deb259
-{
deb259
-	u32 gp2_ts = le32_to_cpu(fw_gp2_ts);
deb259
-	u32 curr_gp2, diff;
deb259
-	u64 now_from_boot_ns;
deb259
-
deb259
-	iwl_mvm_get_sync_time(mvm, &curr_gp2, &now_from_boot_ns);
deb259
-
deb259
-	if (curr_gp2 >= gp2_ts)
deb259
-		diff = curr_gp2 - gp2_ts;
deb259
-	else
deb259
-		diff = curr_gp2 + (U32_MAX - gp2_ts + 1);
deb259
-
deb259
-	return now_from_boot_ns - (u64)diff * 1000;
deb259
-}
deb259
-
deb259
-static void iwl_mvm_ftm_get_lci_civic(struct iwl_mvm *mvm,
deb259
-				      struct cfg80211_pmsr_result *res)
deb259
-{
deb259
-	struct iwl_mvm_loc_entry *entry;
deb259
-
deb259
-	list_for_each_entry(entry, &mvm->ftm_initiator.loc_list, list) {
deb259
-		if (!ether_addr_equal_unaligned(res->addr, entry->addr))
deb259
-			continue;
deb259
-
deb259
-		if (entry->lci_len) {
deb259
-			res->ftm.lci_len = entry->lci_len;
deb259
-			res->ftm.lci = entry->buf;
deb259
-		}
deb259
-
deb259
-		if (entry->civic_len) {
deb259
-			res->ftm.civicloc_len = entry->civic_len;
deb259
-			res->ftm.civicloc = entry->buf + entry->lci_len;
deb259
-		}
deb259
-
deb259
-		/* we found the entry we needed */
deb259
-		break;
deb259
-	}
deb259
-}
deb259
-
deb259
-void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
deb259
-{
deb259
-	struct iwl_rx_packet *pkt = rxb_addr(rxb);
deb259
-	struct iwl_tof_range_rsp_ntfy *fw_resp = (void *)pkt->data;
deb259
-	int i;
deb259
-
deb259
-	lockdep_assert_held(&mvm->mutex);
deb259
-
deb259
-	if (!mvm->ftm_initiator.req) {
deb259
-		IWL_ERR(mvm, "Got FTM response but have no request?\n");
deb259
-		return;
deb259
-	}
deb259
-
deb259
-	if (fw_resp->request_id != (u8)mvm->ftm_initiator.req->cookie) {
deb259
-		IWL_ERR(mvm, "Request ID mismatch, got %u, active %u\n",
deb259
-			fw_resp->request_id,
deb259
-			(u8)mvm->ftm_initiator.req->cookie);
deb259
-		return;
deb259
-	}
deb259
-
deb259
-	if (fw_resp->num_of_aps > mvm->ftm_initiator.req->n_peers) {
deb259
-		IWL_ERR(mvm, "FTM range response invalid\n");
deb259
-		return;
deb259
-	}
deb259
-
deb259
-	for (i = 0; i < fw_resp->num_of_aps && i < IWL_MVM_TOF_MAX_APS; i++) {
deb259
-		struct iwl_tof_range_rsp_ap_entry_ntfy *fw_ap = &fw_resp->ap[i];
deb259
-		struct cfg80211_pmsr_result result = {};
deb259
-		int peer_idx;
deb259
-
deb259
-		peer_idx = iwl_mvm_ftm_find_peer(mvm->ftm_initiator.req,
deb259
-						 fw_ap->bssid);
deb259
-		if (peer_idx < 0) {
deb259
-			IWL_WARN(mvm,
deb259
-				 "Unknown address (%pM, target #%d) in FTM response.\n",
deb259
-				 fw_ap->bssid, i);
deb259
-			continue;
deb259
-		}
deb259
-
deb259
-		switch (fw_ap->measure_status) {
deb259
-		case IWL_TOF_ENTRY_SUCCESS:
deb259
-			result.status = NL80211_PMSR_STATUS_SUCCESS;
deb259
-			break;
deb259
-		case IWL_TOF_ENTRY_TIMING_MEASURE_TIMEOUT:
deb259
-			result.status = NL80211_PMSR_STATUS_TIMEOUT;
deb259
-			break;
deb259
-		case IWL_TOF_ENTRY_NO_RESPONSE:
deb259
-			result.status = NL80211_PMSR_STATUS_FAILURE;
deb259
-			result.ftm.failure_reason =
deb259
-				NL80211_PMSR_FTM_FAILURE_NO_RESPONSE;
deb259
-			break;
deb259
-		case IWL_TOF_ENTRY_REQUEST_REJECTED:
deb259
-			result.status = NL80211_PMSR_STATUS_FAILURE;
deb259
-			result.ftm.failure_reason =
deb259
-				NL80211_PMSR_FTM_FAILURE_PEER_BUSY;
deb259
-			result.ftm.busy_retry_time = fw_ap->refusal_period;
deb259
-			break;
deb259
-		default:
deb259
-			result.status = NL80211_PMSR_STATUS_FAILURE;
deb259
-			result.ftm.failure_reason =
deb259
-				NL80211_PMSR_FTM_FAILURE_UNSPECIFIED;
deb259
-			break;
deb259
-		}
deb259
-		memcpy(result.addr, fw_ap->bssid, ETH_ALEN);
deb259
-		result.host_time = iwl_mvm_ftm_get_host_time(mvm,
deb259
-							     fw_ap->timestamp);
deb259
-		result.type = NL80211_PMSR_TYPE_FTM;
deb259
-		result.ftm.burst_index = mvm->ftm_initiator.responses[peer_idx];
deb259
-		mvm->ftm_initiator.responses[peer_idx]++;
deb259
-		/*
deb259
-		 * FIXME: the firmware needs to report this, we don't even know
deb259
-		 *        the number of bursts the responder picked (if we asked
deb259
-		 *        it to)
deb259
-		 */
deb259
-		result.final = 0;
deb259
-		result.ftm.rssi_avg = fw_ap->rssi;
deb259
-		result.ftm.rssi_avg_valid = 1;
deb259
-		result.ftm.rssi_spread = fw_ap->rssi_spread;
deb259
-		result.ftm.rssi_spread_valid = 1;
deb259
-		result.ftm.rtt_avg = (s32)le32_to_cpu(fw_ap->rtt);
deb259
-		result.ftm.rtt_avg_valid = 1;
deb259
-		result.ftm.rtt_variance = le32_to_cpu(fw_ap->rtt_variance);
deb259
-		result.ftm.rtt_variance_valid = 1;
deb259
-		result.ftm.rtt_spread = le32_to_cpu(fw_ap->rtt_spread);
deb259
-		result.ftm.rtt_spread_valid = 1;
deb259
-
deb259
-		iwl_mvm_ftm_get_lci_civic(mvm, &result);
deb259
-
deb259
-		cfg80211_pmsr_report(mvm->ftm_initiator.req_wdev,
deb259
-				     mvm->ftm_initiator.req,
deb259
-				     &result, GFP_KERNEL);
deb259
-	}
deb259
-
deb259
-	if (fw_resp->last_in_batch) {
deb259
-		cfg80211_pmsr_complete(mvm->ftm_initiator.req_wdev,
deb259
-				       mvm->ftm_initiator.req,
deb259
-				       GFP_KERNEL);
deb259
-		iwl_mvm_ftm_reset(mvm);
deb259
-	}
deb259
-}
deb259
-
deb259
-void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)
deb259
-{
deb259
-	struct iwl_rx_packet *pkt = rxb_addr(rxb);
deb259
-	const struct ieee80211_mgmt *mgmt = (void *)pkt->data;
deb259
-	size_t len = iwl_rx_packet_payload_len(pkt);
deb259
-	struct iwl_mvm_loc_entry *entry;
deb259
-	const u8 *ies, *lci, *civic, *msr_ie;
deb259
-	size_t ies_len, lci_len = 0, civic_len = 0;
deb259
-	size_t baselen = IEEE80211_MIN_ACTION_SIZE +
deb259
-			 sizeof(mgmt->u.action.u.ftm);
deb259
-	static const u8 rprt_type_lci = IEEE80211_SPCT_MSR_RPRT_TYPE_LCI;
deb259
-	static const u8 rprt_type_civic = IEEE80211_SPCT_MSR_RPRT_TYPE_CIVIC;
deb259
-
deb259
-	if (len <= baselen)
deb259
-		return;
deb259
-
deb259
-	lockdep_assert_held(&mvm->mutex);
deb259
-
deb259
-	ies = mgmt->u.action.u.ftm.variable;
deb259
-	ies_len = len - baselen;
deb259
-
deb259
-	msr_ie = cfg80211_find_ie_match(WLAN_EID_MEASURE_REPORT, ies, ies_len,
deb259
-					&rprt_type_lci, 1, 4);
deb259
-	if (msr_ie) {
deb259
-		lci = msr_ie + 2;
deb259
-		lci_len = msr_ie[1];
deb259
-	}
deb259
-
deb259
-	msr_ie = cfg80211_find_ie_match(WLAN_EID_MEASURE_REPORT, ies, ies_len,
deb259
-					&rprt_type_civic, 1, 4);
deb259
-	if (msr_ie) {
deb259
-		civic = msr_ie + 2;
deb259
-		civic_len = msr_ie[1];
deb259
-	}
deb259
-
deb259
-	entry = kmalloc(sizeof(*entry) + lci_len + civic_len, GFP_KERNEL);
deb259
-	if (!entry)
deb259
-		return;
deb259
-
deb259
-	memcpy(entry->addr, mgmt->bssid, ETH_ALEN);
deb259
-
deb259
-	entry->lci_len = lci_len;
deb259
-	if (lci_len)
deb259
-		memcpy(entry->buf, lci, lci_len);
deb259
-
deb259
-	entry->civic_len = civic_len;
deb259
-	if (civic_len)
deb259
-		memcpy(entry->buf + lci_len, civic, civic_len);
deb259
-
deb259
-	list_add_tail(&entry->list, &mvm->ftm_initiator.loc_list);
deb259
-}
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c	2019-07-25 13:34:40.887336660 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c	2019-07-25 13:56:03.738424271 +0200
deb259
@@ -184,29 +184,6 @@
deb259
 };
deb259
 #endif
deb259
 
deb259
-static const struct cfg80211_pmsr_capabilities iwl_mvm_pmsr_capa = {
deb259
-	.max_peers = IWL_MVM_TOF_MAX_APS,
deb259
-	.report_ap_tsf = 1,
deb259
-	.randomize_mac_addr = 1,
deb259
-
deb259
-	.ftm = {
deb259
-		.supported = 1,
deb259
-		.asap = 1,
deb259
-		.non_asap = 1,
deb259
-		.request_lci = 1,
deb259
-		.request_civicloc = 1,
deb259
-		.max_bursts_exponent = -1, /* all supported */
deb259
-		.max_ftms_per_burst = 0, /* no limits */
deb259
-		.bandwidths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
deb259
-			      BIT(NL80211_CHAN_WIDTH_20) |
deb259
-			      BIT(NL80211_CHAN_WIDTH_40) |
deb259
-			      BIT(NL80211_CHAN_WIDTH_80),
deb259
-		.preambles = BIT(NL80211_PREAMBLE_LEGACY) |
deb259
-			     BIT(NL80211_PREAMBLE_HT) |
deb259
-			     BIT(NL80211_PREAMBLE_VHT),
deb259
-	},
deb259
-};
deb259
-
deb259
 void iwl_mvm_ref(struct iwl_mvm *mvm, enum iwl_mvm_ref_type ref_type)
deb259
 {
deb259
 	if (!iwl_mvm_is_d0i3_supported(mvm))
deb259
@@ -573,11 +550,9 @@
deb259
 	}
deb259
 
deb259
 	if (fw_has_capa(&mvm->fw->ucode_capa,
deb259
-			IWL_UCODE_TLV_CAPA_FTM_CALIBRATED)) {
deb259
+			IWL_UCODE_TLV_CAPA_FTM_CALIBRATED))
deb259
 		wiphy_ext_feature_set(hw->wiphy,
deb259
 				      NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER);
deb259
-		hw->wiphy->pmsr_capa = &iwl_mvm_pmsr_capa;
deb259
-	}
deb259
 
deb259
 	ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
deb259
 	hw->wiphy->features |=
deb259
@@ -1220,8 +1195,6 @@
deb259
 	iwl_mvm_cleanup_roc_te(mvm);
deb259
 	ieee80211_remain_on_channel_expired(mvm->hw);
deb259
 
deb259
-	iwl_mvm_ftm_restart(mvm);
deb259
-
deb259
 	/*
deb259
 	 * cleanup all interfaces, even inactive ones, as some might have
deb259
 	 * gone down during the HW restart
deb259
@@ -5066,31 +5039,6 @@
deb259
 	return 0;
deb259
 }
deb259
 
deb259
-static int iwl_mvm_start_pmsr(struct ieee80211_hw *hw,
deb259
-			      struct ieee80211_vif *vif,
deb259
-			      struct cfg80211_pmsr_request *request)
deb259
-{
deb259
-	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
deb259
-	int ret;
deb259
-
deb259
-	mutex_lock(&mvm->mutex);
deb259
-	ret = iwl_mvm_ftm_start(mvm, vif, request);
deb259
-	mutex_unlock(&mvm->mutex);
deb259
-
deb259
-	return ret;
deb259
-}
deb259
-
deb259
-static void iwl_mvm_abort_pmsr(struct ieee80211_hw *hw,
deb259
-			       struct ieee80211_vif *vif,
deb259
-			       struct cfg80211_pmsr_request *request)
deb259
-{
deb259
-	struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
deb259
-
deb259
-	mutex_lock(&mvm->mutex);
deb259
-	iwl_mvm_ftm_abort(mvm, request);
deb259
-	mutex_unlock(&mvm->mutex);
deb259
-}
deb259
-
deb259
 static bool iwl_mvm_can_hw_csum(struct sk_buff *skb)
deb259
 {
deb259
 	u8 protocol = ip_hdr(skb)->protocol;
deb259
@@ -5196,8 +5144,6 @@
deb259
 	.get_survey = iwl_mvm_mac_get_survey,
deb259
 	.sta_statistics = iwl_mvm_mac_sta_statistics,
deb259
 	.get_ftm_responder_stats = iwl_mvm_mac_get_ftm_responder_stats,
deb259
-	.start_pmsr = iwl_mvm_start_pmsr,
deb259
-	.abort_pmsr = iwl_mvm_abort_pmsr,
deb259
 
deb259
 	.can_aggregate_in_amsdu = iwl_mvm_mac_can_aggregate,
deb259
 #ifdef CONFIG_IWLWIFI_DEBUGFS
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h	2019-06-27 14:54:04.136678301 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h	2019-07-25 13:56:03.739424257 +0200
deb259
@@ -1154,12 +1154,6 @@
deb259
 	struct ieee80211_cipher_scheme cs[IWL_UCODE_MAX_CS];
deb259
 
deb259
 	struct cfg80211_ftm_responder_stats ftm_resp_stats;
deb259
-	struct {
deb259
-		struct cfg80211_pmsr_request *req;
deb259
-		struct wireless_dev *req_wdev;
deb259
-		struct list_head loc_list;
deb259
-		int responses[IWL_MVM_TOF_MAX_APS];
deb259
-	} ftm_initiator;
deb259
 
deb259
 	struct ieee80211_vif *nan_vif;
deb259
 #define IWL_MAX_BAID	32
deb259
@@ -2077,16 +2071,6 @@
deb259
 void iwl_mvm_ftm_responder_stats(struct iwl_mvm *mvm,
deb259
 				 struct iwl_rx_cmd_buffer *rxb);
deb259
 
deb259
-/* FTM initiator */
deb259
-void iwl_mvm_ftm_restart(struct iwl_mvm *mvm);
deb259
-void iwl_mvm_ftm_range_resp(struct iwl_mvm *mvm,
deb259
-			    struct iwl_rx_cmd_buffer *rxb);
deb259
-void iwl_mvm_ftm_lc_notif(struct iwl_mvm *mvm,
deb259
-			  struct iwl_rx_cmd_buffer *rxb);
deb259
-int iwl_mvm_ftm_start(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
deb259
-		      struct cfg80211_pmsr_request *request);
deb259
-void iwl_mvm_ftm_abort(struct iwl_mvm *mvm, struct cfg80211_pmsr_request *req);
deb259
-
deb259
 /* TDLS */
deb259
 
deb259
 /*
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/mvm/ops.c	2019-07-25 13:55:50.589601396 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/mvm/ops.c	2019-07-25 13:56:03.739424257 +0200
deb259
@@ -302,12 +302,6 @@
deb259
 		   RX_HANDLER_SYNC),
deb259
 	RX_HANDLER_GRP(LOCATION_GROUP, TOF_RESPONDER_STATS,
deb259
 		       iwl_mvm_ftm_responder_stats, RX_HANDLER_ASYNC_LOCKED),
deb259
-
deb259
-	RX_HANDLER_GRP(LOCATION_GROUP, TOF_RANGE_RESPONSE_NOTIF,
deb259
-		       iwl_mvm_ftm_range_resp, RX_HANDLER_ASYNC_LOCKED),
deb259
-	RX_HANDLER_GRP(LOCATION_GROUP, TOF_LC_NOTIF,
deb259
-		       iwl_mvm_ftm_lc_notif, RX_HANDLER_ASYNC_LOCKED),
deb259
-
deb259
 	RX_HANDLER_GRP(DEBUG_GROUP, MFU_ASSERT_DUMP_NTF,
deb259
 		       iwl_mvm_mfu_assert_dump_notif, RX_HANDLER_SYNC),
deb259
 	RX_HANDLER_GRP(PROT_OFFLOAD_GROUP, STORED_BEACON_NTF,
deb259
@@ -706,7 +700,6 @@
deb259
 	INIT_LIST_HEAD(&mvm->aux_roc_te_list);
deb259
 	INIT_LIST_HEAD(&mvm->async_handlers_list);
deb259
 	spin_lock_init(&mvm->time_event_lock);
deb259
-	INIT_LIST_HEAD(&mvm->ftm_initiator.loc_list);
deb259
 
deb259
 	INIT_WORK(&mvm->async_handlers_wk, iwl_mvm_async_handlers_wk);
deb259
 	INIT_WORK(&mvm->roc_done_wk, iwl_mvm_roc_done_wk);