History log of /linux-master/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
Revision Date Author Comments
# dbfff5bf 15-Apr-2024 Avraham Stern <avraham.stern@intel.com>

wifi: iwlwifi: mvm: remove old PASN station when adding a new one

If a PASN station is added, and an old PASN station already exists
for the same mac address, remove the old station before adding the
new one. Keeping the old station caueses old security context to
be used in measurements.

Fixes: 0739a7d70e00 ("iwlwifi: mvm: initiator: add option for adding a PASN responder")
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240415114847.ef3544a416f2.I4e8c7c8ca22737f4f908ae5cd4fc0b920c703dd3@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 137d33ac 29-Jan-2024 Ilan Peer <ilan.peer@intel.com>

wifi: iwlwifi: mvm: Fix FTM initiator flags

When secure LTF is used MFP must also be set.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Avraham Stern <avraham.stern@intel.com>
Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240129211905.6cad71069e87.I7f9fd5239cfd2244f155f88419980e6e91d00ff2@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 44fa698c 12-Jun-2023 Avraham Stern <avraham.stern@intel.com>

wifi: iwlwifi: mvm: FTM initiator MLO support

When checking if the initiator is associated to the responder,
iterate over all active links.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230612184434.1737f26e9cf7.I8f140ca55094da1d73c387fc036394fb2c148c85@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 8b4580ab 06-Jun-2023 Johannes Berg <johannes.berg@intel.com>

Revert "wifi: iwlwifi: mvm: FTM initiator MLO support"

