hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/wireless/intel/iwlwifi/mvm/tdls.c
....@@ -7,7 +7,7 @@
77 *
88 * Copyright(c) 2014 Intel Mobile Communications GmbH
99 * Copyright(c) 2017 Intel Deutschland GmbH
10
- * Copyright(C) 2018 Intel Corporation
10
+ * Copyright(C) 2018 - 2020 Intel Corporation
1111 *
1212 * This program is free software; you can redistribute it and/or modify
1313 * it under the terms of version 2 of the GNU General Public License as
....@@ -17,9 +17,6 @@
1717 * WITHOUT ANY WARRANTY; without even the implied warranty of
1818 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1919 * General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program.
2320 *
2421 * The full GNU General Public License is included in this distribution
2522 * in the file called COPYING.
....@@ -32,7 +29,7 @@
3229 *
3330 * Copyright(c) 2014 Intel Mobile Communications GmbH
3431 * Copyright(c) 2017 Intel Deutschland GmbH
35
- * Copyright(C) 2018 Intel Corporation
32
+ * Copyright(C) 2018 - 2020 Intel Corporation
3633 * All rights reserved.
3734 *
3835 * Redistribution and use in source and binary forms, with or without
....@@ -80,7 +77,7 @@
8077
8178 lockdep_assert_held(&mvm->mutex);
8279
83
- for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) {
80
+ for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
8481 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
8582 lockdep_is_held(&mvm->mutex));
8683 if (!sta || IS_ERR(sta) || !sta->tdls)
....@@ -103,7 +100,7 @@
103100
104101 lockdep_assert_held(&mvm->mutex);
105102
106
- for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) {
103
+ for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
107104 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
108105 lockdep_is_held(&mvm->mutex));
109106 if (!sta || IS_ERR(sta) || !sta->tdls)
....@@ -147,7 +144,7 @@
147144
148145 /* populate TDLS peer data */
149146 cnt = 0;
150
- for (i = 0; i < ARRAY_SIZE(mvm->fw_id_to_mac_id); i++) {
147
+ for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
151148 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
152149 lockdep_is_held(&mvm->mutex));
153150 if (IS_ERR_OR_NULL(sta) || !sta->tdls)
....@@ -208,19 +205,16 @@
208205 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
209206 u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int;
210207
211
- /*
212
- * iwl_mvm_protect_session() reads directly from the device
213
- * (the system time), so make sure it is available.
214
- */
215
- if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PROTECT_TDLS))
216
- return;
217
-
218
- mutex_lock(&mvm->mutex);
219208 /* Protect the session to hear the TDLS setup response on the channel */
220
- iwl_mvm_protect_session(mvm, vif, duration, duration, 100, true);
209
+ mutex_lock(&mvm->mutex);
210
+ if (fw_has_capa(&mvm->fw->ucode_capa,
211
+ IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD))
212
+ iwl_mvm_schedule_session_protection(mvm, vif, duration,
213
+ duration, true);
214
+ else
215
+ iwl_mvm_protect_session(mvm, vif, duration,
216
+ duration, 100, true);
221217 mutex_unlock(&mvm->mutex);
222
-
223
- iwl_mvm_unref(mvm, IWL_MVM_REF_PROTECT_TDLS);
224218 }
225219
226220 static const char *
....@@ -255,8 +249,7 @@
255249
256250 /* we only send requests to our switching peer - update sent time */
257251 if (state == IWL_MVM_TDLS_SW_REQ_SENT)
258
- mvm->tdls_cs.peer.sent_timestamp =
259
- iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG);
252
+ mvm->tdls_cs.peer.sent_timestamp = iwl_mvm_get_systime(mvm);
260253
261254 if (state == IWL_MVM_TDLS_SW_IDLE)
262255 mvm->tdls_cs.cur_sta_id = IWL_MVM_INVALID_STA;
....@@ -280,7 +273,7 @@
280273 return;
281274 }
282275
283
- if (WARN_ON(sta_id >= IWL_MVM_STATION_COUNT))
276
+ if (WARN_ON(sta_id >= mvm->fw->ucode_capa.num_stations))
284277 return;
285278
286279 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
....@@ -402,6 +395,9 @@
402395 struct ieee80211_tx_info *info;
403396 struct ieee80211_hdr *hdr;
404397 struct iwl_tdls_channel_switch_cmd cmd = {0};
398
+ struct iwl_tdls_channel_switch_cmd_tail *tail =
399
+ iwl_mvm_chan_info_cmd_tail(mvm, &cmd.ci);
400
+ u16 len = sizeof(cmd) - iwl_mvm_chan_info_padding(mvm);
405401 int ret;
406402
407403 lockdep_assert_held(&mvm->mutex);
....@@ -417,9 +413,9 @@
417413 }
418414
419415 cmd.switch_type = type;
420
- cmd.timing.frame_timestamp = cpu_to_le32(timestamp);
421
- cmd.timing.switch_time = cpu_to_le32(switch_time);
422
- cmd.timing.switch_timeout = cpu_to_le32(switch_timeout);
416
+ tail->timing.frame_timestamp = cpu_to_le32(timestamp);
417
+ tail->timing.switch_time = cpu_to_le32(switch_time);
418
+ tail->timing.switch_timeout = cpu_to_le32(switch_timeout);
423419
424420 rcu_read_lock();
425421 sta = ieee80211_find_sta(vif, peer);
....@@ -451,21 +447,16 @@
451447 }
452448 }
453449
454
- if (chandef) {
455
- cmd.ci.band = (chandef->chan->band == NL80211_BAND_2GHZ ?
456
- PHY_BAND_24 : PHY_BAND_5);
457
- cmd.ci.channel = chandef->chan->hw_value;
458
- cmd.ci.width = iwl_mvm_get_channel_width(chandef);
459
- cmd.ci.ctrl_pos = iwl_mvm_get_ctrl_pos(chandef);
460
- }
450
+ if (chandef)
451
+ iwl_mvm_set_chan_info_chandef(mvm, &cmd.ci, chandef);
461452
462453 /* keep quota calculation simple for now - 50% of DTIM for TDLS */
463
- cmd.timing.max_offchan_duration =
454
+ tail->timing.max_offchan_duration =
464455 cpu_to_le32(TU_TO_US(vif->bss_conf.dtim_period *
465456 vif->bss_conf.beacon_int) / 2);
466457
467458 /* Switch time is the first element in the switch-timing IE. */
468
- cmd.frame.switch_time_offset = cpu_to_le32(ch_sw_tm_ie + 2);
459
+ tail->frame.switch_time_offset = cpu_to_le32(ch_sw_tm_ie + 2);
469460
470461 info = IEEE80211_SKB_CB(skb);
471462 hdr = (void *)skb->data;
....@@ -475,20 +466,19 @@
475466 ret = -EINVAL;
476467 goto out;
477468 }
478
- iwl_mvm_set_tx_cmd_ccmp(info, &cmd.frame.tx_cmd);
469
+ iwl_mvm_set_tx_cmd_ccmp(info, &tail->frame.tx_cmd);
479470 }
480471
481
- iwl_mvm_set_tx_cmd(mvm, skb, &cmd.frame.tx_cmd, info,
472
+ iwl_mvm_set_tx_cmd(mvm, skb, &tail->frame.tx_cmd, info,
482473 mvmsta->sta_id);
483474
484
- iwl_mvm_set_tx_cmd_rate(mvm, &cmd.frame.tx_cmd, info, sta,
475
+ iwl_mvm_set_tx_cmd_rate(mvm, &tail->frame.tx_cmd, info, sta,
485476 hdr->frame_control);
486477 rcu_read_unlock();
487478
488
- memcpy(cmd.frame.data, skb->data, skb->len);
479
+ memcpy(tail->frame.data, skb->data, skb->len);
489480
490
- ret = iwl_mvm_send_cmd_pdu(mvm, TDLS_CHANNEL_SWITCH_CMD, 0,
491
- sizeof(cmd), &cmd);
481
+ ret = iwl_mvm_send_cmd_pdu(mvm, TDLS_CHANNEL_SWITCH_CMD, 0, len, &cmd);
492482 if (ret) {
493483 IWL_ERR(mvm, "Failed to send TDLS_CHANNEL_SWITCH cmd: %d\n",
494484 ret);