1 /******************************************************************************
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
24 * The full GNU General Public License is included in this distribution
25 * in the file called COPYING.
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
33 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 *****************************************************************************/
63 #include <linux/kernel.h>
64 #include <linux/slab.h>
65 #include <linux/skbuff.h>
66 #include <linux/netdevice.h>
67 #include <linux/etherdevice.h>
69 #include <linux/if_arp.h>
70 #include <net/mac80211.h>
71 #include <net/ieee80211_radiotap.h>
74 #include "iwl-op-mode.h"
78 #include "time-event.h"
79 #include "iwl-eeprom-parse.h"
80 #include "fw-api-scan.h"
81 #include "iwl-phy-db.h"
83 #include "iwl-fw-error-dump.h"
86 static const struct ieee80211_iface_limit iwl_mvm_limits
[] = {
89 .types
= BIT(NL80211_IFTYPE_STATION
),
93 .types
= BIT(NL80211_IFTYPE_AP
) |
94 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
95 BIT(NL80211_IFTYPE_P2P_GO
),
99 .types
= BIT(NL80211_IFTYPE_P2P_DEVICE
),
103 static const struct ieee80211_iface_combination iwl_mvm_iface_combinations
[] = {
105 .num_different_channels
= 1,
107 .limits
= iwl_mvm_limits
,
108 .n_limits
= ARRAY_SIZE(iwl_mvm_limits
),
112 #ifdef CONFIG_PM_SLEEP
113 static const struct nl80211_wowlan_tcp_data_token_feature
114 iwl_mvm_wowlan_tcp_token_feature
= {
117 .bufsize
= IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS
,
120 static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support
= {
121 .tok
= &iwl_mvm_wowlan_tcp_token_feature
,
122 .data_payload_max
= IWL_WOWLAN_TCP_MAX_PACKET_LEN
-
123 sizeof(struct ethhdr
) -
124 sizeof(struct iphdr
) -
125 sizeof(struct tcphdr
),
126 .data_interval_max
= 65535, /* __le16 in API */
127 .wake_payload_max
= IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN
-
128 sizeof(struct ethhdr
) -
129 sizeof(struct iphdr
) -
130 sizeof(struct tcphdr
),
135 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
137 * Use the reserved field to indicate magic values.
138 * these values will only be used internally by the driver,
139 * and won't make it to the fw (reserved will be 0).
140 * BC_FILTER_MAGIC_IP - configure the val of this attribute to
141 * be the vif's ip address. in case there is not a single
142 * ip address (0, or more than 1), this attribute will
144 * BC_FILTER_MAGIC_MAC - set the val of this attribute to
145 * the LSB bytes of the vif's mac address
148 BC_FILTER_MAGIC_NONE
= 0,
153 static const struct iwl_fw_bcast_filter iwl_mvm_default_bcast_filters
[] = {
157 .frame_type
= BCAST_FILTER_FRAME_TYPE_ALL
,
160 /* frame type - arp, hw type - ethernet */
162 BCAST_FILTER_OFFSET_PAYLOAD_START
,
163 .offset
= sizeof(rfc1042_header
),
164 .val
= cpu_to_be32(0x08060001),
165 .mask
= cpu_to_be32(0xffffffff),
170 BCAST_FILTER_OFFSET_PAYLOAD_START
,
171 .offset
= sizeof(rfc1042_header
) + 2 +
172 sizeof(struct arphdr
) +
173 ETH_ALEN
+ sizeof(__be32
) +
175 .mask
= cpu_to_be32(0xffffffff),
176 /* mark it as special field */
177 .reserved1
= cpu_to_le16(BC_FILTER_MAGIC_IP
),
182 /* dhcp offer bcast */
184 .frame_type
= BCAST_FILTER_FRAME_TYPE_IPV4
,
187 /* udp dest port - 68 (bootp client)*/
188 .offset_type
= BCAST_FILTER_OFFSET_IP_END
,
189 .offset
= offsetof(struct udphdr
, dest
),
190 .val
= cpu_to_be32(0x00440000),
191 .mask
= cpu_to_be32(0xffff0000),
194 /* dhcp - lsb bytes of client hw address */
195 .offset_type
= BCAST_FILTER_OFFSET_IP_END
,
197 .mask
= cpu_to_be32(0xffffffff),
198 /* mark it as special field */
199 .reserved1
= cpu_to_le16(BC_FILTER_MAGIC_MAC
),
203 /* last filter must be empty */
208 void iwl_mvm_ref(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref_type
)
210 if (!iwl_mvm_is_d0i3_supported(mvm
))
213 IWL_DEBUG_RPM(mvm
, "Take mvm reference - type %d\n", ref_type
);
214 WARN_ON(test_and_set_bit(ref_type
, mvm
->ref_bitmap
));
215 iwl_trans_ref(mvm
->trans
);
218 void iwl_mvm_unref(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref_type
)
220 if (!iwl_mvm_is_d0i3_supported(mvm
))
223 IWL_DEBUG_RPM(mvm
, "Leave mvm reference - type %d\n", ref_type
);
224 WARN_ON(!test_and_clear_bit(ref_type
, mvm
->ref_bitmap
));
225 iwl_trans_unref(mvm
->trans
);
229 iwl_mvm_unref_all_except(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref
)
233 if (!iwl_mvm_is_d0i3_supported(mvm
))
236 for_each_set_bit(i
, mvm
->ref_bitmap
, IWL_MVM_REF_COUNT
) {
240 IWL_DEBUG_RPM(mvm
, "Cleanup: remove mvm ref type %d\n", i
);
241 clear_bit(i
, mvm
->ref_bitmap
);
242 iwl_trans_unref(mvm
->trans
);
246 static int iwl_mvm_ref_sync(struct iwl_mvm
*mvm
, enum iwl_mvm_ref_type ref_type
)
248 iwl_mvm_ref(mvm
, ref_type
);
250 if (!wait_event_timeout(mvm
->d0i3_exit_waitq
,
251 !test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
),
254 iwl_mvm_unref(mvm
, ref_type
);
261 static void iwl_mvm_reset_phy_ctxts(struct iwl_mvm
*mvm
)
265 memset(mvm
->phy_ctxts
, 0, sizeof(mvm
->phy_ctxts
));
266 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
267 mvm
->phy_ctxts
[i
].id
= i
;
268 mvm
->phy_ctxts
[i
].ref
= 0;
272 static int iwl_mvm_max_scan_ie_len(struct iwl_mvm
*mvm
)
274 /* we create the 802.11 header and SSID element */
275 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_NO_BASIC_SSID
)
276 return mvm
->fw
->ucode_capa
.max_probe_length
- 24 - 2;
277 return mvm
->fw
->ucode_capa
.max_probe_length
- 24 - 34;
280 int iwl_mvm_mac_setup_register(struct iwl_mvm
*mvm
)
282 struct ieee80211_hw
*hw
= mvm
->hw
;
285 /* Tell mac80211 our characteristics */
286 hw
->flags
= IEEE80211_HW_SIGNAL_DBM
|
287 IEEE80211_HW_SPECTRUM_MGMT
|
288 IEEE80211_HW_REPORTS_TX_ACK_STATUS
|
289 IEEE80211_HW_QUEUE_CONTROL
|
290 IEEE80211_HW_WANT_MONITOR_VIF
|
291 IEEE80211_HW_SUPPORTS_PS
|
292 IEEE80211_HW_SUPPORTS_DYNAMIC_PS
|
293 IEEE80211_HW_AMPDU_AGGREGATION
|
294 IEEE80211_HW_TIMING_BEACON_ONLY
|
295 IEEE80211_HW_CONNECTION_MONITOR
|
296 IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS
|
297 IEEE80211_HW_SUPPORTS_STATIC_SMPS
;
299 hw
->queues
= mvm
->first_agg_queue
;
300 hw
->offchannel_tx_hw_queue
= IWL_MVM_OFFCHANNEL_QUEUE
;
301 hw
->radiotap_mcs_details
|= IEEE80211_RADIOTAP_MCS_HAVE_FEC
|
302 IEEE80211_RADIOTAP_MCS_HAVE_STBC
;
303 hw
->radiotap_vht_details
|= IEEE80211_RADIOTAP_VHT_KNOWN_STBC
;
304 hw
->rate_control_algorithm
= "iwl-mvm-rs";
307 * Enable 11w if advertised by firmware and software crypto
308 * is not enabled (as the firmware will interpret some mgmt
309 * packets, so enabling it with software crypto isn't safe)
311 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_MFP
&&
312 !iwlwifi_mod_params
.sw_crypto
)
313 hw
->flags
|= IEEE80211_HW_MFP_CAPABLE
;
315 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT
&&
316 IWL_UCODE_API(mvm
->fw
->ucode_ver
) >= 9 &&
317 !iwlwifi_mod_params
.uapsd_disable
) {
318 hw
->flags
|= IEEE80211_HW_SUPPORTS_UAPSD
;
319 hw
->uapsd_queues
= IWL_UAPSD_AC_INFO
;
320 hw
->uapsd_max_sp_len
= IWL_UAPSD_MAX_SP
;
323 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT
&&
324 !iwlwifi_mod_params
.uapsd_disable
) {
325 hw
->flags
|= IEEE80211_HW_SUPPORTS_UAPSD
;
326 hw
->uapsd_queues
= IWL_UAPSD_AC_INFO
;
327 hw
->uapsd_max_sp_len
= IWL_UAPSD_MAX_SP
;
330 if (mvm
->fw
->ucode_capa
.api
[0] & IWL_UCODE_TLV_API_LMAC_SCAN
)
331 hw
->flags
|= IEEE80211_SINGLE_HW_SCAN_ON_ALL_BANDS
;
333 hw
->sta_data_size
= sizeof(struct iwl_mvm_sta
);
334 hw
->vif_data_size
= sizeof(struct iwl_mvm_vif
);
335 hw
->chanctx_data_size
= sizeof(u16
);
337 hw
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
338 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
339 BIT(NL80211_IFTYPE_AP
) |
340 BIT(NL80211_IFTYPE_P2P_GO
) |
341 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
342 BIT(NL80211_IFTYPE_ADHOC
);
344 hw
->wiphy
->flags
|= WIPHY_FLAG_IBSS_RSN
;
345 hw
->wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
346 REGULATORY_DISABLE_BEACON_HINTS
;
348 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_GO_UAPSD
)
349 hw
->wiphy
->flags
|= WIPHY_FLAG_AP_UAPSD
;
351 if (mvm
->fw
->ucode_capa
.api
[0] & IWL_UCODE_TLV_API_CSA_FLOW
)
352 hw
->wiphy
->flags
|= WIPHY_FLAG_HAS_CHANNEL_SWITCH
;
354 hw
->wiphy
->iface_combinations
= iwl_mvm_iface_combinations
;
355 hw
->wiphy
->n_iface_combinations
=
356 ARRAY_SIZE(iwl_mvm_iface_combinations
);
358 hw
->wiphy
->max_remain_on_channel_duration
= 10000;
359 hw
->max_listen_interval
= IWL_CONN_MAX_LISTEN_INTERVAL
;
361 /* Extract MAC address */
362 memcpy(mvm
->addresses
[0].addr
, mvm
->nvm_data
->hw_addr
, ETH_ALEN
);
363 hw
->wiphy
->addresses
= mvm
->addresses
;
364 hw
->wiphy
->n_addresses
= 1;
366 /* Extract additional MAC addresses if available */
367 num_mac
= (mvm
->nvm_data
->n_hw_addrs
> 1) ?
368 min(IWL_MVM_MAX_ADDRESSES
, mvm
->nvm_data
->n_hw_addrs
) : 1;
370 for (i
= 1; i
< num_mac
; i
++) {
371 memcpy(mvm
->addresses
[i
].addr
, mvm
->addresses
[i
-1].addr
,
373 mvm
->addresses
[i
].addr
[5]++;
374 hw
->wiphy
->n_addresses
++;
377 iwl_mvm_reset_phy_ctxts(mvm
);
379 hw
->wiphy
->max_scan_ie_len
= iwl_mvm_max_scan_ie_len(mvm
);
381 hw
->wiphy
->max_scan_ssids
= PROBE_OPTION_MAX
;
383 if (mvm
->nvm_data
->bands
[IEEE80211_BAND_2GHZ
].n_channels
)
384 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] =
385 &mvm
->nvm_data
->bands
[IEEE80211_BAND_2GHZ
];
386 if (mvm
->nvm_data
->bands
[IEEE80211_BAND_5GHZ
].n_channels
)
387 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] =
388 &mvm
->nvm_data
->bands
[IEEE80211_BAND_5GHZ
];
390 hw
->wiphy
->hw_version
= mvm
->trans
->hw_id
;
392 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
)
393 hw
->wiphy
->flags
|= WIPHY_FLAG_PS_ON_BY_DEFAULT
;
395 hw
->wiphy
->flags
&= ~WIPHY_FLAG_PS_ON_BY_DEFAULT
;
397 hw
->wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_SCHED_SCAN
;
398 hw
->wiphy
->max_sched_scan_ssids
= PROBE_OPTION_MAX
;
399 hw
->wiphy
->max_match_sets
= IWL_SCAN_MAX_PROFILES
;
400 /* we create the 802.11 header and zero length SSID IE. */
401 hw
->wiphy
->max_sched_scan_ie_len
= SCAN_OFFLOAD_PROBE_REQ_SIZE
- 24 - 2;
403 hw
->wiphy
->features
|= NL80211_FEATURE_P2P_GO_CTWIN
|
404 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
405 NL80211_FEATURE_P2P_GO_OPPPS
;
407 mvm
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
409 /* currently FW API supports only one optional cipher scheme */
410 if (mvm
->fw
->cs
[0].cipher
) {
411 mvm
->hw
->n_cipher_schemes
= 1;
412 mvm
->hw
->cipher_schemes
= &mvm
->fw
->cs
[0];
415 #ifdef CONFIG_PM_SLEEP
416 if (iwl_mvm_is_d0i3_supported(mvm
) &&
417 device_can_wakeup(mvm
->trans
->dev
)) {
418 mvm
->wowlan
.flags
= WIPHY_WOWLAN_ANY
;
419 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
420 } else if (mvm
->fw
->img
[IWL_UCODE_WOWLAN
].sec
[0].len
&&
421 mvm
->trans
->ops
->d3_suspend
&&
422 mvm
->trans
->ops
->d3_resume
&&
423 device_can_wakeup(mvm
->trans
->dev
)) {
424 mvm
->wowlan
.flags
= WIPHY_WOWLAN_MAGIC_PKT
|
425 WIPHY_WOWLAN_DISCONNECT
|
426 WIPHY_WOWLAN_EAP_IDENTITY_REQ
|
427 WIPHY_WOWLAN_RFKILL_RELEASE
;
428 if (!iwlwifi_mod_params
.sw_crypto
)
429 mvm
->wowlan
.flags
|= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
430 WIPHY_WOWLAN_GTK_REKEY_FAILURE
|
431 WIPHY_WOWLAN_4WAY_HANDSHAKE
;
433 mvm
->wowlan
.n_patterns
= IWL_WOWLAN_MAX_PATTERNS
;
434 mvm
->wowlan
.pattern_min_len
= IWL_WOWLAN_MIN_PATTERN_LEN
;
435 mvm
->wowlan
.pattern_max_len
= IWL_WOWLAN_MAX_PATTERN_LEN
;
436 mvm
->wowlan
.tcp
= &iwl_mvm_wowlan_tcp_support
;
437 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
441 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
442 /* assign default bcast filtering configuration */
443 mvm
->bcast_filters
= iwl_mvm_default_bcast_filters
;
446 ret
= iwl_mvm_leds_init(mvm
);
450 ret
= ieee80211_register_hw(mvm
->hw
);
452 iwl_mvm_leds_exit(mvm
);
457 static bool iwl_mvm_defer_tx(struct iwl_mvm
*mvm
,
458 struct ieee80211_sta
*sta
,
461 struct iwl_mvm_sta
*mvmsta
;
465 * double check the IN_D0I3 flag both before and after
466 * taking the spinlock, in order to prevent taking
467 * the spinlock when not needed.
469 if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
)))
472 spin_lock(&mvm
->d0i3_tx_lock
);
474 * testing the flag again ensures the skb dequeue
475 * loop (on d0i3 exit) hasn't run yet.
477 if (!test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
))
480 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
481 if (mvmsta
->sta_id
== IWL_MVM_STATION_COUNT
||
482 mvmsta
->sta_id
!= mvm
->d0i3_ap_sta_id
)
485 __skb_queue_tail(&mvm
->d0i3_tx
, skb
);
486 ieee80211_stop_queues(mvm
->hw
);
489 iwl_mvm_ref(mvm
, IWL_MVM_REF_TX
);
490 iwl_mvm_unref(mvm
, IWL_MVM_REF_TX
);
494 spin_unlock(&mvm
->d0i3_tx_lock
);
498 static void iwl_mvm_mac_tx(struct ieee80211_hw
*hw
,
499 struct ieee80211_tx_control
*control
,
502 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
503 struct ieee80211_sta
*sta
= control
->sta
;
504 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
505 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
507 if (iwl_mvm_is_radio_killed(mvm
)) {
508 IWL_DEBUG_DROP(mvm
, "Dropping - RF/CT KILL\n");
512 if (IEEE80211_SKB_CB(skb
)->hw_queue
== IWL_MVM_OFFCHANNEL_QUEUE
&&
513 !test_bit(IWL_MVM_STATUS_ROC_RUNNING
, &mvm
->status
))
516 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */
517 if (unlikely(info
->flags
& IEEE80211_TX_CTL_NO_PS_BUFFER
&&
518 ieee80211_is_mgmt(hdr
->frame_control
) &&
519 !ieee80211_is_deauth(hdr
->frame_control
) &&
520 !ieee80211_is_disassoc(hdr
->frame_control
) &&
521 !ieee80211_is_action(hdr
->frame_control
)))
525 if (iwl_mvm_defer_tx(mvm
, sta
, skb
))
527 if (iwl_mvm_tx_skb(mvm
, skb
, sta
))
532 if (iwl_mvm_tx_skb_non_sta(mvm
, skb
))
536 ieee80211_free_txskb(hw
, skb
);
539 static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg
*cfg
)
541 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_RXAGG
)
546 static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg
*cfg
)
548 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_TXAGG
)
550 if (iwlwifi_mod_params
.disable_11n
& IWL_ENABLE_HT_TXAGG
)
553 /* enabled by default */
557 static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw
*hw
,
558 struct ieee80211_vif
*vif
,
559 enum ieee80211_ampdu_mlme_action action
,
560 struct ieee80211_sta
*sta
, u16 tid
,
561 u16
*ssn
, u8 buf_size
)
563 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
565 bool tx_agg_ref
= false;
567 IWL_DEBUG_HT(mvm
, "A-MPDU action on addr %pM tid %d: action %d\n",
568 sta
->addr
, tid
, action
);
570 if (!(mvm
->nvm_data
->sku_cap_11n_enable
))
573 /* return from D0i3 before starting a new Tx aggregation */
575 case IEEE80211_AMPDU_TX_START
:
576 case IEEE80211_AMPDU_TX_STOP_CONT
:
577 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
578 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
579 case IEEE80211_AMPDU_TX_OPERATIONAL
:
581 * for tx start, wait synchronously until D0i3 exit to
582 * get the correct sequence number for the tid.
583 * additionally, some other ampdu actions use direct
584 * target access, which is not handled automatically
585 * by the trans layer (unlike commands), so wait for
586 * d0i3 exit in these cases as well.
588 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_TX_AGG
);
598 mutex_lock(&mvm
->mutex
);
601 case IEEE80211_AMPDU_RX_START
:
602 if (!iwl_enable_rx_ampdu(mvm
->cfg
)) {
606 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, *ssn
, true);
608 case IEEE80211_AMPDU_RX_STOP
:
609 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, 0, false);
611 case IEEE80211_AMPDU_TX_START
:
612 if (!iwl_enable_tx_ampdu(mvm
->cfg
)) {
616 ret
= iwl_mvm_sta_tx_agg_start(mvm
, vif
, sta
, tid
, ssn
);
618 case IEEE80211_AMPDU_TX_STOP_CONT
:
619 ret
= iwl_mvm_sta_tx_agg_stop(mvm
, vif
, sta
, tid
);
621 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
622 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
623 ret
= iwl_mvm_sta_tx_agg_flush(mvm
, vif
, sta
, tid
);
625 case IEEE80211_AMPDU_TX_OPERATIONAL
:
626 ret
= iwl_mvm_sta_tx_agg_oper(mvm
, vif
, sta
, tid
, buf_size
);
633 mutex_unlock(&mvm
->mutex
);
636 * If the tid is marked as started, we won't use it for offloaded
637 * traffic on the next D0i3 entry. It's safe to unref.
640 iwl_mvm_unref(mvm
, IWL_MVM_REF_TX_AGG
);
645 static void iwl_mvm_cleanup_iterator(void *data
, u8
*mac
,
646 struct ieee80211_vif
*vif
)
648 struct iwl_mvm
*mvm
= data
;
649 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
651 mvmvif
->uploaded
= false;
652 mvmvif
->ap_sta_id
= IWL_MVM_STATION_COUNT
;
654 /* does this make sense at all? */
657 spin_lock_bh(&mvm
->time_event_lock
);
658 iwl_mvm_te_clear_data(mvm
, &mvmvif
->time_event_data
);
659 spin_unlock_bh(&mvm
->time_event_lock
);
661 mvmvif
->phy_ctxt
= NULL
;
664 #ifdef CONFIG_IWLWIFI_DEBUGFS
665 static void iwl_mvm_fw_error_dump(struct iwl_mvm
*mvm
)
667 struct iwl_fw_error_dump_file
*dump_file
;
668 struct iwl_fw_error_dump_data
*dump_data
;
669 struct iwl_fw_error_dump_info
*dump_info
;
670 const struct fw_img
*img
;
671 u32 sram_len
, sram_ofs
;
672 u32 file_len
, rxf_len
;
677 lockdep_assert_held(&mvm
->mutex
);
679 if (mvm
->fw_error_dump
)
682 img
= &mvm
->fw
->img
[mvm
->cur_ucode
];
683 sram_ofs
= img
->sec
[IWL_UCODE_SECTION_DATA
].offset
;
684 sram_len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
686 /* reading buffer size */
687 reg_val
= iwl_trans_read_prph(mvm
->trans
, RXF_SIZE_ADDR
);
688 rxf_len
= (reg_val
& RXF_SIZE_BYTE_CNT_MSK
) >> RXF_SIZE_BYTE_CND_POS
;
690 /* the register holds the value divided by 128 */
691 rxf_len
= rxf_len
<< 7;
693 file_len
= sizeof(*dump_file
) +
694 sizeof(*dump_data
) * 3 +
699 trans_len
= iwl_trans_dump_data(mvm
->trans
, NULL
, 0);
701 file_len
+= trans_len
;
703 dump_file
= vzalloc(file_len
);
707 mvm
->fw_error_dump
= dump_file
;
709 dump_file
->barker
= cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER
);
710 dump_file
->file_len
= cpu_to_le32(file_len
);
711 dump_data
= (void *)dump_file
->data
;
713 dump_data
->type
= cpu_to_le32(IWL_FW_ERROR_DUMP_DEV_FW_INFO
);
714 dump_data
->len
= cpu_to_le32(sizeof(*dump_info
));
715 dump_info
= (void *) dump_data
->data
;
716 dump_info
->device_family
=
717 mvm
->cfg
->device_family
== IWL_DEVICE_FAMILY_7000
?
718 cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_7
) :
719 cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_8
);
720 memcpy(dump_info
->fw_human_readable
, mvm
->fw
->human_readable
,
721 sizeof(dump_info
->fw_human_readable
));
722 strncpy(dump_info
->dev_human_readable
, mvm
->cfg
->name
,
723 sizeof(dump_info
->dev_human_readable
));
724 strncpy(dump_info
->bus_human_readable
, mvm
->dev
->bus
->name
,
725 sizeof(dump_info
->bus_human_readable
));
727 dump_data
= iwl_fw_error_next_data(dump_data
);
728 dump_data
->type
= cpu_to_le32(IWL_FW_ERROR_DUMP_RXF
);
729 dump_data
->len
= cpu_to_le32(rxf_len
);
731 if (iwl_trans_grab_nic_access(mvm
->trans
, false, &flags
)) {
732 u32
*rxf
= (void *)dump_data
->data
;
735 for (i
= 0; i
< (rxf_len
/ sizeof(u32
)); i
++) {
736 iwl_trans_write_prph(mvm
->trans
,
737 RXF_LD_FENCE_OFFSET_ADDR
,
739 rxf
[i
] = iwl_trans_read_prph(mvm
->trans
,
740 RXF_FIFO_RD_FENCE_ADDR
);
742 iwl_trans_release_nic_access(mvm
->trans
, &flags
);
745 dump_data
= iwl_fw_error_next_data(dump_data
);
746 dump_data
->type
= cpu_to_le32(IWL_FW_ERROR_DUMP_SRAM
);
747 dump_data
->len
= cpu_to_le32(sram_len
);
748 iwl_trans_read_mem_bytes(mvm
->trans
, sram_ofs
, dump_data
->data
,
752 void *buf
= iwl_fw_error_next_data(dump_data
);
753 u32 real_trans_len
= iwl_trans_dump_data(mvm
->trans
, buf
,
755 dump_data
= (void *)((u8
*)buf
+ real_trans_len
);
756 dump_file
->file_len
=
757 cpu_to_le32(file_len
- trans_len
+ real_trans_len
);
762 static void iwl_mvm_restart_cleanup(struct iwl_mvm
*mvm
)
764 #ifdef CONFIG_IWLWIFI_DEBUGFS
765 static char *env
[] = { "DRIVER=iwlwifi", "EVENT=error_dump", NULL
};
767 iwl_mvm_fw_error_dump(mvm
);
769 /* notify the userspace about the error we had */
770 kobject_uevent_env(&mvm
->hw
->wiphy
->dev
.kobj
, KOBJ_CHANGE
, env
);
773 iwl_trans_stop_device(mvm
->trans
);
775 mvm
->scan_status
= IWL_MVM_SCAN_NONE
;
777 /* just in case one was running */
778 ieee80211_remain_on_channel_expired(mvm
->hw
);
780 ieee80211_iterate_active_interfaces_atomic(
781 mvm
->hw
, IEEE80211_IFACE_ITER_RESUME_ALL
,
782 iwl_mvm_cleanup_iterator
, mvm
);
784 mvm
->p2p_device_vif
= NULL
;
785 mvm
->d0i3_ap_sta_id
= IWL_MVM_STATION_COUNT
;
787 iwl_mvm_reset_phy_ctxts(mvm
);
788 memset(mvm
->fw_key_table
, 0, sizeof(mvm
->fw_key_table
));
789 memset(mvm
->sta_drained
, 0, sizeof(mvm
->sta_drained
));
791 ieee80211_wake_queues(mvm
->hw
);
793 /* cleanup all stale references (scan, roc), but keep the
794 * ucode_down ref until reconfig is complete */
795 iwl_mvm_unref_all_except(mvm
, IWL_MVM_REF_UCODE_DOWN
);
798 mvm
->rx_ba_sessions
= 0;
801 static int iwl_mvm_mac_start(struct ieee80211_hw
*hw
)
803 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
806 mutex_lock(&mvm
->mutex
);
808 /* Clean up some internal and mac80211 state on restart */
809 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
810 iwl_mvm_restart_cleanup(mvm
);
812 ret
= iwl_mvm_up(mvm
);
814 if (ret
&& test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
815 /* Something went wrong - we need to finish some cleanup
816 * that normally iwl_mvm_mac_restart_complete() below
819 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
820 iwl_mvm_d0i3_enable_tx(mvm
, NULL
);
823 mutex_unlock(&mvm
->mutex
);
828 static void iwl_mvm_mac_restart_complete(struct ieee80211_hw
*hw
)
830 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
833 mutex_lock(&mvm
->mutex
);
835 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
836 iwl_mvm_d0i3_enable_tx(mvm
, NULL
);
837 ret
= iwl_mvm_update_quotas(mvm
, NULL
);
839 IWL_ERR(mvm
, "Failed to update quotas after restart (%d)\n",
842 /* allow transport/FW low power modes */
843 iwl_mvm_unref(mvm
, IWL_MVM_REF_UCODE_DOWN
);
845 mutex_unlock(&mvm
->mutex
);
848 static void iwl_mvm_mac_stop(struct ieee80211_hw
*hw
)
850 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
852 flush_work(&mvm
->d0i3_exit_work
);
853 flush_work(&mvm
->async_handlers_wk
);
855 mutex_lock(&mvm
->mutex
);
857 /* disallow low power states when the FW is down */
858 iwl_mvm_ref(mvm
, IWL_MVM_REF_UCODE_DOWN
);
860 /* async_handlers_wk is now blocked */
863 * The work item could be running or queued if the
864 * ROC time event stops just as we get here.
866 cancel_work_sync(&mvm
->roc_done_wk
);
868 iwl_trans_stop_device(mvm
->trans
);
870 iwl_mvm_async_handlers_purge(mvm
);
871 /* async_handlers_list is empty and will stay empty: HW is stopped */
873 /* the fw is stopped, the aux sta is dead: clean up driver state */
874 iwl_mvm_dealloc_int_sta(mvm
, &mvm
->aux_sta
);
876 mutex_unlock(&mvm
->mutex
);
879 * The worker might have been waiting for the mutex, let it run and
880 * discover that its list is now empty.
882 cancel_work_sync(&mvm
->async_handlers_wk
);
885 static struct iwl_mvm_phy_ctxt
*iwl_mvm_get_free_phy_ctxt(struct iwl_mvm
*mvm
)
889 lockdep_assert_held(&mvm
->mutex
);
891 for (i
= 0; i
< NUM_PHY_CTX
; i
++)
892 if (!mvm
->phy_ctxts
[i
].ref
)
893 return &mvm
->phy_ctxts
[i
];
895 IWL_ERR(mvm
, "No available PHY context\n");
899 static int iwl_mvm_set_tx_power(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
902 /* FW is in charge of regulatory enforcement */
903 struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd
= {
904 .mac_context_id
= iwl_mvm_vif_from_mac80211(vif
)->id
,
905 .pwr_restriction
= cpu_to_le16(tx_power
),
908 return iwl_mvm_send_cmd_pdu(mvm
, REDUCE_TX_POWER_CMD
, 0,
909 sizeof(reduce_txpwr_cmd
),
913 static int iwl_mvm_mac_add_interface(struct ieee80211_hw
*hw
,
914 struct ieee80211_vif
*vif
)
916 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
917 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
921 * make sure D0i3 exit is completed, otherwise a target access
922 * during tx queue configuration could be done when still in
925 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_ADD_IF
);
930 * Not much to do here. The stack will not allow interface
931 * types or combinations that we didn't advertise, so we
932 * don't really have to check the types.
935 mutex_lock(&mvm
->mutex
);
937 /* Allocate resources for the MAC context, and add it to the fw */
938 ret
= iwl_mvm_mac_ctxt_init(mvm
, vif
);
942 /* Counting number of interfaces is needed for legacy PM */
943 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
947 * The AP binding flow can be done only after the beacon
948 * template is configured (which happens only in the mac80211
949 * start_ap() flow), and adding the broadcast station can happen
950 * only after the binding.
951 * In addition, since modifying the MAC before adding a bcast
952 * station is not allowed by the FW, delay the adding of MAC context to
953 * the point where we can also add the bcast station.
954 * In short: there's not much we can do at this point, other than
955 * allocating resources :)
957 if (vif
->type
== NL80211_IFTYPE_AP
||
958 vif
->type
== NL80211_IFTYPE_ADHOC
) {
959 u32 qmask
= iwl_mvm_mac_get_queues_mask(mvm
, vif
);
960 ret
= iwl_mvm_allocate_int_sta(mvm
, &mvmvif
->bcast_sta
,
962 ieee80211_vif_type_p2p(vif
));
964 IWL_ERR(mvm
, "Failed to allocate bcast sta\n");
968 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
972 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
976 ret
= iwl_mvm_power_update_mac(mvm
);
980 /* beacon filtering */
981 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
985 if (!mvm
->bf_allowed_vif
&&
986 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
) {
987 mvm
->bf_allowed_vif
= mvmvif
;
988 vif
->driver_flags
|= IEEE80211_VIF_BEACON_FILTER
|
989 IEEE80211_VIF_SUPPORTS_CQM_RSSI
;
993 * P2P_DEVICE interface does not have a channel context assigned to it,
994 * so a dedicated PHY context is allocated to it and the corresponding
995 * MAC context is bound to it at this stage.
997 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
999 mvmvif
->phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
1000 if (!mvmvif
->phy_ctxt
) {
1005 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
1006 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
1010 ret
= iwl_mvm_add_bcast_sta(mvm
, vif
, &mvmvif
->bcast_sta
);
1014 /* Save a pointer to p2p device vif, so it can later be used to
1015 * update the p2p device MAC when a GO is started/stopped */
1016 mvm
->p2p_device_vif
= vif
;
1019 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
1023 iwl_mvm_binding_remove_vif(mvm
, vif
);
1025 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
1027 if (mvm
->bf_allowed_vif
== mvmvif
) {
1028 mvm
->bf_allowed_vif
= NULL
;
1029 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1030 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1033 mvmvif
->phy_ctxt
= NULL
;
1034 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1036 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1039 iwl_mvm_mac_ctxt_release(mvm
, vif
);
1041 mutex_unlock(&mvm
->mutex
);
1043 iwl_mvm_unref(mvm
, IWL_MVM_REF_ADD_IF
);
1048 static void iwl_mvm_prepare_mac_removal(struct iwl_mvm
*mvm
,
1049 struct ieee80211_vif
*vif
)
1051 u32 tfd_msk
= 0, ac
;
1053 for (ac
= 0; ac
< IEEE80211_NUM_ACS
; ac
++)
1054 if (vif
->hw_queue
[ac
] != IEEE80211_INVAL_HW_QUEUE
)
1055 tfd_msk
|= BIT(vif
->hw_queue
[ac
]);
1057 if (vif
->cab_queue
!= IEEE80211_INVAL_HW_QUEUE
)
1058 tfd_msk
|= BIT(vif
->cab_queue
);
1061 mutex_lock(&mvm
->mutex
);
1062 iwl_mvm_flush_tx_path(mvm
, tfd_msk
, true);
1063 mutex_unlock(&mvm
->mutex
);
1066 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1068 * Flush the ROC worker which will flush the OFFCHANNEL queue.
1069 * We assume here that all the packets sent to the OFFCHANNEL
1070 * queue are sent in ROC session.
1072 flush_work(&mvm
->roc_done_wk
);
1075 * By now, all the AC queues are empty. The AGG queues are
1076 * empty too. We already got all the Tx responses for all the
1077 * packets in the queues. The drain work can have been
1078 * triggered. Flush it.
1080 flush_work(&mvm
->sta_drained_wk
);
1084 static void iwl_mvm_mac_remove_interface(struct ieee80211_hw
*hw
,
1085 struct ieee80211_vif
*vif
)
1087 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1088 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1090 iwl_mvm_prepare_mac_removal(mvm
, vif
);
1092 mutex_lock(&mvm
->mutex
);
1094 if (mvm
->bf_allowed_vif
== mvmvif
) {
1095 mvm
->bf_allowed_vif
= NULL
;
1096 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1097 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1100 iwl_mvm_vif_dbgfs_clean(mvm
, vif
);
1103 * For AP/GO interface, the tear down of the resources allocated to the
1104 * interface is be handled as part of the stop_ap flow.
1106 if (vif
->type
== NL80211_IFTYPE_AP
||
1107 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1108 #ifdef CONFIG_NL80211_TESTMODE
1109 if (vif
== mvm
->noa_vif
) {
1110 mvm
->noa_vif
= NULL
;
1111 mvm
->noa_duration
= 0;
1114 iwl_mvm_dealloc_int_sta(mvm
, &mvmvif
->bcast_sta
);
1118 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1119 mvm
->p2p_device_vif
= NULL
;
1120 iwl_mvm_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
1121 iwl_mvm_binding_remove_vif(mvm
, vif
);
1122 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
1123 mvmvif
->phy_ctxt
= NULL
;
1126 if (mvm
->vif_count
&& vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1129 iwl_mvm_power_update_mac(mvm
);
1130 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1133 iwl_mvm_mac_ctxt_release(mvm
, vif
);
1134 mutex_unlock(&mvm
->mutex
);
1137 static int iwl_mvm_mac_config(struct ieee80211_hw
*hw
, u32 changed
)
1142 struct iwl_mvm_mc_iter_data
{
1143 struct iwl_mvm
*mvm
;
1147 static void iwl_mvm_mc_iface_iterator(void *_data
, u8
*mac
,
1148 struct ieee80211_vif
*vif
)
1150 struct iwl_mvm_mc_iter_data
*data
= _data
;
1151 struct iwl_mvm
*mvm
= data
->mvm
;
1152 struct iwl_mcast_filter_cmd
*cmd
= mvm
->mcast_filter_cmd
;
1155 /* if we don't have free ports, mcast frames will be dropped */
1156 if (WARN_ON_ONCE(data
->port_id
>= MAX_PORT_ID_NUM
))
1159 if (vif
->type
!= NL80211_IFTYPE_STATION
||
1160 !vif
->bss_conf
.assoc
)
1163 cmd
->port_id
= data
->port_id
++;
1164 memcpy(cmd
->bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
1165 len
= roundup(sizeof(*cmd
) + cmd
->count
* ETH_ALEN
, 4);
1167 ret
= iwl_mvm_send_cmd_pdu(mvm
, MCAST_FILTER_CMD
, CMD_ASYNC
, len
, cmd
);
1169 IWL_ERR(mvm
, "mcast filter cmd error. ret=%d\n", ret
);
1172 static void iwl_mvm_recalc_multicast(struct iwl_mvm
*mvm
)
1174 struct iwl_mvm_mc_iter_data iter_data
= {
1178 lockdep_assert_held(&mvm
->mutex
);
1180 if (WARN_ON_ONCE(!mvm
->mcast_filter_cmd
))
1183 ieee80211_iterate_active_interfaces_atomic(
1184 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1185 iwl_mvm_mc_iface_iterator
, &iter_data
);
1188 static u64
iwl_mvm_prepare_multicast(struct ieee80211_hw
*hw
,
1189 struct netdev_hw_addr_list
*mc_list
)
1191 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1192 struct iwl_mcast_filter_cmd
*cmd
;
1193 struct netdev_hw_addr
*addr
;
1194 int addr_count
= netdev_hw_addr_list_count(mc_list
);
1195 bool pass_all
= false;
1198 if (addr_count
> MAX_MCAST_FILTERING_ADDRESSES
) {
1203 len
= roundup(sizeof(*cmd
) + addr_count
* ETH_ALEN
, 4);
1204 cmd
= kzalloc(len
, GFP_ATOMIC
);
1210 return (u64
)(unsigned long)cmd
;
1213 netdev_hw_addr_list_for_each(addr
, mc_list
) {
1214 IWL_DEBUG_MAC80211(mvm
, "mcast addr (%d): %pM\n",
1215 cmd
->count
, addr
->addr
);
1216 memcpy(&cmd
->addr_list
[cmd
->count
* ETH_ALEN
],
1217 addr
->addr
, ETH_ALEN
);
1221 return (u64
)(unsigned long)cmd
;
1224 static void iwl_mvm_configure_filter(struct ieee80211_hw
*hw
,
1225 unsigned int changed_flags
,
1226 unsigned int *total_flags
,
1229 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1230 struct iwl_mcast_filter_cmd
*cmd
= (void *)(unsigned long)multicast
;
1232 mutex_lock(&mvm
->mutex
);
1234 /* replace previous configuration */
1235 kfree(mvm
->mcast_filter_cmd
);
1236 mvm
->mcast_filter_cmd
= cmd
;
1241 iwl_mvm_recalc_multicast(mvm
);
1243 mutex_unlock(&mvm
->mutex
);
1247 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1248 struct iwl_bcast_iter_data
{
1249 struct iwl_mvm
*mvm
;
1250 struct iwl_bcast_filter_cmd
*cmd
;
1255 iwl_mvm_set_bcast_filter(struct ieee80211_vif
*vif
,
1256 const struct iwl_fw_bcast_filter
*in_filter
,
1257 struct iwl_fw_bcast_filter
*out_filter
)
1259 struct iwl_fw_bcast_filter_attr
*attr
;
1262 memcpy(out_filter
, in_filter
, sizeof(*out_filter
));
1264 for (i
= 0; i
< ARRAY_SIZE(out_filter
->attrs
); i
++) {
1265 attr
= &out_filter
->attrs
[i
];
1270 switch (attr
->reserved1
) {
1271 case cpu_to_le16(BC_FILTER_MAGIC_IP
):
1272 if (vif
->bss_conf
.arp_addr_cnt
!= 1) {
1277 attr
->val
= vif
->bss_conf
.arp_addr_list
[0];
1279 case cpu_to_le16(BC_FILTER_MAGIC_MAC
):
1280 attr
->val
= *(__be32
*)&vif
->addr
[2];
1285 attr
->reserved1
= 0;
1286 out_filter
->num_attrs
++;
1290 static void iwl_mvm_bcast_filter_iterator(void *_data
, u8
*mac
,
1291 struct ieee80211_vif
*vif
)
1293 struct iwl_bcast_iter_data
*data
= _data
;
1294 struct iwl_mvm
*mvm
= data
->mvm
;
1295 struct iwl_bcast_filter_cmd
*cmd
= data
->cmd
;
1296 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1297 struct iwl_fw_bcast_mac
*bcast_mac
;
1300 if (WARN_ON(mvmvif
->id
>= ARRAY_SIZE(cmd
->macs
)))
1303 bcast_mac
= &cmd
->macs
[mvmvif
->id
];
1306 * enable filtering only for associated stations, but not for P2P
1309 if (vif
->type
!= NL80211_IFTYPE_STATION
|| vif
->p2p
||
1310 !vif
->bss_conf
.assoc
)
1313 bcast_mac
->default_discard
= 1;
1315 /* copy all configured filters */
1316 for (i
= 0; mvm
->bcast_filters
[i
].attrs
[0].mask
; i
++) {
1318 * Make sure we don't exceed our filters limit.
1319 * if there is still a valid filter to be configured,
1320 * be on the safe side and just allow bcast for this mac.
1322 if (WARN_ON_ONCE(data
->current_filter
>=
1323 ARRAY_SIZE(cmd
->filters
))) {
1324 bcast_mac
->default_discard
= 0;
1325 bcast_mac
->attached_filters
= 0;
1329 iwl_mvm_set_bcast_filter(vif
,
1330 &mvm
->bcast_filters
[i
],
1331 &cmd
->filters
[data
->current_filter
]);
1333 /* skip current filter if it contains no attributes */
1334 if (!cmd
->filters
[data
->current_filter
].num_attrs
)
1337 /* attach the filter to current mac */
1338 bcast_mac
->attached_filters
|=
1339 cpu_to_le16(BIT(data
->current_filter
));
1341 data
->current_filter
++;
1345 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm
*mvm
,
1346 struct iwl_bcast_filter_cmd
*cmd
)
1348 struct iwl_bcast_iter_data iter_data
= {
1353 memset(cmd
, 0, sizeof(*cmd
));
1354 cmd
->max_bcast_filters
= ARRAY_SIZE(cmd
->filters
);
1355 cmd
->max_macs
= ARRAY_SIZE(cmd
->macs
);
1357 #ifdef CONFIG_IWLWIFI_DEBUGFS
1358 /* use debugfs filters/macs if override is configured */
1359 if (mvm
->dbgfs_bcast_filtering
.override
) {
1360 memcpy(cmd
->filters
, &mvm
->dbgfs_bcast_filtering
.cmd
.filters
,
1361 sizeof(cmd
->filters
));
1362 memcpy(cmd
->macs
, &mvm
->dbgfs_bcast_filtering
.cmd
.macs
,
1368 /* if no filters are configured, do nothing */
1369 if (!mvm
->bcast_filters
)
1372 /* configure and attach these filters for each associated sta vif */
1373 ieee80211_iterate_active_interfaces(
1374 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1375 iwl_mvm_bcast_filter_iterator
, &iter_data
);
1379 static int iwl_mvm_configure_bcast_filter(struct iwl_mvm
*mvm
,
1380 struct ieee80211_vif
*vif
)
1382 struct iwl_bcast_filter_cmd cmd
;
1384 if (!(mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_BCAST_FILTERING
))
1387 if (!iwl_mvm_bcast_filter_build_cmd(mvm
, &cmd
))
1390 return iwl_mvm_send_cmd_pdu(mvm
, BCAST_FILTER_CMD
, 0,
1394 static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm
*mvm
,
1395 struct ieee80211_vif
*vif
)
1401 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm
*mvm
,
1402 struct ieee80211_vif
*vif
,
1403 struct ieee80211_bss_conf
*bss_conf
,
1406 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1410 * Re-calculate the tsf id, as the master-slave relations depend on the
1411 * beacon interval, which was not known when the station interface was
1414 if (changes
& BSS_CHANGED_ASSOC
&& bss_conf
->assoc
)
1415 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
1417 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false);
1419 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
1421 if (changes
& BSS_CHANGED_ASSOC
) {
1422 if (bss_conf
->assoc
) {
1423 /* add quota for this interface */
1424 ret
= iwl_mvm_update_quotas(mvm
, vif
);
1426 IWL_ERR(mvm
, "failed to update quotas\n");
1430 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
1433 * If we're restarting then the firmware will
1434 * obviously have lost synchronisation with
1435 * the AP. It will attempt to synchronise by
1436 * itself, but we can make it more reliable by
1437 * scheduling a session protection time event.
1439 * The firmware needs to receive a beacon to
1440 * catch up with synchronisation, use 110% of
1441 * the beacon interval.
1443 * Set a large maximum delay to allow for more
1444 * than a single interface.
1446 u32 dur
= (11 * vif
->bss_conf
.beacon_int
) / 10;
1447 iwl_mvm_protect_session(mvm
, vif
, dur
, dur
,
1451 iwl_mvm_sf_update(mvm
, vif
, false);
1452 iwl_mvm_power_vif_assoc(mvm
, vif
);
1454 iwl_mvm_ref(mvm
, IWL_MVM_REF_P2P_CLIENT
);
1455 } else if (mvmvif
->ap_sta_id
!= IWL_MVM_STATION_COUNT
) {
1457 * If update fails - SF might be running in associated
1458 * mode while disassociated - which is forbidden.
1460 WARN_ONCE(iwl_mvm_sf_update(mvm
, vif
, false),
1461 "Failed to update SF upon disassociation\n");
1463 /* remove AP station now that the MAC is unassoc */
1464 ret
= iwl_mvm_rm_sta_id(mvm
, vif
, mvmvif
->ap_sta_id
);
1466 IWL_ERR(mvm
, "failed to remove AP station\n");
1468 if (mvm
->d0i3_ap_sta_id
== mvmvif
->ap_sta_id
)
1469 mvm
->d0i3_ap_sta_id
= IWL_MVM_STATION_COUNT
;
1470 mvmvif
->ap_sta_id
= IWL_MVM_STATION_COUNT
;
1471 /* remove quota for this interface */
1472 ret
= iwl_mvm_update_quotas(mvm
, NULL
);
1474 IWL_ERR(mvm
, "failed to update quotas\n");
1477 iwl_mvm_unref(mvm
, IWL_MVM_REF_P2P_CLIENT
);
1480 iwl_mvm_recalc_multicast(mvm
);
1481 iwl_mvm_configure_bcast_filter(mvm
, vif
);
1483 /* reset rssi values */
1484 mvmvif
->bf_data
.ave_beacon_signal
= 0;
1486 iwl_mvm_bt_coex_vif_change(mvm
);
1487 iwl_mvm_update_smps(mvm
, vif
, IWL_MVM_SMPS_REQ_TT
,
1488 IEEE80211_SMPS_AUTOMATIC
);
1489 } else if (changes
& BSS_CHANGED_BEACON_INFO
) {
1491 * We received a beacon _after_ association so
1492 * remove the session protection.
1494 iwl_mvm_remove_time_event(mvm
, mvmvif
,
1495 &mvmvif
->time_event_data
);
1496 iwl_mvm_sf_update(mvm
, vif
, false);
1497 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
, 0));
1498 } else if (changes
& (BSS_CHANGED_PS
| BSS_CHANGED_P2P_PS
|
1500 ret
= iwl_mvm_power_update_mac(mvm
);
1502 IWL_ERR(mvm
, "failed to update power mode\n");
1504 if (changes
& BSS_CHANGED_TXPOWER
) {
1505 IWL_DEBUG_CALIB(mvm
, "Changing TX Power to %d\n",
1507 iwl_mvm_set_tx_power(mvm
, vif
, bss_conf
->txpower
);
1510 if (changes
& BSS_CHANGED_CQM
) {
1511 IWL_DEBUG_MAC80211(mvm
, "cqm info_changed\n");
1512 /* reset cqm events tracking */
1513 mvmvif
->bf_data
.last_cqm_event
= 0;
1514 if (mvmvif
->bf_data
.bf_enabled
) {
1515 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
1518 "failed to update CQM thresholds\n");
1522 if (changes
& BSS_CHANGED_ARP_FILTER
) {
1523 IWL_DEBUG_MAC80211(mvm
, "arp filter changed\n");
1524 iwl_mvm_configure_bcast_filter(mvm
, vif
);
1528 static int iwl_mvm_start_ap_ibss(struct ieee80211_hw
*hw
,
1529 struct ieee80211_vif
*vif
)
1531 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1532 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1535 mutex_lock(&mvm
->mutex
);
1537 /* Send the beacon template */
1538 ret
= iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
);
1543 * Re-calculate the tsf id, as the master-slave relations depend on the
1544 * beacon interval, which was not known when the AP interface was added.
1546 if (vif
->type
== NL80211_IFTYPE_AP
)
1547 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
1549 /* Add the mac context */
1550 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
1554 /* Perform the binding */
1555 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
1559 /* Send the bcast station. At this stage the TBTT and DTIM time events
1560 * are added and applied to the scheduler */
1561 ret
= iwl_mvm_send_bcast_sta(mvm
, vif
, &mvmvif
->bcast_sta
);
1565 /* must be set before quota calculations */
1566 mvmvif
->ap_ibss_active
= true;
1568 /* power updated needs to be done before quotas */
1569 iwl_mvm_power_update_mac(mvm
);
1571 ret
= iwl_mvm_update_quotas(mvm
, vif
);
1573 goto out_quota_failed
;
1575 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
1576 if (vif
->p2p
&& mvm
->p2p_device_vif
)
1577 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false);
1579 iwl_mvm_ref(mvm
, IWL_MVM_REF_AP_IBSS
);
1581 iwl_mvm_bt_coex_vif_change(mvm
);
1583 mutex_unlock(&mvm
->mutex
);
1587 iwl_mvm_power_update_mac(mvm
);
1588 mvmvif
->ap_ibss_active
= false;
1589 iwl_mvm_send_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
1591 iwl_mvm_binding_remove_vif(mvm
, vif
);
1593 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1595 mutex_unlock(&mvm
->mutex
);
1599 static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw
*hw
,
1600 struct ieee80211_vif
*vif
)
1602 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1603 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1605 iwl_mvm_prepare_mac_removal(mvm
, vif
);
1607 mutex_lock(&mvm
->mutex
);
1609 mvmvif
->ap_ibss_active
= false;
1610 mvm
->ap_last_beacon_gp2
= 0;
1612 iwl_mvm_bt_coex_vif_change(mvm
);
1614 iwl_mvm_unref(mvm
, IWL_MVM_REF_AP_IBSS
);
1616 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
1617 if (vif
->p2p
&& mvm
->p2p_device_vif
)
1618 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false);
1620 iwl_mvm_update_quotas(mvm
, NULL
);
1621 iwl_mvm_send_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
1622 iwl_mvm_binding_remove_vif(mvm
, vif
);
1624 iwl_mvm_power_update_mac(mvm
);
1626 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1628 mutex_unlock(&mvm
->mutex
);
1632 iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm
*mvm
,
1633 struct ieee80211_vif
*vif
,
1634 struct ieee80211_bss_conf
*bss_conf
,
1637 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1639 /* Changes will be applied when the AP/IBSS is started */
1640 if (!mvmvif
->ap_ibss_active
)
1643 if (changes
& (BSS_CHANGED_ERP_CTS_PROT
| BSS_CHANGED_HT
|
1644 BSS_CHANGED_BANDWIDTH
) &&
1645 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false))
1646 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
1648 /* Need to send a new beacon template to the FW */
1649 if (changes
& BSS_CHANGED_BEACON
&&
1650 iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
))
1651 IWL_WARN(mvm
, "Failed updating beacon data\n");
1654 static void iwl_mvm_bss_info_changed(struct ieee80211_hw
*hw
,
1655 struct ieee80211_vif
*vif
,
1656 struct ieee80211_bss_conf
*bss_conf
,
1659 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1661 mutex_lock(&mvm
->mutex
);
1663 if (changes
& BSS_CHANGED_IDLE
&& !bss_conf
->idle
)
1664 iwl_mvm_scan_offload_stop(mvm
, true);
1666 switch (vif
->type
) {
1667 case NL80211_IFTYPE_STATION
:
1668 iwl_mvm_bss_info_changed_station(mvm
, vif
, bss_conf
, changes
);
1670 case NL80211_IFTYPE_AP
:
1671 case NL80211_IFTYPE_ADHOC
:
1672 iwl_mvm_bss_info_changed_ap_ibss(mvm
, vif
, bss_conf
, changes
);
1675 /* shouldn't happen */
1679 mutex_unlock(&mvm
->mutex
);
1682 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw
*hw
,
1683 struct ieee80211_vif
*vif
,
1684 struct ieee80211_scan_request
*hw_req
)
1686 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1687 struct cfg80211_scan_request
*req
= &hw_req
->req
;
1690 if (req
->n_channels
== 0 ||
1691 req
->n_channels
> mvm
->fw
->ucode_capa
.n_scan_channels
)
1694 mutex_lock(&mvm
->mutex
);
1696 switch (mvm
->scan_status
) {
1697 case IWL_MVM_SCAN_SCHED
:
1698 ret
= iwl_mvm_scan_offload_stop(mvm
, true);
1704 case IWL_MVM_SCAN_NONE
:
1711 iwl_mvm_ref(mvm
, IWL_MVM_REF_SCAN
);
1713 if (mvm
->fw
->ucode_capa
.api
[0] & IWL_UCODE_TLV_API_LMAC_SCAN
)
1714 ret
= iwl_mvm_unified_scan_lmac(mvm
, vif
, hw_req
);
1716 ret
= iwl_mvm_scan_request(mvm
, vif
, req
);
1719 iwl_mvm_unref(mvm
, IWL_MVM_REF_SCAN
);
1721 mutex_unlock(&mvm
->mutex
);
1722 /* make sure to flush the Rx handler before the next scan arrives */
1723 iwl_mvm_wait_for_async_handlers(mvm
);
1727 static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw
*hw
,
1728 struct ieee80211_vif
*vif
)
1730 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1732 mutex_lock(&mvm
->mutex
);
1734 iwl_mvm_cancel_scan(mvm
);
1736 mutex_unlock(&mvm
->mutex
);
1740 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw
*hw
,
1741 struct ieee80211_sta
*sta
, u16 tids
,
1743 enum ieee80211_frame_release_type reason
,
1746 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1748 /* Called when we need to transmit (a) frame(s) from mac80211 */
1750 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
1751 tids
, more_data
, false);
1755 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw
*hw
,
1756 struct ieee80211_sta
*sta
, u16 tids
,
1758 enum ieee80211_frame_release_type reason
,
1761 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1763 /* Called when we need to transmit (a) frame(s) from agg queue */
1765 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
1766 tids
, more_data
, true);
1769 static void iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
,
1770 struct ieee80211_vif
*vif
,
1771 enum sta_notify_cmd cmd
,
1772 struct ieee80211_sta
*sta
)
1774 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1775 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
1779 case STA_NOTIFY_SLEEP
:
1780 if (atomic_read(&mvm
->pending_frames
[mvmsta
->sta_id
]) > 0)
1781 ieee80211_sta_block_awake(hw
, sta
, true);
1782 spin_lock_bh(&mvmsta
->lock
);
1783 for (tid
= 0; tid
< IWL_MAX_TID_COUNT
; tid
++) {
1784 struct iwl_mvm_tid_data
*tid_data
;
1786 tid_data
= &mvmsta
->tid_data
[tid
];
1787 if (tid_data
->state
!= IWL_AGG_ON
&&
1788 tid_data
->state
!= IWL_EMPTYING_HW_QUEUE_DELBA
)
1790 if (iwl_mvm_tid_queued(tid_data
) == 0)
1792 ieee80211_sta_set_buffered(sta
, tid
, true);
1794 spin_unlock_bh(&mvmsta
->lock
);
1796 * The fw updates the STA to be asleep. Tx packets on the Tx
1797 * queues to this station will not be transmitted. The fw will
1798 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
1801 case STA_NOTIFY_AWAKE
:
1802 if (WARN_ON(mvmsta
->sta_id
== IWL_MVM_STATION_COUNT
))
1804 iwl_mvm_sta_modify_ps_wake(mvm
, sta
);
1811 static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw
*hw
,
1812 struct ieee80211_vif
*vif
,
1813 struct ieee80211_sta
*sta
)
1815 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1816 struct iwl_mvm_sta
*mvm_sta
= (void *)sta
->drv_priv
;
1819 * This is called before mac80211 does RCU synchronisation,
1820 * so here we already invalidate our internal RCU-protected
1821 * station pointer. The rest of the code will thus no longer
1822 * be able to find the station this way, and we don't rely
1823 * on further RCU synchronisation after the sta_state()
1824 * callback deleted the station.
1826 mutex_lock(&mvm
->mutex
);
1827 if (sta
== rcu_access_pointer(mvm
->fw_id_to_mac_id
[mvm_sta
->sta_id
]))
1828 rcu_assign_pointer(mvm
->fw_id_to_mac_id
[mvm_sta
->sta_id
],
1830 mutex_unlock(&mvm
->mutex
);
1833 static int iwl_mvm_mac_sta_state(struct ieee80211_hw
*hw
,
1834 struct ieee80211_vif
*vif
,
1835 struct ieee80211_sta
*sta
,
1836 enum ieee80211_sta_state old_state
,
1837 enum ieee80211_sta_state new_state
)
1839 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1840 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1843 IWL_DEBUG_MAC80211(mvm
, "station %pM state change %d->%d\n",
1844 sta
->addr
, old_state
, new_state
);
1846 /* this would be a mac80211 bug ... but don't crash */
1847 if (WARN_ON_ONCE(!mvmvif
->phy_ctxt
))
1850 /* if a STA is being removed, reuse its ID */
1851 flush_work(&mvm
->sta_drained_wk
);
1853 mutex_lock(&mvm
->mutex
);
1854 if (old_state
== IEEE80211_STA_NOTEXIST
&&
1855 new_state
== IEEE80211_STA_NONE
) {
1857 * Firmware bug - it'll crash if the beacon interval is less
1858 * than 16. We can't avoid connecting at all, so refuse the
1859 * station state change, this will cause mac80211 to abandon
1860 * attempts to connect to this AP, and eventually wpa_s will
1861 * blacklist the AP...
1863 if (vif
->type
== NL80211_IFTYPE_STATION
&&
1864 vif
->bss_conf
.beacon_int
< 16) {
1866 "AP %pM beacon interval is %d, refusing due to firmware bug!\n",
1867 sta
->addr
, vif
->bss_conf
.beacon_int
);
1871 ret
= iwl_mvm_add_sta(mvm
, vif
, sta
);
1872 } else if (old_state
== IEEE80211_STA_NONE
&&
1873 new_state
== IEEE80211_STA_AUTH
) {
1875 * EBS may be disabled due to previous failures reported by FW.
1876 * Reset EBS status here assuming environment has been changed.
1878 mvm
->last_ebs_successful
= true;
1880 } else if (old_state
== IEEE80211_STA_AUTH
&&
1881 new_state
== IEEE80211_STA_ASSOC
) {
1882 ret
= iwl_mvm_update_sta(mvm
, vif
, sta
);
1884 iwl_mvm_rs_rate_init(mvm
, sta
,
1885 mvmvif
->phy_ctxt
->channel
->band
,
1887 } else if (old_state
== IEEE80211_STA_ASSOC
&&
1888 new_state
== IEEE80211_STA_AUTHORIZED
) {
1889 /* enable beacon filtering */
1890 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
, 0));
1892 } else if (old_state
== IEEE80211_STA_AUTHORIZED
&&
1893 new_state
== IEEE80211_STA_ASSOC
) {
1894 /* disable beacon filtering */
1895 WARN_ON(iwl_mvm_disable_beacon_filter(mvm
, vif
, 0));
1897 } else if (old_state
== IEEE80211_STA_ASSOC
&&
1898 new_state
== IEEE80211_STA_AUTH
) {
1900 } else if (old_state
== IEEE80211_STA_AUTH
&&
1901 new_state
== IEEE80211_STA_NONE
) {
1903 } else if (old_state
== IEEE80211_STA_NONE
&&
1904 new_state
== IEEE80211_STA_NOTEXIST
) {
1905 ret
= iwl_mvm_rm_sta(mvm
, vif
, sta
);
1910 mutex_unlock(&mvm
->mutex
);
1915 static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
1917 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1919 mvm
->rts_threshold
= value
;
1924 static void iwl_mvm_sta_rc_update(struct ieee80211_hw
*hw
,
1925 struct ieee80211_vif
*vif
,
1926 struct ieee80211_sta
*sta
, u32 changed
)
1928 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1930 if (vif
->type
== NL80211_IFTYPE_STATION
&&
1931 changed
& IEEE80211_RC_NSS_CHANGED
)
1932 iwl_mvm_sf_update(mvm
, vif
, false);
1935 static int iwl_mvm_mac_conf_tx(struct ieee80211_hw
*hw
,
1936 struct ieee80211_vif
*vif
, u16 ac
,
1937 const struct ieee80211_tx_queue_params
*params
)
1939 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1940 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1942 mvmvif
->queue_params
[ac
] = *params
;
1945 * No need to update right away, we'll get BSS_CHANGED_QOS
1946 * The exception is P2P_DEVICE interface which needs immediate update.
1948 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1951 mutex_lock(&mvm
->mutex
);
1952 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false);
1953 mutex_unlock(&mvm
->mutex
);
1959 static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw
*hw
,
1960 struct ieee80211_vif
*vif
)
1962 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1963 u32 duration
= min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS
,
1964 200 + vif
->bss_conf
.beacon_int
);
1965 u32 min_duration
= min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS
,
1966 100 + vif
->bss_conf
.beacon_int
);
1968 if (WARN_ON_ONCE(vif
->bss_conf
.assoc
))
1971 mutex_lock(&mvm
->mutex
);
1972 /* Try really hard to protect the session and hear a beacon */
1973 iwl_mvm_protect_session(mvm
, vif
, duration
, min_duration
, 500);
1974 mutex_unlock(&mvm
->mutex
);
1977 static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw
*hw
,
1978 struct ieee80211_vif
*vif
,
1979 struct cfg80211_sched_scan_request
*req
,
1980 struct ieee80211_scan_ies
*ies
)
1982 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1985 mutex_lock(&mvm
->mutex
);
1987 if (!iwl_mvm_is_idle(mvm
)) {
1992 switch (mvm
->scan_status
) {
1993 case IWL_MVM_SCAN_OS
:
1994 IWL_DEBUG_SCAN(mvm
, "Stopping previous scan for sched_scan\n");
1995 ret
= iwl_mvm_cancel_scan(mvm
);
2002 * iwl_mvm_rx_scan_complete() will be called soon but will
2003 * not reset the scan status as it won't be IWL_MVM_SCAN_OS
2004 * any more since we queue the next scan immediately (below).
2005 * We make sure it is called before the next scan starts by
2006 * flushing the async-handlers work.
2009 case IWL_MVM_SCAN_NONE
:
2016 mvm
->scan_status
= IWL_MVM_SCAN_SCHED
;
2018 if (!(mvm
->fw
->ucode_capa
.api
[0] & IWL_UCODE_TLV_API_LMAC_SCAN
)) {
2019 ret
= iwl_mvm_config_sched_scan(mvm
, vif
, req
, ies
);
2024 ret
= iwl_mvm_config_sched_scan_profiles(mvm
, req
);
2028 if (mvm
->fw
->ucode_capa
.api
[0] & IWL_UCODE_TLV_API_LMAC_SCAN
)
2029 ret
= iwl_mvm_unified_sched_scan_lmac(mvm
, vif
, req
, ies
);
2031 ret
= iwl_mvm_sched_scan_start(mvm
, req
);
2036 mvm
->scan_status
= IWL_MVM_SCAN_NONE
;
2038 mutex_unlock(&mvm
->mutex
);
2039 /* make sure to flush the Rx handler before the next scan arrives */
2040 iwl_mvm_wait_for_async_handlers(mvm
);
2044 static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw
*hw
,
2045 struct ieee80211_vif
*vif
)
2047 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2050 mutex_lock(&mvm
->mutex
);
2051 ret
= iwl_mvm_scan_offload_stop(mvm
, false);
2052 mutex_unlock(&mvm
->mutex
);
2053 iwl_mvm_wait_for_async_handlers(mvm
);
2058 static int iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
,
2059 enum set_key_cmd cmd
,
2060 struct ieee80211_vif
*vif
,
2061 struct ieee80211_sta
*sta
,
2062 struct ieee80211_key_conf
*key
)
2064 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2067 if (iwlwifi_mod_params
.sw_crypto
) {
2068 IWL_DEBUG_MAC80211(mvm
, "leave - hwcrypto disabled\n");
2072 switch (key
->cipher
) {
2073 case WLAN_CIPHER_SUITE_TKIP
:
2074 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
2076 case WLAN_CIPHER_SUITE_CCMP
:
2077 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
2079 case WLAN_CIPHER_SUITE_AES_CMAC
:
2080 WARN_ON_ONCE(!(hw
->flags
& IEEE80211_HW_MFP_CAPABLE
));
2082 case WLAN_CIPHER_SUITE_WEP40
:
2083 case WLAN_CIPHER_SUITE_WEP104
:
2085 * Support for TX only, at least for now, so accept
2086 * the key and do nothing else. Then mac80211 will
2087 * pass it for TX but we don't have to use it for RX.
2091 /* currently FW supports only one optional cipher scheme */
2092 if (hw
->n_cipher_schemes
&&
2093 hw
->cipher_schemes
->cipher
== key
->cipher
)
2094 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
2099 mutex_lock(&mvm
->mutex
);
2103 if ((vif
->type
== NL80211_IFTYPE_ADHOC
||
2104 vif
->type
== NL80211_IFTYPE_AP
) && !sta
) {
2106 * GTK on AP interface is a TX-only key, return 0;
2107 * on IBSS they're per-station and because we're lazy
2108 * we don't support them for RX, so do the same.
2111 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
2115 IWL_DEBUG_MAC80211(mvm
, "set hwcrypto key\n");
2116 ret
= iwl_mvm_set_sta_key(mvm
, vif
, sta
, key
, false);
2118 IWL_WARN(mvm
, "set key failed\n");
2120 * can't add key for RX, but we don't need it
2121 * in the device for TX so still return 0
2123 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
2129 if (key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
2134 IWL_DEBUG_MAC80211(mvm
, "disable hwcrypto key\n");
2135 ret
= iwl_mvm_remove_sta_key(mvm
, vif
, sta
, key
);
2141 mutex_unlock(&mvm
->mutex
);
2145 static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw
*hw
,
2146 struct ieee80211_vif
*vif
,
2147 struct ieee80211_key_conf
*keyconf
,
2148 struct ieee80211_sta
*sta
,
2149 u32 iv32
, u16
*phase1key
)
2151 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2153 if (keyconf
->hw_key_idx
== STA_KEY_IDX_INVALID
)
2156 iwl_mvm_update_tkip_key(mvm
, vif
, keyconf
, sta
, iv32
, phase1key
);
2160 static int iwl_mvm_roc(struct ieee80211_hw
*hw
,
2161 struct ieee80211_vif
*vif
,
2162 struct ieee80211_channel
*channel
,
2164 enum ieee80211_roc_type type
)
2166 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2167 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2168 struct cfg80211_chan_def chandef
;
2169 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
2172 IWL_DEBUG_MAC80211(mvm
, "enter (%d, %d, %d)\n", channel
->hw_value
,
2175 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
) {
2176 IWL_ERR(mvm
, "vif isn't a P2P_DEVICE: %d\n", vif
->type
);
2180 mutex_lock(&mvm
->mutex
);
2182 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
2183 phy_ctxt
= &mvm
->phy_ctxts
[i
];
2184 if (phy_ctxt
->ref
== 0 || mvmvif
->phy_ctxt
== phy_ctxt
)
2187 if (phy_ctxt
->ref
&& channel
== phy_ctxt
->channel
) {
2189 * Unbind the P2P_DEVICE from the current PHY context,
2190 * and if the PHY context is not used remove it.
2192 ret
= iwl_mvm_binding_remove_vif(mvm
, vif
);
2193 if (WARN(ret
, "Failed unbinding P2P_DEVICE\n"))
2196 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
2198 /* Bind the P2P_DEVICE to the current PHY Context */
2199 mvmvif
->phy_ctxt
= phy_ctxt
;
2201 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2202 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
2205 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
2206 goto schedule_time_event
;
2210 /* Need to update the PHY context only if the ROC channel changed */
2211 if (channel
== mvmvif
->phy_ctxt
->channel
)
2212 goto schedule_time_event
;
2214 cfg80211_chandef_create(&chandef
, channel
, NL80211_CHAN_NO_HT
);
2217 * Change the PHY context configuration as it is currently referenced
2218 * only by the P2P Device MAC
2220 if (mvmvif
->phy_ctxt
->ref
== 1) {
2221 ret
= iwl_mvm_phy_ctxt_changed(mvm
, mvmvif
->phy_ctxt
,
2227 * The PHY context is shared with other MACs. Need to remove the
2228 * P2P Device from the binding, allocate an new PHY context and
2229 * create a new binding
2231 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
2237 ret
= iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &chandef
,
2240 IWL_ERR(mvm
, "Failed to change PHY context\n");
2244 /* Unbind the P2P_DEVICE from the current PHY context */
2245 ret
= iwl_mvm_binding_remove_vif(mvm
, vif
);
2246 if (WARN(ret
, "Failed unbinding P2P_DEVICE\n"))
2249 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
2251 /* Bind the P2P_DEVICE to the new allocated PHY context */
2252 mvmvif
->phy_ctxt
= phy_ctxt
;
2254 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2255 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
2258 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
2261 schedule_time_event
:
2262 /* Schedule the time events */
2263 ret
= iwl_mvm_start_p2p_roc(mvm
, vif
, duration
, type
);
2266 mutex_unlock(&mvm
->mutex
);
2267 IWL_DEBUG_MAC80211(mvm
, "leave\n");
2271 static int iwl_mvm_cancel_roc(struct ieee80211_hw
*hw
)
2273 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2275 IWL_DEBUG_MAC80211(mvm
, "enter\n");
2277 mutex_lock(&mvm
->mutex
);
2278 iwl_mvm_stop_p2p_roc(mvm
);
2279 mutex_unlock(&mvm
->mutex
);
2281 IWL_DEBUG_MAC80211(mvm
, "leave\n");
2285 static int iwl_mvm_add_chanctx(struct ieee80211_hw
*hw
,
2286 struct ieee80211_chanctx_conf
*ctx
)
2288 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2289 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2290 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
2293 IWL_DEBUG_MAC80211(mvm
, "Add channel context\n");
2295 mutex_lock(&mvm
->mutex
);
2296 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
2302 ret
= iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->min_def
,
2303 ctx
->rx_chains_static
,
2304 ctx
->rx_chains_dynamic
);
2306 IWL_ERR(mvm
, "Failed to add PHY context\n");
2310 iwl_mvm_phy_ctxt_ref(mvm
, phy_ctxt
);
2311 *phy_ctxt_id
= phy_ctxt
->id
;
2313 mutex_unlock(&mvm
->mutex
);
2317 static void iwl_mvm_remove_chanctx(struct ieee80211_hw
*hw
,
2318 struct ieee80211_chanctx_conf
*ctx
)
2320 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2321 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2322 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
2324 mutex_lock(&mvm
->mutex
);
2325 iwl_mvm_phy_ctxt_unref(mvm
, phy_ctxt
);
2326 mutex_unlock(&mvm
->mutex
);
2329 static void iwl_mvm_change_chanctx(struct ieee80211_hw
*hw
,
2330 struct ieee80211_chanctx_conf
*ctx
,
2333 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2334 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2335 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
2337 if (WARN_ONCE((phy_ctxt
->ref
> 1) &&
2338 (changed
& ~(IEEE80211_CHANCTX_CHANGE_WIDTH
|
2339 IEEE80211_CHANCTX_CHANGE_RX_CHAINS
|
2340 IEEE80211_CHANCTX_CHANGE_RADAR
|
2341 IEEE80211_CHANCTX_CHANGE_MIN_WIDTH
)),
2342 "Cannot change PHY. Ref=%d, changed=0x%X\n",
2343 phy_ctxt
->ref
, changed
))
2346 mutex_lock(&mvm
->mutex
);
2347 iwl_mvm_bt_coex_vif_change(mvm
);
2348 iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->min_def
,
2349 ctx
->rx_chains_static
,
2350 ctx
->rx_chains_dynamic
);
2351 mutex_unlock(&mvm
->mutex
);
2354 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw
*hw
,
2355 struct ieee80211_vif
*vif
,
2356 struct ieee80211_chanctx_conf
*ctx
)
2358 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2359 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2360 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
2361 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2364 mutex_lock(&mvm
->mutex
);
2366 mvmvif
->phy_ctxt
= phy_ctxt
;
2368 switch (vif
->type
) {
2369 case NL80211_IFTYPE_AP
:
2370 /* Unless it's a CSA flow we have nothing to do here */
2371 if (vif
->csa_active
) {
2372 mvmvif
->ap_ibss_active
= true;
2375 case NL80211_IFTYPE_ADHOC
:
2377 * The AP binding flow is handled as part of the start_ap flow
2378 * (in bss_info_changed), similarly for IBSS.
2382 case NL80211_IFTYPE_STATION
:
2383 case NL80211_IFTYPE_MONITOR
:
2390 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2395 * Power state must be updated before quotas,
2396 * otherwise fw will complain.
2398 iwl_mvm_power_update_mac(mvm
);
2400 /* Setting the quota at this stage is only required for monitor
2401 * interfaces. For the other types, the bss_info changed flow
2402 * will handle quota settings.
2404 if (vif
->type
== NL80211_IFTYPE_MONITOR
) {
2405 mvmvif
->monitor_active
= true;
2406 ret
= iwl_mvm_update_quotas(mvm
, vif
);
2408 goto out_remove_binding
;
2411 /* Handle binding during CSA */
2412 if (vif
->type
== NL80211_IFTYPE_AP
) {
2413 iwl_mvm_update_quotas(mvm
, vif
);
2414 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false);
2420 iwl_mvm_binding_remove_vif(mvm
, vif
);
2421 iwl_mvm_power_update_mac(mvm
);
2423 mutex_unlock(&mvm
->mutex
);
2425 mvmvif
->phy_ctxt
= NULL
;
2429 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw
*hw
,
2430 struct ieee80211_vif
*vif
,
2431 struct ieee80211_chanctx_conf
*ctx
)
2433 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2434 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2436 mutex_lock(&mvm
->mutex
);
2438 iwl_mvm_remove_time_event(mvm
, mvmvif
, &mvmvif
->time_event_data
);
2440 switch (vif
->type
) {
2441 case NL80211_IFTYPE_ADHOC
:
2443 case NL80211_IFTYPE_MONITOR
:
2444 mvmvif
->monitor_active
= false;
2445 iwl_mvm_update_quotas(mvm
, NULL
);
2447 case NL80211_IFTYPE_AP
:
2448 /* This part is triggered only during CSA */
2449 if (!vif
->csa_active
|| !mvmvif
->ap_ibss_active
)
2452 mvmvif
->ap_ibss_active
= false;
2453 iwl_mvm_update_quotas(mvm
, NULL
);
2454 /*TODO: bt_coex notification here? */
2459 iwl_mvm_binding_remove_vif(mvm
, vif
);
2462 mvmvif
->phy_ctxt
= NULL
;
2463 iwl_mvm_power_update_mac(mvm
);
2464 mutex_unlock(&mvm
->mutex
);
2467 static int iwl_mvm_set_tim(struct ieee80211_hw
*hw
,
2468 struct ieee80211_sta
*sta
,
2471 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2472 struct iwl_mvm_sta
*mvm_sta
= (void *)sta
->drv_priv
;
2474 if (!mvm_sta
|| !mvm_sta
->vif
) {
2475 IWL_ERR(mvm
, "Station is not associated to a vif\n");
2479 return iwl_mvm_mac_ctxt_beacon_changed(mvm
, mvm_sta
->vif
);
2482 #ifdef CONFIG_NL80211_TESTMODE
2483 static const struct nla_policy iwl_mvm_tm_policy
[IWL_MVM_TM_ATTR_MAX
+ 1] = {
2484 [IWL_MVM_TM_ATTR_CMD
] = { .type
= NLA_U32
},
2485 [IWL_MVM_TM_ATTR_NOA_DURATION
] = { .type
= NLA_U32
},
2486 [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
] = { .type
= NLA_U32
},
2489 static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm
*mvm
,
2490 struct ieee80211_vif
*vif
,
2491 void *data
, int len
)
2493 struct nlattr
*tb
[IWL_MVM_TM_ATTR_MAX
+ 1];
2497 err
= nla_parse(tb
, IWL_MVM_TM_ATTR_MAX
, data
, len
, iwl_mvm_tm_policy
);
2501 if (!tb
[IWL_MVM_TM_ATTR_CMD
])
2504 switch (nla_get_u32(tb
[IWL_MVM_TM_ATTR_CMD
])) {
2505 case IWL_MVM_TM_CMD_SET_NOA
:
2506 if (!vif
|| vif
->type
!= NL80211_IFTYPE_AP
|| !vif
->p2p
||
2507 !vif
->bss_conf
.enable_beacon
||
2508 !tb
[IWL_MVM_TM_ATTR_NOA_DURATION
])
2511 noa_duration
= nla_get_u32(tb
[IWL_MVM_TM_ATTR_NOA_DURATION
]);
2512 if (noa_duration
>= vif
->bss_conf
.beacon_int
)
2515 mvm
->noa_duration
= noa_duration
;
2518 return iwl_mvm_update_quotas(mvm
, NULL
);
2519 case IWL_MVM_TM_CMD_SET_BEACON_FILTER
:
2520 /* must be associated client vif - ignore authorized */
2521 if (!vif
|| vif
->type
!= NL80211_IFTYPE_STATION
||
2522 !vif
->bss_conf
.assoc
|| !vif
->bss_conf
.dtim_period
||
2523 !tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
])
2526 if (nla_get_u32(tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
]))
2527 return iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
2528 return iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
2534 static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw
*hw
,
2535 struct ieee80211_vif
*vif
,
2536 void *data
, int len
)
2538 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2541 mutex_lock(&mvm
->mutex
);
2542 err
= __iwl_mvm_mac_testmode_cmd(mvm
, vif
, data
, len
);
2543 mutex_unlock(&mvm
->mutex
);
2549 static void iwl_mvm_channel_switch_beacon(struct ieee80211_hw
*hw
,
2550 struct ieee80211_vif
*vif
,
2551 struct cfg80211_chan_def
*chandef
)
2553 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2555 mutex_lock(&mvm
->mutex
);
2556 if (WARN(mvm
->csa_vif
&& mvm
->csa_vif
->csa_active
,
2557 "Another CSA is already in progress"))
2560 IWL_DEBUG_MAC80211(mvm
, "CSA started to freq %d\n",
2561 chandef
->center_freq1
);
2565 mutex_unlock(&mvm
->mutex
);
2568 static void iwl_mvm_mac_flush(struct ieee80211_hw
*hw
,
2569 struct ieee80211_vif
*vif
, u32 queues
, bool drop
)
2571 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2572 struct iwl_mvm_vif
*mvmvif
;
2573 struct iwl_mvm_sta
*mvmsta
;
2575 if (!vif
|| vif
->type
!= NL80211_IFTYPE_STATION
)
2578 mutex_lock(&mvm
->mutex
);
2579 mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2580 mvmsta
= iwl_mvm_sta_from_staid_protected(mvm
, mvmvif
->ap_sta_id
);
2582 if (WARN_ON_ONCE(!mvmsta
))
2586 if (iwl_mvm_flush_tx_path(mvm
, mvmsta
->tfd_queue_msk
, true))
2587 IWL_ERR(mvm
, "flush request fail\n");
2589 iwl_trans_wait_tx_queue_empty(mvm
->trans
,
2590 mvmsta
->tfd_queue_msk
);
2593 mutex_unlock(&mvm
->mutex
);
2596 const struct ieee80211_ops iwl_mvm_hw_ops
= {
2597 .tx
= iwl_mvm_mac_tx
,
2598 .ampdu_action
= iwl_mvm_mac_ampdu_action
,
2599 .start
= iwl_mvm_mac_start
,
2600 .restart_complete
= iwl_mvm_mac_restart_complete
,
2601 .stop
= iwl_mvm_mac_stop
,
2602 .add_interface
= iwl_mvm_mac_add_interface
,
2603 .remove_interface
= iwl_mvm_mac_remove_interface
,
2604 .config
= iwl_mvm_mac_config
,
2605 .prepare_multicast
= iwl_mvm_prepare_multicast
,
2606 .configure_filter
= iwl_mvm_configure_filter
,
2607 .bss_info_changed
= iwl_mvm_bss_info_changed
,
2608 .hw_scan
= iwl_mvm_mac_hw_scan
,
2609 .cancel_hw_scan
= iwl_mvm_mac_cancel_hw_scan
,
2610 .sta_pre_rcu_remove
= iwl_mvm_sta_pre_rcu_remove
,
2611 .sta_state
= iwl_mvm_mac_sta_state
,
2612 .sta_notify
= iwl_mvm_mac_sta_notify
,
2613 .allow_buffered_frames
= iwl_mvm_mac_allow_buffered_frames
,
2614 .release_buffered_frames
= iwl_mvm_mac_release_buffered_frames
,
2615 .set_rts_threshold
= iwl_mvm_mac_set_rts_threshold
,
2616 .sta_rc_update
= iwl_mvm_sta_rc_update
,
2617 .conf_tx
= iwl_mvm_mac_conf_tx
,
2618 .mgd_prepare_tx
= iwl_mvm_mac_mgd_prepare_tx
,
2619 .flush
= iwl_mvm_mac_flush
,
2620 .sched_scan_start
= iwl_mvm_mac_sched_scan_start
,
2621 .sched_scan_stop
= iwl_mvm_mac_sched_scan_stop
,
2622 .set_key
= iwl_mvm_mac_set_key
,
2623 .update_tkip_key
= iwl_mvm_mac_update_tkip_key
,
2624 .remain_on_channel
= iwl_mvm_roc
,
2625 .cancel_remain_on_channel
= iwl_mvm_cancel_roc
,
2626 .add_chanctx
= iwl_mvm_add_chanctx
,
2627 .remove_chanctx
= iwl_mvm_remove_chanctx
,
2628 .change_chanctx
= iwl_mvm_change_chanctx
,
2629 .assign_vif_chanctx
= iwl_mvm_assign_vif_chanctx
,
2630 .unassign_vif_chanctx
= iwl_mvm_unassign_vif_chanctx
,
2632 .start_ap
= iwl_mvm_start_ap_ibss
,
2633 .stop_ap
= iwl_mvm_stop_ap_ibss
,
2634 .join_ibss
= iwl_mvm_start_ap_ibss
,
2635 .leave_ibss
= iwl_mvm_stop_ap_ibss
,
2637 .set_tim
= iwl_mvm_set_tim
,
2639 .channel_switch_beacon
= iwl_mvm_channel_switch_beacon
,
2641 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd
)
2643 #ifdef CONFIG_PM_SLEEP
2645 .suspend
= iwl_mvm_suspend
,
2646 .resume
= iwl_mvm_resume
,
2647 .set_wakeup
= iwl_mvm_set_wakeup
,
2648 .set_rekey_data
= iwl_mvm_set_rekey_data
,
2649 #if IS_ENABLED(CONFIG_IPV6)
2650 .ipv6_addr_change
= iwl_mvm_ipv6_addr_change
,
2652 .set_default_unicast_key
= iwl_mvm_set_default_unicast_key
,