This reverts commit 1bcbb1208e9a ("wifi: iwlwifi: mvm: FTM
initiator MLO support") as it causes a merge conflict, and
we can defer and re-do those changes later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 1bcbb120 31-May-2023 Avraham Stern <avraham.stern@intel.com>

wifi: iwlwifi: mvm: FTM initiator MLO support

When checking if the initiator is associated to the responder,
iterate over all active links.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230531194629.a0d86655e7d2.I8f140ca55094da1d73c387fc036394fb2c148c85@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 68182662 13-May-2023 Gregory Greenman <gregory.greenman@intel.com>

wifi: iwlwifi: mvm: fix access to fw_id_to_mac_id

RCU protected fw_id_to_mac_id can be initialized with either
an error code or NULL. Thus, after dereferencing need to check
the value with IS_ERR_OR_NULL() and not only that it is not NULL.
Fix it.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230514120631.ec5f2880e81c.Ifa8c0f451df2835bde800f5c3670cc46238a3bd8@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 26c680b7 13-Apr-2023 Avraham Stern <avraham.stern@intel.com>

wifi: iwlwifi: mvm: make HLTK configuration for PASN station optional

When secure LTF is not used, the HLTK is not derived during the PASN
authentication. Make the HLTK optional when adding a PASN station.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230413213309.a57f7f3b59bd.Ifa88afb51a2516156153ac321d81556e295036c2@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 650cadb7 28-Mar-2023 Gregory Greenman <gregory.greenman@intel.com>

wifi: iwlwifi: mvm: vif preparation for MLO

In MLO, some fields of iwl_mvm_vif should be defined in the
context of a link. Define a separate structure for these fields and
add a deflink object to hold it as part of iwl_mvm_vif. Non-MLO legacy
code will use only deflink object while MLO related code will use the
corresponding link from the link array.

It follows the strategy applied in mac80211 for introducing MLO
changes.

The below spatch takes care of updating all driver code to access
fields separated into MLD specific data structure via deflink (need
to convert all references to the fields listed in var to deflink.var
and also to take care of calls like iwl_mvm_vif_from_mac80211(vif)->field).

@iwl_mld_vif@
struct iwl_mvm_vif *v;
struct ieee80211_vif *vv;
identifier fn;
identifier var = {bssid, ap_sta_id, bcast_sta, mcast_sta,
beacon_stats, smps_requests, probe_resp_data,
he_ru_2mhz_block, cab_queue, phy_ctxt,
queue_params};
@@

(
v->
- var
+ deflink.var
|
fn(vv)->
- var
+ deflink.var
)

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230328104948.4896576f0a9f.Ifaf0187c96b9fe52b24bd629331165831a877691@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 4de5ceef 26-Jan-2023 Tom Rix <trix@redhat.com>

wifi: iwlwifi: mvm: remove h from printk format specifier

This change fixes the checkpatch warning described in this commit
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
unnecessary %h[xudi] and %hh[xudi]")

Standard integer promotion is already done and %hx and %hhx is useless
so do not encourage the use of %hh[xudi] or %h[xudi].

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20230127002430.a25158d58fd7.Ibfe217f12a63c1d5349218e74c4b802c70c13c7c@changeid
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>


# 6d7cb4a6 05-Dec-2022 Jakob Koschel <jakobkoschel@gmail.com>

wifi: iwlwifi: mvm: replace usage of found with dedicated list iterator variable

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable instead of a
found boolean [1].

This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.

While at it, stop using the unnecessary _safe() variant.

[1] https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/

Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
[change to not use _safe variant]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20221205102808.e4882dc35543.I32b2b945ba234de72ee119fc20f5b8be02b6a3f2@changeid


# 7819b3d1 11-Jul-2022 Justin Stitt <justinstitt@google.com>

wifi: iwlwifi: mvm: fix clang -Wformat warnings

When building with Clang we encounter these warnings:
| drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:1108:47: error:
| format specifies type 'unsigned char' but the argument has type 's16'
| (aka 'short') [-Werror,-Wformat] IWL_DEBUG_INFO(mvm, "\tburst index:
| %hhu\n", res->ftm.burst_index);
-
| drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:1111:47: error:
| format specifies type 'unsigned char' but the argument has type 's32'
| (aka 'int') [-Werror,-Wformat] IWL_DEBUG_INFO(mvm, "\trssi spread:
| %hhu\n", res->ftm.rssi_spread);

The previous format specifier `%hhu` describes a u8 but our arguments
are wider than this which means bits are potentially being lost.

Variadic functions (printf-like) undergo default argument promotion.
Documentation/core-api/printk-formats.rst specifically recommends using
the promoted-to-type's format flag.

As per C11 6.3.1.1:
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf) `If an int
can represent all values of the original type ..., the value is
converted to an int; otherwise, it is converted to an unsigned int.
These are called the integer promotions.` Thus it makes sense to change
`%hhu` to `%d` for both instances of the warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220711222919.2043613-1-justinstitt@google.com


# f276e20b 10-May-2022 Johannes Berg <johannes.berg@intel.com>

wifi: mac80211: move interface config to new struct

We'll use bss_conf for per-link configuration later, so
move out all the non-link-specific data out into a new
struct ieee80211_vif_cfg used in the vif.

Some adjustments were done with the following spatch:

@@
expression sdata;
struct ieee80211_vif *vifp;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
(
-sdata->vif.bss_conf.var
+sdata->vif.cfg.var
|
-vifp->bss_conf.var
+vifp->cfg.var
)

@bss_conf@
struct ieee80211_bss_conf *bss_conf;
identifier var = { assoc, ibss_joined, aid, arp_addr_list, arp_addr_cnt, ssid, ssid_len, s1g, ibss_creator };
@@
-bss_conf->var
+vif_cfg->var

(though more manual fixups were needed, e.g. replacing
"vif_cfg->" by "vif->cfg." in many files.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>


# 971cbe50 28-Jan-2022 Johannes Berg <johannes.berg@intel.com>

iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id

Instead of taking the group/command separately, make the function
take a combined command ID. In many cases, this allows us to pass
an existing command ID (e.g. cmd.id), or introduce a new variable
for it, so that we don't use the command ID twice.

This way, we can also use LONG_GROUP implicitly, so we don't need
to spell that out for many commands.

Apart from mvm.h, fw/img.{c,h} changes and some copyright and
indentation updates, this was done with spatch:

@@
identifier cmd;
expression fw, G, C, def;
@@
struct iwl_host_cmd cmd = {
.id = WIDE_ID(G, C),
...
};
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)

@@
identifier cmd;
expression fw, C, def;
@@
struct iwl_host_cmd cmd = {
.id = C,
...
};
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd.id, def)

@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = WIDE_ID(G, C);
...
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}

@@
identifier func;
expression fw, G, C, mvm, flags, cmd, size, def;
type rettype;
@@
rettype func(...)
{
+u32 cmd_id = C;
...
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
...
-iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
+iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
...
}

@@
expression fw, C, def;
@@
-iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
+iwl_fw_lookup_cmd_ver(fw, C, def)

@@
expression fw, C, G, def;
@@
-iwl_fw_lookup_cmd_ver(fw, G, C, def)
+iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# f0c86427 28-Jan-2022 Johannes Berg <johannes.berg@intel.com>

iwlwifi: prefer WIDE_ID() over iwl_cmd_id()

The order of arguments for iwl_cmd_id() is confusing, and the
version is always 0 and thus a useless argument. Prefer the
WIDE_ID() macro (which needs to be a macro due to use in switch
cases etc.) over the iwl_cmd_id() function.

Obviously done with spatch:

@@
expression G, C;
@@
-iwl_cmd_id(C, G, 0)
+WIDE_ID(G, C)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220128153014.cc4f9d1a2e9b.Ieb023cd773ea22e819d1ef1c37ae857ecc1a839d@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 4ccdcc8f 27-Dec-2021 Nathan Chancellor <nathan@kernel.org>

iwlwifi: mvm: Use div_s64 instead of do_div in iwl_mvm_ftm_rtt_smoothing()

When building ARCH=arm allmodconfig:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c: In function ‘iwl_mvm_ftm_rtt_smoothing’:
./include/asm-generic/div64.h:222:35: error: comparison of distinct pointer types lacks a cast [-Werror]
222 | (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
| ^~
drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:1070:9: note: in expansion of macro ‘do_div’
1070 | do_div(rtt_avg, 100);
| ^~~~~~

do_div() has to be used with an unsigned 64-bit integer dividend but
rtt_avg is a signed 64-bit integer.

div_s64() expects a signed 64-bit integer dividend and signed 32-bit
divisor, which fits this scenario, so use that function here to fix the
warning.

Fixes: 8b0f92549f2c ("iwlwifi: mvm: fix 32-bit build in FTM")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211227191757.2354329-1-nathan@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>


# 6bb2ea37 19-Dec-2021 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: set protected flag only for NDP ranging

Don't use protected ranging negotiation for FTM ranging as responders
that support only FTM ranging don't expect the FTM request to be
protected.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Fixes: 517a5eb9fab2 ("iwlwifi: mvm: when associated with PMF, use protected NDP ranging negotiation")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211219132536.f50ed0e3c6b3.Ibff247ee9d4e6e0a1a2d08a3c8a4bbb37e6829dd@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 8b0f9254 19-Dec-2021 Johannes Berg <johannes.berg@intel.com>

iwlwifi: mvm: fix 32-bit build in FTM

On a 32-bit build, the division here needs to be done
using do_div(), otherwise the compiler will try to call
a function that doesn't exist, thus failing to build.

Fixes: b68bd2e3143a ("iwlwifi: mvm: Add FTM initiator RTT smoothing logic")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211219111352.e56cbf614a4d.Ib98004ccd2c7a55fd883a8ea7eebd810f406dec6@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# bd8b5f30 16-Oct-2021 Miri Korenblit <miriam.rachel.korenblit@intel.com>

iwlwifi: mvm: Support new version of ranging response notification

As part of the new rate_n_flags, FW added a new version for
LOCATION_RANGE_RSP_NTFY, and it's internal structure -
LOCATION_RANGE_RSP_AP_ETRY_NTFY. Add support for this.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211017123741.c5c6c863631e.I4b493f4eeabbfa1dc965ae012b72fc57de7d5f4f@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 8a2c1516 17-Oct-2021 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for 160Mhz in ranging measurements

Add support for 160Mhz bandwidth in ranging measurements for
initiator and responder. Advertise 160Mhz in the supported
bandwidths for ranging.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20211017113927.32a13ac0f4d4.I883492648518cc5067a2f91b7ecf8bfa55f6876a@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 830aa3e7 26-Aug-2021 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for range request command version 13

This version adds the following configuration options:
1. Set the BSS color for NDP ranging
2. Set the minimum and maximum time between measurements for
non trigger based NDP ranging.
3. Terminate the session in case the responder requests LMR feedback.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210826224715.9dcd5210b7e5.I76f6977cde852de0f251344e279ad85076eef8d6@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 5c1f0942 17-Jun-2021 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: support LMR feedback

If the LMR feedback is set in the ranging request, set the
corresponding flag in the fw command.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210617100544.0c00dd724f5c.I8283b95c26f4226deaea42e7be35aa9d41eb7580@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# c4ae8b9d 12-Jun-2021 Luca Coelho <luciano.coelho@intel.com>

iwlwifi: mvm: pass the clock type to iwl_mvm_get_sync_time()

Allow the caller to pass the clock type to iwl_mvm_get_sync_time() so
callers with different needs can decide whether to use boottime or
realtime.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210612142637.093f6660e69b.Ifd2328ac2130269f729c9c1bceec44ba01d79e88@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 517a5eb9 30-Mar-2021 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: when associated with PMF, use protected NDP ranging negotiation

When associated to the resonder with PMF, request to protect the NDP
ranging negotiation with PMF.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210331121101.e7982c72e12b.Ib6db362d01a31132c638e194d49476cd8e3ff430@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 9896b0b9 30-Mar-2021 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: support range request command version 12

Version 12 adds configuration of NDP ranging parameters:
- max number of LTF repetitions
- max number of spatial streams
- max total LTFs

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210330162204.2c30c376c5cf.I01460f7277594ee7c98a8e1fe5447c59e70bf073@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 27eeb037 09-Dec-2020 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add size checks for range response notification

The range response notification has several versions. Check the
notification size according to the expected notification version.
Notifications with incorrect size will be ignored.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201209231352.ee57c3214d05.I810d7de33fb08001ef1a2e24714d5b68932e088e@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 8e99ea8d 09-Dec-2020 Johannes Berg <johannes.berg@intel.com>

iwlwifi: use SPDX tags

Use SPDX tags instead of the long copyright notices. Also cleanup
some duplicate copyright notices and combine the years where possible.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201210000603.481bcb512a6f.I8146abe5a637079e7336209f23cb26af98b12b31@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 0739a7d7 30-Sep-2020 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: initiator: add option for adding a PASN responder

Add an option for adding a PASN responder, specifying the HLTK and
TK (if not associated). When a receiving a range request for a
PASN responder, the driver will ask for a secured measurement with
the specified HLTK and TK.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200930161256.28c5f5266000.I2d58b72ff92c47ac33a6aacc27fbf3790b6dfc51@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# b68bd2e3 30-Sep-2020 Ilan Peer <ilan.peer@intel.com>

iwlwifi: mvm: Add FTM initiator RTT smoothing logic

The overcome instabilities in the RTT results add smoothing logic
to the reported results. In short, the smoothing logic tracks the
RTT average of each responder for a period of time, and in case
a new RTT results is found to be a spur, the tracked RTT average
is reported instead of the current RTT measurement.

Smooth logic debug configuration using iwl-dbg-cfg.ini:

- MVM_FTM_INITIATOR_ENABLE_SMOOTH: Set to 1 to enable smoothing logic
(default=0).
- MVM_FTM_INITIATOR_SMOOTH_ALPHA: A value between 0 - 100, defining
the weight of the current RTT results vs. the RTT average tracked
based on the previous results. A value of 100 means use only the
current RTT results.
- MVM_FTM_INITIATOR_SMOOTH_AGE_SEC: The maximal time in seconds in which
the RTT average tracked based on previous results is considered valid.
- MVM_FTM_INITIATOR_SMOOTH_UNDERSHOOT: if the current RTT is positive
and below the RTT average by at least this value, report the average
RTT instead of the current one. In units of picoseconds.
- MVM_FTM_INITIATOR_SMOOTH_OVERSHOOT: if the current RTT is positive
and above the RTT average by at least this value, report the average
RTT instead of the current one. In units of picoseconds.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200930161256.48a9cec2081b.Iaec1e29f738232adfe9e2ea8e9eb9b6ff0323ae1@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 1c096d89 27-Sep-2020 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for range request command ver 11

Version 11 of the range request command adds support for setting
the PN for secure ranging. For now, this is not yet supported.

The same functions that are used for version 9 and 10 are also
used for version 11 as the common part is the same.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200928121852.6f9ed4140e8c.I046e0d9f6dfaafda9794e5eb2ee1f02fcad2851a@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# e80bfd11 27-Sep-2020 Mordechay Goodstein <mordechay.goodstein@intel.com>

iwlwifi: fw: add default value for iwl_fw_lookup_cmd_ver

For new APIs this avoids checking every return if it's
IWL_FW_CMD_VER_UNKNOWN (99) or it's lower than the new API value

Done with spatch:
-iwl_fw_lookup_cmd_ver(E1, E2, E3)
+iwl_fw_lookup_cmd_ver(E1, E2, E3, IWL_FW_CMD_VER_UNKNOWN)

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200928121852.70bec6eb8008.I6ea78553801d33f7ed10fcd2e4be4ba781fe469a@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 018971b1 29-May-2020 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for range request version 10

Range request version 10 keeps the same command size as version 9
but uses 2 reserved fields for the responder beacon interval and
station id (if exists).
For now, since the beacon interval of unassoc APs is unknown, use
a value of 100 TUs which is a common value for many APs.

While at it, remove the definition for CCMP_256 cipher, since this
is not supported.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200529092401.b7ccdad0805f.I59ea7f773caed85a66c61401066ae169008442e6@changeid


# f092e4e3 24-Apr-2020 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for range request command version 9

This version adds support for per responder calibrations.
Currently the driver will use a single value for all responders
and bandwidths.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200424182644.5ce74a87009c.I9079332b21eef490bbdbf8d7d66e35d7d0c7882b@changeid


# 4af11950 21-Apr-2020 Mordechay Goodstein <mordechay.goodstein@intel.com>

iwlwifi: move API version lookup to common code

The API version lookup is parsed from a TLV and should be in shared code
make make it reusable across all opmodes.

Also change the function names from mvm to fw, since this is not
mvm-specific anymore.

Additionally, since this function is not just a single line of code, it
shouldn't be inline. Convert them to actual functions.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200421133326.cf94672dfcdb.I5ede9cc25ee8de7b8d2b5c574f917a18971da734@changeid


# 6815e3d0 05-Oct-2019 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for non EDCA based measurements

Add support for requesting trigger-based / non trigger-based
measurements.

Change-Id: Ib4d0c471da9c50d9981541a7f5926db384a0f7ce
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# cc4255ef 31-Jan-2020 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: avoid use after free for pmsr request

When a FTM request is aborted, the driver sends the abort command to
the fw and waits for a response. When the response arrives, the driver
calls cfg80211_pmsr_complete() for that request.
However, cfg80211 frees the requested data immediately after sending
the abort command, so this may lead to use after free.

Fix it by clearing the request data in the driver when the abort
command arrives and ignoring the fw notification that will come
afterwards.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Fixes: fc36ffda3267 ("iwlwifi: mvm: support FTM initiator")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# b59ec4ca 01-Oct-2019 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for location range request version 8

The new API requires the driver to set the frame format
(legacy, HT, VHT etc.) to be used for the measurement.

The new API also supports 11az and secured measurement, but
these are not supported by the driver for now.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 9285ec4c 21-Jun-2019 Jason A. Donenfeld <Jason@zx2c4.com>

timekeeping: Use proper clock specifier names in functions

This makes boot uniformly boottime and tai uniformly clocktai, to
address the remaining oversights.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lkml.kernel.org/r/20190621203249.3909-2-Jason@zx2c4.com


# cec2d4f6 12-Mar-2019 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: report FTM start time TSF when applicable

When the interface that is requesting an FTM measurement is connected
to a BSS, it is possible that the FTM request was originated by an
RRM request from the AP. In this case the station needs to report
the measurement start time in terms of the TSF of the AP.

Since there is no indication in the FTM request itself if the TSF
is needed, always report the TSF if the station is associated.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 957a67c8 25-Feb-2019 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: support rtt confidence indication

The range response notification API has changed to add a value that
indicates the confidence of the rtt result.
Support the new API and print the rtt confidence for debug.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# 688cd8bd 04-Mar-2019 Arnd Bergmann <arnd@arndb.de>

iwlwifi: fix 64-bit division

do_div() expects unsigned operands and otherwise triggers a warning like:

drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c:465:2: error: comparison of distinct pointer types ('typeof ((rtt_avg)) *' (aka 'long long *') and 'uint64_t *' (aka 'unsigned long long *')) [-Werror,-Wcompare-distinct-pointer-types]
do_div(rtt_avg, 6666);
^~~~~~~~~~~~~~~~~~~~~
include/asm-generic/div64.h:222:28: note: expanded from macro 'do_div'
(void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
1 error generated.

Change the do_div() to the simpler div_s64() that can handle
negative inputs correctly.

Fixes: 937b10c0de68 ("iwlwifi: mvm: add debug prints for FTM")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>


# 937b10c0 10-Jan-2019 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add debug prints for FTM

Add debug prints for FTM results info. These prints are used by
tests automation.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# ff418fee 07-Jan-2019 Avraham Stern <avraham.stern@intel.com>

iwlwifi: mvm: add support for new FTM fw API

The FTM new API uses API TLV bit 15. The driver mistakenly uses
this bit for beacon filter API, although no TLV was assigned for
the beacon filter API. For now, make beacon filter use bit 16
instead (not set by the fw anyway). Once a TLV is assigned to the
beacon filter API it should be updated.

Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>


# fc36ffda 05-Dec-2018 Johannes Berg <johannes.berg@intel.com>

iwlwifi: mvm: support FTM initiator

Add support for FTM initiator, i.e. peer measurements with FTM
if the firmware supports FTM.

Additionally, add two defines we depend on in
include/linux/ieee80211.h.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>