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 hw
->sta_data_size
= sizeof(struct iwl_mvm_sta
);
331 hw
->vif_data_size
= sizeof(struct iwl_mvm_vif
);
332 hw
->chanctx_data_size
= sizeof(u16
);
334 hw
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
335 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
336 BIT(NL80211_IFTYPE_AP
) |
337 BIT(NL80211_IFTYPE_P2P_GO
) |
338 BIT(NL80211_IFTYPE_P2P_DEVICE
) |
339 BIT(NL80211_IFTYPE_ADHOC
);
341 hw
->wiphy
->flags
|= WIPHY_FLAG_IBSS_RSN
;
342 hw
->wiphy
->regulatory_flags
|= REGULATORY_CUSTOM_REG
|
343 REGULATORY_DISABLE_BEACON_HINTS
;
345 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_GO_UAPSD
)
346 hw
->wiphy
->flags
|= WIPHY_FLAG_AP_UAPSD
;
348 if (mvm
->fw
->ucode_capa
.api
[0] & IWL_UCODE_TLV_API_CSA_FLOW
)
349 hw
->wiphy
->flags
|= WIPHY_FLAG_HAS_CHANNEL_SWITCH
;
351 hw
->wiphy
->iface_combinations
= iwl_mvm_iface_combinations
;
352 hw
->wiphy
->n_iface_combinations
=
353 ARRAY_SIZE(iwl_mvm_iface_combinations
);
355 hw
->wiphy
->max_remain_on_channel_duration
= 10000;
356 hw
->max_listen_interval
= IWL_CONN_MAX_LISTEN_INTERVAL
;
358 /* Extract MAC address */
359 memcpy(mvm
->addresses
[0].addr
, mvm
->nvm_data
->hw_addr
, ETH_ALEN
);
360 hw
->wiphy
->addresses
= mvm
->addresses
;
361 hw
->wiphy
->n_addresses
= 1;
363 /* Extract additional MAC addresses if available */
364 num_mac
= (mvm
->nvm_data
->n_hw_addrs
> 1) ?
365 min(IWL_MVM_MAX_ADDRESSES
, mvm
->nvm_data
->n_hw_addrs
) : 1;
367 for (i
= 1; i
< num_mac
; i
++) {
368 memcpy(mvm
->addresses
[i
].addr
, mvm
->addresses
[i
-1].addr
,
370 mvm
->addresses
[i
].addr
[5]++;
371 hw
->wiphy
->n_addresses
++;
374 iwl_mvm_reset_phy_ctxts(mvm
);
376 hw
->wiphy
->max_scan_ie_len
= iwl_mvm_max_scan_ie_len(mvm
);
378 hw
->wiphy
->max_scan_ssids
= PROBE_OPTION_MAX
;
380 if (mvm
->nvm_data
->bands
[IEEE80211_BAND_2GHZ
].n_channels
)
381 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] =
382 &mvm
->nvm_data
->bands
[IEEE80211_BAND_2GHZ
];
383 if (mvm
->nvm_data
->bands
[IEEE80211_BAND_5GHZ
].n_channels
)
384 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] =
385 &mvm
->nvm_data
->bands
[IEEE80211_BAND_5GHZ
];
387 hw
->wiphy
->hw_version
= mvm
->trans
->hw_id
;
389 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
)
390 hw
->wiphy
->flags
|= WIPHY_FLAG_PS_ON_BY_DEFAULT
;
392 hw
->wiphy
->flags
&= ~WIPHY_FLAG_PS_ON_BY_DEFAULT
;
394 hw
->wiphy
->flags
|= WIPHY_FLAG_SUPPORTS_SCHED_SCAN
;
395 hw
->wiphy
->max_sched_scan_ssids
= PROBE_OPTION_MAX
;
396 hw
->wiphy
->max_match_sets
= IWL_SCAN_MAX_PROFILES
;
397 /* we create the 802.11 header and zero length SSID IE. */
398 hw
->wiphy
->max_sched_scan_ie_len
= SCAN_OFFLOAD_PROBE_REQ_SIZE
- 24 - 2;
400 hw
->wiphy
->features
|= NL80211_FEATURE_P2P_GO_CTWIN
|
401 NL80211_FEATURE_LOW_PRIORITY_SCAN
|
402 NL80211_FEATURE_P2P_GO_OPPPS
;
404 mvm
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
406 /* currently FW API supports only one optional cipher scheme */
407 if (mvm
->fw
->cs
[0].cipher
) {
408 mvm
->hw
->n_cipher_schemes
= 1;
409 mvm
->hw
->cipher_schemes
= &mvm
->fw
->cs
[0];
412 #ifdef CONFIG_PM_SLEEP
413 if (iwl_mvm_is_d0i3_supported(mvm
) &&
414 device_can_wakeup(mvm
->trans
->dev
)) {
415 mvm
->wowlan
.flags
= WIPHY_WOWLAN_ANY
;
416 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
417 } else if (mvm
->fw
->img
[IWL_UCODE_WOWLAN
].sec
[0].len
&&
418 mvm
->trans
->ops
->d3_suspend
&&
419 mvm
->trans
->ops
->d3_resume
&&
420 device_can_wakeup(mvm
->trans
->dev
)) {
421 mvm
->wowlan
.flags
= WIPHY_WOWLAN_MAGIC_PKT
|
422 WIPHY_WOWLAN_DISCONNECT
|
423 WIPHY_WOWLAN_EAP_IDENTITY_REQ
|
424 WIPHY_WOWLAN_RFKILL_RELEASE
;
425 if (!iwlwifi_mod_params
.sw_crypto
)
426 mvm
->wowlan
.flags
|= WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
427 WIPHY_WOWLAN_GTK_REKEY_FAILURE
|
428 WIPHY_WOWLAN_4WAY_HANDSHAKE
;
430 mvm
->wowlan
.n_patterns
= IWL_WOWLAN_MAX_PATTERNS
;
431 mvm
->wowlan
.pattern_min_len
= IWL_WOWLAN_MIN_PATTERN_LEN
;
432 mvm
->wowlan
.pattern_max_len
= IWL_WOWLAN_MAX_PATTERN_LEN
;
433 mvm
->wowlan
.tcp
= &iwl_mvm_wowlan_tcp_support
;
434 hw
->wiphy
->wowlan
= &mvm
->wowlan
;
438 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
439 /* assign default bcast filtering configuration */
440 mvm
->bcast_filters
= iwl_mvm_default_bcast_filters
;
443 ret
= iwl_mvm_leds_init(mvm
);
447 ret
= ieee80211_register_hw(mvm
->hw
);
449 iwl_mvm_leds_exit(mvm
);
454 static bool iwl_mvm_defer_tx(struct iwl_mvm
*mvm
,
455 struct ieee80211_sta
*sta
,
458 struct iwl_mvm_sta
*mvmsta
;
462 * double check the IN_D0I3 flag both before and after
463 * taking the spinlock, in order to prevent taking
464 * the spinlock when not needed.
466 if (likely(!test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
)))
469 spin_lock(&mvm
->d0i3_tx_lock
);
471 * testing the flag again ensures the skb dequeue
472 * loop (on d0i3 exit) hasn't run yet.
474 if (!test_bit(IWL_MVM_STATUS_IN_D0I3
, &mvm
->status
))
477 mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
478 if (mvmsta
->sta_id
== IWL_MVM_STATION_COUNT
||
479 mvmsta
->sta_id
!= mvm
->d0i3_ap_sta_id
)
482 __skb_queue_tail(&mvm
->d0i3_tx
, skb
);
483 ieee80211_stop_queues(mvm
->hw
);
486 iwl_mvm_ref(mvm
, IWL_MVM_REF_TX
);
487 iwl_mvm_unref(mvm
, IWL_MVM_REF_TX
);
491 spin_unlock(&mvm
->d0i3_tx_lock
);
495 static void iwl_mvm_mac_tx(struct ieee80211_hw
*hw
,
496 struct ieee80211_tx_control
*control
,
499 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
500 struct ieee80211_sta
*sta
= control
->sta
;
501 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
502 struct ieee80211_hdr
*hdr
= (void *)skb
->data
;
504 if (iwl_mvm_is_radio_killed(mvm
)) {
505 IWL_DEBUG_DROP(mvm
, "Dropping - RF/CT KILL\n");
509 if (IEEE80211_SKB_CB(skb
)->hw_queue
== IWL_MVM_OFFCHANNEL_QUEUE
&&
510 !test_bit(IWL_MVM_STATUS_ROC_RUNNING
, &mvm
->status
))
513 /* treat non-bufferable MMPDUs as broadcast if sta is sleeping */
514 if (unlikely(info
->flags
& IEEE80211_TX_CTL_NO_PS_BUFFER
&&
515 ieee80211_is_mgmt(hdr
->frame_control
) &&
516 !ieee80211_is_deauth(hdr
->frame_control
) &&
517 !ieee80211_is_disassoc(hdr
->frame_control
) &&
518 !ieee80211_is_action(hdr
->frame_control
)))
522 if (iwl_mvm_defer_tx(mvm
, sta
, skb
))
524 if (iwl_mvm_tx_skb(mvm
, skb
, sta
))
529 if (iwl_mvm_tx_skb_non_sta(mvm
, skb
))
533 ieee80211_free_txskb(hw
, skb
);
536 static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg
*cfg
)
538 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_RXAGG
)
543 static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg
*cfg
)
545 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_TXAGG
)
547 if (iwlwifi_mod_params
.disable_11n
& IWL_ENABLE_HT_TXAGG
)
550 /* enabled by default */
554 static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw
*hw
,
555 struct ieee80211_vif
*vif
,
556 enum ieee80211_ampdu_mlme_action action
,
557 struct ieee80211_sta
*sta
, u16 tid
,
558 u16
*ssn
, u8 buf_size
)
560 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
562 bool tx_agg_ref
= false;
564 IWL_DEBUG_HT(mvm
, "A-MPDU action on addr %pM tid %d: action %d\n",
565 sta
->addr
, tid
, action
);
567 if (!(mvm
->nvm_data
->sku_cap_11n_enable
))
570 /* return from D0i3 before starting a new Tx aggregation */
572 case IEEE80211_AMPDU_TX_START
:
573 case IEEE80211_AMPDU_TX_STOP_CONT
:
574 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
575 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
576 case IEEE80211_AMPDU_TX_OPERATIONAL
:
578 * for tx start, wait synchronously until D0i3 exit to
579 * get the correct sequence number for the tid.
580 * additionally, some other ampdu actions use direct
581 * target access, which is not handled automatically
582 * by the trans layer (unlike commands), so wait for
583 * d0i3 exit in these cases as well.
585 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_TX_AGG
);
595 mutex_lock(&mvm
->mutex
);
598 case IEEE80211_AMPDU_RX_START
:
599 if (!iwl_enable_rx_ampdu(mvm
->cfg
)) {
603 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, *ssn
, true);
605 case IEEE80211_AMPDU_RX_STOP
:
606 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, 0, false);
608 case IEEE80211_AMPDU_TX_START
:
609 if (!iwl_enable_tx_ampdu(mvm
->cfg
)) {
613 ret
= iwl_mvm_sta_tx_agg_start(mvm
, vif
, sta
, tid
, ssn
);
615 case IEEE80211_AMPDU_TX_STOP_CONT
:
616 ret
= iwl_mvm_sta_tx_agg_stop(mvm
, vif
, sta
, tid
);
618 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
619 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
620 ret
= iwl_mvm_sta_tx_agg_flush(mvm
, vif
, sta
, tid
);
622 case IEEE80211_AMPDU_TX_OPERATIONAL
:
623 ret
= iwl_mvm_sta_tx_agg_oper(mvm
, vif
, sta
, tid
, buf_size
);
630 mutex_unlock(&mvm
->mutex
);
633 * If the tid is marked as started, we won't use it for offloaded
634 * traffic on the next D0i3 entry. It's safe to unref.
637 iwl_mvm_unref(mvm
, IWL_MVM_REF_TX_AGG
);
642 static void iwl_mvm_cleanup_iterator(void *data
, u8
*mac
,
643 struct ieee80211_vif
*vif
)
645 struct iwl_mvm
*mvm
= data
;
646 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
648 mvmvif
->uploaded
= false;
649 mvmvif
->ap_sta_id
= IWL_MVM_STATION_COUNT
;
651 /* does this make sense at all? */
654 spin_lock_bh(&mvm
->time_event_lock
);
655 iwl_mvm_te_clear_data(mvm
, &mvmvif
->time_event_data
);
656 spin_unlock_bh(&mvm
->time_event_lock
);
658 mvmvif
->phy_ctxt
= NULL
;
661 #ifdef CONFIG_IWLWIFI_DEBUGFS
662 static void iwl_mvm_fw_error_dump(struct iwl_mvm
*mvm
)
664 struct iwl_fw_error_dump_file
*dump_file
;
665 struct iwl_fw_error_dump_data
*dump_data
;
666 struct iwl_fw_error_dump_info
*dump_info
;
667 const struct fw_img
*img
;
668 u32 sram_len
, sram_ofs
;
669 u32 file_len
, rxf_len
;
674 lockdep_assert_held(&mvm
->mutex
);
676 if (mvm
->fw_error_dump
)
679 img
= &mvm
->fw
->img
[mvm
->cur_ucode
];
680 sram_ofs
= img
->sec
[IWL_UCODE_SECTION_DATA
].offset
;
681 sram_len
= img
->sec
[IWL_UCODE_SECTION_DATA
].len
;
683 /* reading buffer size */
684 reg_val
= iwl_trans_read_prph(mvm
->trans
, RXF_SIZE_ADDR
);
685 rxf_len
= (reg_val
& RXF_SIZE_BYTE_CNT_MSK
) >> RXF_SIZE_BYTE_CND_POS
;
687 /* the register holds the value divided by 128 */
688 rxf_len
= rxf_len
<< 7;
690 file_len
= sizeof(*dump_file
) +
691 sizeof(*dump_data
) * 3 +
696 trans_len
= iwl_trans_dump_data(mvm
->trans
, NULL
, 0);
698 file_len
+= trans_len
;
700 dump_file
= vzalloc(file_len
);
704 mvm
->fw_error_dump
= dump_file
;
706 dump_file
->barker
= cpu_to_le32(IWL_FW_ERROR_DUMP_BARKER
);
707 dump_file
->file_len
= cpu_to_le32(file_len
);
708 dump_data
= (void *)dump_file
->data
;
710 dump_data
->type
= cpu_to_le32(IWL_FW_ERROR_DUMP_DEV_FW_INFO
);
711 dump_data
->len
= cpu_to_le32(sizeof(*dump_info
));
712 dump_info
= (void *) dump_data
->data
;
713 dump_info
->device_family
=
714 mvm
->cfg
->device_family
== IWL_DEVICE_FAMILY_7000
?
715 cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_7
) :
716 cpu_to_le32(IWL_FW_ERROR_DUMP_FAMILY_8
);
717 memcpy(dump_info
->fw_human_readable
, mvm
->fw
->human_readable
,
718 sizeof(dump_info
->fw_human_readable
));
719 strncpy(dump_info
->dev_human_readable
, mvm
->cfg
->name
,
720 sizeof(dump_info
->dev_human_readable
));
721 strncpy(dump_info
->bus_human_readable
, mvm
->dev
->bus
->name
,
722 sizeof(dump_info
->bus_human_readable
));
724 dump_data
= iwl_fw_error_next_data(dump_data
);
725 dump_data
->type
= cpu_to_le32(IWL_FW_ERROR_DUMP_RXF
);
726 dump_data
->len
= cpu_to_le32(rxf_len
);
728 if (iwl_trans_grab_nic_access(mvm
->trans
, false, &flags
)) {
729 u32
*rxf
= (void *)dump_data
->data
;
732 for (i
= 0; i
< (rxf_len
/ sizeof(u32
)); i
++) {
733 iwl_trans_write_prph(mvm
->trans
,
734 RXF_LD_FENCE_OFFSET_ADDR
,
736 rxf
[i
] = iwl_trans_read_prph(mvm
->trans
,
737 RXF_FIFO_RD_FENCE_ADDR
);
739 iwl_trans_release_nic_access(mvm
->trans
, &flags
);
742 dump_data
= iwl_fw_error_next_data(dump_data
);
743 dump_data
->type
= cpu_to_le32(IWL_FW_ERROR_DUMP_SRAM
);
744 dump_data
->len
= cpu_to_le32(sram_len
);
745 iwl_trans_read_mem_bytes(mvm
->trans
, sram_ofs
, dump_data
->data
,
749 void *buf
= iwl_fw_error_next_data(dump_data
);
750 u32 real_trans_len
= iwl_trans_dump_data(mvm
->trans
, buf
,
752 dump_data
= (void *)((u8
*)buf
+ real_trans_len
);
753 dump_file
->file_len
=
754 cpu_to_le32(file_len
- trans_len
+ real_trans_len
);
759 static void iwl_mvm_restart_cleanup(struct iwl_mvm
*mvm
)
761 #ifdef CONFIG_IWLWIFI_DEBUGFS
762 static char *env
[] = { "DRIVER=iwlwifi", "EVENT=error_dump", NULL
};
764 iwl_mvm_fw_error_dump(mvm
);
766 /* notify the userspace about the error we had */
767 kobject_uevent_env(&mvm
->hw
->wiphy
->dev
.kobj
, KOBJ_CHANGE
, env
);
770 iwl_trans_stop_device(mvm
->trans
);
772 mvm
->scan_status
= IWL_MVM_SCAN_NONE
;
774 /* just in case one was running */
775 ieee80211_remain_on_channel_expired(mvm
->hw
);
777 ieee80211_iterate_active_interfaces_atomic(
778 mvm
->hw
, IEEE80211_IFACE_ITER_RESUME_ALL
,
779 iwl_mvm_cleanup_iterator
, mvm
);
781 mvm
->p2p_device_vif
= NULL
;
782 mvm
->d0i3_ap_sta_id
= IWL_MVM_STATION_COUNT
;
784 iwl_mvm_reset_phy_ctxts(mvm
);
785 memset(mvm
->fw_key_table
, 0, sizeof(mvm
->fw_key_table
));
786 memset(mvm
->sta_drained
, 0, sizeof(mvm
->sta_drained
));
788 ieee80211_wake_queues(mvm
->hw
);
790 /* cleanup all stale references (scan, roc), but keep the
791 * ucode_down ref until reconfig is complete */
792 iwl_mvm_unref_all_except(mvm
, IWL_MVM_REF_UCODE_DOWN
);
795 mvm
->rx_ba_sessions
= 0;
798 static int iwl_mvm_mac_start(struct ieee80211_hw
*hw
)
800 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
803 mutex_lock(&mvm
->mutex
);
805 /* Clean up some internal and mac80211 state on restart */
806 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
807 iwl_mvm_restart_cleanup(mvm
);
809 ret
= iwl_mvm_up(mvm
);
811 if (ret
&& test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
)) {
812 /* Something went wrong - we need to finish some cleanup
813 * that normally iwl_mvm_mac_restart_complete() below
816 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
817 iwl_mvm_d0i3_enable_tx(mvm
, NULL
);
820 mutex_unlock(&mvm
->mutex
);
825 static void iwl_mvm_mac_restart_complete(struct ieee80211_hw
*hw
)
827 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
830 mutex_lock(&mvm
->mutex
);
832 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
833 iwl_mvm_d0i3_enable_tx(mvm
, NULL
);
834 ret
= iwl_mvm_update_quotas(mvm
, NULL
);
836 IWL_ERR(mvm
, "Failed to update quotas after restart (%d)\n",
839 /* allow transport/FW low power modes */
840 iwl_mvm_unref(mvm
, IWL_MVM_REF_UCODE_DOWN
);
842 mutex_unlock(&mvm
->mutex
);
845 static void iwl_mvm_mac_stop(struct ieee80211_hw
*hw
)
847 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
849 flush_work(&mvm
->d0i3_exit_work
);
850 flush_work(&mvm
->async_handlers_wk
);
852 mutex_lock(&mvm
->mutex
);
854 /* disallow low power states when the FW is down */
855 iwl_mvm_ref(mvm
, IWL_MVM_REF_UCODE_DOWN
);
857 /* async_handlers_wk is now blocked */
860 * The work item could be running or queued if the
861 * ROC time event stops just as we get here.
863 cancel_work_sync(&mvm
->roc_done_wk
);
865 iwl_trans_stop_device(mvm
->trans
);
867 iwl_mvm_async_handlers_purge(mvm
);
868 /* async_handlers_list is empty and will stay empty: HW is stopped */
870 /* the fw is stopped, the aux sta is dead: clean up driver state */
871 iwl_mvm_dealloc_int_sta(mvm
, &mvm
->aux_sta
);
873 mutex_unlock(&mvm
->mutex
);
876 * The worker might have been waiting for the mutex, let it run and
877 * discover that its list is now empty.
879 cancel_work_sync(&mvm
->async_handlers_wk
);
882 static struct iwl_mvm_phy_ctxt
*iwl_mvm_get_free_phy_ctxt(struct iwl_mvm
*mvm
)
886 lockdep_assert_held(&mvm
->mutex
);
888 for (i
= 0; i
< NUM_PHY_CTX
; i
++)
889 if (!mvm
->phy_ctxts
[i
].ref
)
890 return &mvm
->phy_ctxts
[i
];
892 IWL_ERR(mvm
, "No available PHY context\n");
896 static int iwl_mvm_set_tx_power(struct iwl_mvm
*mvm
, struct ieee80211_vif
*vif
,
899 /* FW is in charge of regulatory enforcement */
900 struct iwl_reduce_tx_power_cmd reduce_txpwr_cmd
= {
901 .mac_context_id
= iwl_mvm_vif_from_mac80211(vif
)->id
,
902 .pwr_restriction
= cpu_to_le16(tx_power
),
905 return iwl_mvm_send_cmd_pdu(mvm
, REDUCE_TX_POWER_CMD
, 0,
906 sizeof(reduce_txpwr_cmd
),
910 static int iwl_mvm_mac_add_interface(struct ieee80211_hw
*hw
,
911 struct ieee80211_vif
*vif
)
913 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
914 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
918 * make sure D0i3 exit is completed, otherwise a target access
919 * during tx queue configuration could be done when still in
922 ret
= iwl_mvm_ref_sync(mvm
, IWL_MVM_REF_ADD_IF
);
927 * Not much to do here. The stack will not allow interface
928 * types or combinations that we didn't advertise, so we
929 * don't really have to check the types.
932 mutex_lock(&mvm
->mutex
);
934 /* Allocate resources for the MAC context, and add it to the fw */
935 ret
= iwl_mvm_mac_ctxt_init(mvm
, vif
);
939 /* Counting number of interfaces is needed for legacy PM */
940 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
944 * The AP binding flow can be done only after the beacon
945 * template is configured (which happens only in the mac80211
946 * start_ap() flow), and adding the broadcast station can happen
947 * only after the binding.
948 * In addition, since modifying the MAC before adding a bcast
949 * station is not allowed by the FW, delay the adding of MAC context to
950 * the point where we can also add the bcast station.
951 * In short: there's not much we can do at this point, other than
952 * allocating resources :)
954 if (vif
->type
== NL80211_IFTYPE_AP
||
955 vif
->type
== NL80211_IFTYPE_ADHOC
) {
956 u32 qmask
= iwl_mvm_mac_get_queues_mask(mvm
, vif
);
957 ret
= iwl_mvm_allocate_int_sta(mvm
, &mvmvif
->bcast_sta
,
959 ieee80211_vif_type_p2p(vif
));
961 IWL_ERR(mvm
, "Failed to allocate bcast sta\n");
965 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
969 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
973 ret
= iwl_mvm_power_update_mac(mvm
);
977 /* beacon filtering */
978 ret
= iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
982 if (!mvm
->bf_allowed_vif
&&
983 vif
->type
== NL80211_IFTYPE_STATION
&& !vif
->p2p
) {
984 mvm
->bf_allowed_vif
= mvmvif
;
985 vif
->driver_flags
|= IEEE80211_VIF_BEACON_FILTER
|
986 IEEE80211_VIF_SUPPORTS_CQM_RSSI
;
990 * P2P_DEVICE interface does not have a channel context assigned to it,
991 * so a dedicated PHY context is allocated to it and the corresponding
992 * MAC context is bound to it at this stage.
994 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
996 mvmvif
->phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
997 if (!mvmvif
->phy_ctxt
) {
1002 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
1003 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
1007 ret
= iwl_mvm_add_bcast_sta(mvm
, vif
, &mvmvif
->bcast_sta
);
1011 /* Save a pointer to p2p device vif, so it can later be used to
1012 * update the p2p device MAC when a GO is started/stopped */
1013 mvm
->p2p_device_vif
= vif
;
1016 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
1020 iwl_mvm_binding_remove_vif(mvm
, vif
);
1022 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
1024 if (mvm
->bf_allowed_vif
== mvmvif
) {
1025 mvm
->bf_allowed_vif
= NULL
;
1026 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1027 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1030 mvmvif
->phy_ctxt
= NULL
;
1031 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1033 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1036 iwl_mvm_mac_ctxt_release(mvm
, vif
);
1038 mutex_unlock(&mvm
->mutex
);
1040 iwl_mvm_unref(mvm
, IWL_MVM_REF_ADD_IF
);
1045 static void iwl_mvm_prepare_mac_removal(struct iwl_mvm
*mvm
,
1046 struct ieee80211_vif
*vif
)
1048 u32 tfd_msk
= 0, ac
;
1050 for (ac
= 0; ac
< IEEE80211_NUM_ACS
; ac
++)
1051 if (vif
->hw_queue
[ac
] != IEEE80211_INVAL_HW_QUEUE
)
1052 tfd_msk
|= BIT(vif
->hw_queue
[ac
]);
1054 if (vif
->cab_queue
!= IEEE80211_INVAL_HW_QUEUE
)
1055 tfd_msk
|= BIT(vif
->cab_queue
);
1058 mutex_lock(&mvm
->mutex
);
1059 iwl_mvm_flush_tx_path(mvm
, tfd_msk
, true);
1060 mutex_unlock(&mvm
->mutex
);
1063 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1065 * Flush the ROC worker which will flush the OFFCHANNEL queue.
1066 * We assume here that all the packets sent to the OFFCHANNEL
1067 * queue are sent in ROC session.
1069 flush_work(&mvm
->roc_done_wk
);
1072 * By now, all the AC queues are empty. The AGG queues are
1073 * empty too. We already got all the Tx responses for all the
1074 * packets in the queues. The drain work can have been
1075 * triggered. Flush it.
1077 flush_work(&mvm
->sta_drained_wk
);
1081 static void iwl_mvm_mac_remove_interface(struct ieee80211_hw
*hw
,
1082 struct ieee80211_vif
*vif
)
1084 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1085 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1087 iwl_mvm_prepare_mac_removal(mvm
, vif
);
1089 mutex_lock(&mvm
->mutex
);
1091 if (mvm
->bf_allowed_vif
== mvmvif
) {
1092 mvm
->bf_allowed_vif
= NULL
;
1093 vif
->driver_flags
&= ~(IEEE80211_VIF_BEACON_FILTER
|
1094 IEEE80211_VIF_SUPPORTS_CQM_RSSI
);
1097 iwl_mvm_vif_dbgfs_clean(mvm
, vif
);
1100 * For AP/GO interface, the tear down of the resources allocated to the
1101 * interface is be handled as part of the stop_ap flow.
1103 if (vif
->type
== NL80211_IFTYPE_AP
||
1104 vif
->type
== NL80211_IFTYPE_ADHOC
) {
1105 #ifdef CONFIG_NL80211_TESTMODE
1106 if (vif
== mvm
->noa_vif
) {
1107 mvm
->noa_vif
= NULL
;
1108 mvm
->noa_duration
= 0;
1111 iwl_mvm_dealloc_int_sta(mvm
, &mvmvif
->bcast_sta
);
1115 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1116 mvm
->p2p_device_vif
= NULL
;
1117 iwl_mvm_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
1118 iwl_mvm_binding_remove_vif(mvm
, vif
);
1119 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
1120 mvmvif
->phy_ctxt
= NULL
;
1123 if (mvm
->vif_count
&& vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
1126 iwl_mvm_power_update_mac(mvm
);
1127 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1130 iwl_mvm_mac_ctxt_release(mvm
, vif
);
1131 mutex_unlock(&mvm
->mutex
);
1134 static int iwl_mvm_mac_config(struct ieee80211_hw
*hw
, u32 changed
)
1139 struct iwl_mvm_mc_iter_data
{
1140 struct iwl_mvm
*mvm
;
1144 static void iwl_mvm_mc_iface_iterator(void *_data
, u8
*mac
,
1145 struct ieee80211_vif
*vif
)
1147 struct iwl_mvm_mc_iter_data
*data
= _data
;
1148 struct iwl_mvm
*mvm
= data
->mvm
;
1149 struct iwl_mcast_filter_cmd
*cmd
= mvm
->mcast_filter_cmd
;
1152 /* if we don't have free ports, mcast frames will be dropped */
1153 if (WARN_ON_ONCE(data
->port_id
>= MAX_PORT_ID_NUM
))
1156 if (vif
->type
!= NL80211_IFTYPE_STATION
||
1157 !vif
->bss_conf
.assoc
)
1160 cmd
->port_id
= data
->port_id
++;
1161 memcpy(cmd
->bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
1162 len
= roundup(sizeof(*cmd
) + cmd
->count
* ETH_ALEN
, 4);
1164 ret
= iwl_mvm_send_cmd_pdu(mvm
, MCAST_FILTER_CMD
, CMD_ASYNC
, len
, cmd
);
1166 IWL_ERR(mvm
, "mcast filter cmd error. ret=%d\n", ret
);
1169 static void iwl_mvm_recalc_multicast(struct iwl_mvm
*mvm
)
1171 struct iwl_mvm_mc_iter_data iter_data
= {
1175 lockdep_assert_held(&mvm
->mutex
);
1177 if (WARN_ON_ONCE(!mvm
->mcast_filter_cmd
))
1180 ieee80211_iterate_active_interfaces_atomic(
1181 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1182 iwl_mvm_mc_iface_iterator
, &iter_data
);
1185 static u64
iwl_mvm_prepare_multicast(struct ieee80211_hw
*hw
,
1186 struct netdev_hw_addr_list
*mc_list
)
1188 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1189 struct iwl_mcast_filter_cmd
*cmd
;
1190 struct netdev_hw_addr
*addr
;
1191 int addr_count
= netdev_hw_addr_list_count(mc_list
);
1192 bool pass_all
= false;
1195 if (addr_count
> MAX_MCAST_FILTERING_ADDRESSES
) {
1200 len
= roundup(sizeof(*cmd
) + addr_count
* ETH_ALEN
, 4);
1201 cmd
= kzalloc(len
, GFP_ATOMIC
);
1207 return (u64
)(unsigned long)cmd
;
1210 netdev_hw_addr_list_for_each(addr
, mc_list
) {
1211 IWL_DEBUG_MAC80211(mvm
, "mcast addr (%d): %pM\n",
1212 cmd
->count
, addr
->addr
);
1213 memcpy(&cmd
->addr_list
[cmd
->count
* ETH_ALEN
],
1214 addr
->addr
, ETH_ALEN
);
1218 return (u64
)(unsigned long)cmd
;
1221 static void iwl_mvm_configure_filter(struct ieee80211_hw
*hw
,
1222 unsigned int changed_flags
,
1223 unsigned int *total_flags
,
1226 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1227 struct iwl_mcast_filter_cmd
*cmd
= (void *)(unsigned long)multicast
;
1229 mutex_lock(&mvm
->mutex
);
1231 /* replace previous configuration */
1232 kfree(mvm
->mcast_filter_cmd
);
1233 mvm
->mcast_filter_cmd
= cmd
;
1238 iwl_mvm_recalc_multicast(mvm
);
1240 mutex_unlock(&mvm
->mutex
);
1244 #ifdef CONFIG_IWLWIFI_BCAST_FILTERING
1245 struct iwl_bcast_iter_data
{
1246 struct iwl_mvm
*mvm
;
1247 struct iwl_bcast_filter_cmd
*cmd
;
1252 iwl_mvm_set_bcast_filter(struct ieee80211_vif
*vif
,
1253 const struct iwl_fw_bcast_filter
*in_filter
,
1254 struct iwl_fw_bcast_filter
*out_filter
)
1256 struct iwl_fw_bcast_filter_attr
*attr
;
1259 memcpy(out_filter
, in_filter
, sizeof(*out_filter
));
1261 for (i
= 0; i
< ARRAY_SIZE(out_filter
->attrs
); i
++) {
1262 attr
= &out_filter
->attrs
[i
];
1267 switch (attr
->reserved1
) {
1268 case cpu_to_le16(BC_FILTER_MAGIC_IP
):
1269 if (vif
->bss_conf
.arp_addr_cnt
!= 1) {
1274 attr
->val
= vif
->bss_conf
.arp_addr_list
[0];
1276 case cpu_to_le16(BC_FILTER_MAGIC_MAC
):
1277 attr
->val
= *(__be32
*)&vif
->addr
[2];
1282 attr
->reserved1
= 0;
1283 out_filter
->num_attrs
++;
1287 static void iwl_mvm_bcast_filter_iterator(void *_data
, u8
*mac
,
1288 struct ieee80211_vif
*vif
)
1290 struct iwl_bcast_iter_data
*data
= _data
;
1291 struct iwl_mvm
*mvm
= data
->mvm
;
1292 struct iwl_bcast_filter_cmd
*cmd
= data
->cmd
;
1293 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1294 struct iwl_fw_bcast_mac
*bcast_mac
;
1297 if (WARN_ON(mvmvif
->id
>= ARRAY_SIZE(cmd
->macs
)))
1300 bcast_mac
= &cmd
->macs
[mvmvif
->id
];
1303 * enable filtering only for associated stations, but not for P2P
1306 if (vif
->type
!= NL80211_IFTYPE_STATION
|| vif
->p2p
||
1307 !vif
->bss_conf
.assoc
)
1310 bcast_mac
->default_discard
= 1;
1312 /* copy all configured filters */
1313 for (i
= 0; mvm
->bcast_filters
[i
].attrs
[0].mask
; i
++) {
1315 * Make sure we don't exceed our filters limit.
1316 * if there is still a valid filter to be configured,
1317 * be on the safe side and just allow bcast for this mac.
1319 if (WARN_ON_ONCE(data
->current_filter
>=
1320 ARRAY_SIZE(cmd
->filters
))) {
1321 bcast_mac
->default_discard
= 0;
1322 bcast_mac
->attached_filters
= 0;
1326 iwl_mvm_set_bcast_filter(vif
,
1327 &mvm
->bcast_filters
[i
],
1328 &cmd
->filters
[data
->current_filter
]);
1330 /* skip current filter if it contains no attributes */
1331 if (!cmd
->filters
[data
->current_filter
].num_attrs
)
1334 /* attach the filter to current mac */
1335 bcast_mac
->attached_filters
|=
1336 cpu_to_le16(BIT(data
->current_filter
));
1338 data
->current_filter
++;
1342 bool iwl_mvm_bcast_filter_build_cmd(struct iwl_mvm
*mvm
,
1343 struct iwl_bcast_filter_cmd
*cmd
)
1345 struct iwl_bcast_iter_data iter_data
= {
1350 memset(cmd
, 0, sizeof(*cmd
));
1351 cmd
->max_bcast_filters
= ARRAY_SIZE(cmd
->filters
);
1352 cmd
->max_macs
= ARRAY_SIZE(cmd
->macs
);
1354 #ifdef CONFIG_IWLWIFI_DEBUGFS
1355 /* use debugfs filters/macs if override is configured */
1356 if (mvm
->dbgfs_bcast_filtering
.override
) {
1357 memcpy(cmd
->filters
, &mvm
->dbgfs_bcast_filtering
.cmd
.filters
,
1358 sizeof(cmd
->filters
));
1359 memcpy(cmd
->macs
, &mvm
->dbgfs_bcast_filtering
.cmd
.macs
,
1365 /* if no filters are configured, do nothing */
1366 if (!mvm
->bcast_filters
)
1369 /* configure and attach these filters for each associated sta vif */
1370 ieee80211_iterate_active_interfaces(
1371 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
1372 iwl_mvm_bcast_filter_iterator
, &iter_data
);
1376 static int iwl_mvm_configure_bcast_filter(struct iwl_mvm
*mvm
,
1377 struct ieee80211_vif
*vif
)
1379 struct iwl_bcast_filter_cmd cmd
;
1381 if (!(mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_BCAST_FILTERING
))
1384 if (!iwl_mvm_bcast_filter_build_cmd(mvm
, &cmd
))
1387 return iwl_mvm_send_cmd_pdu(mvm
, BCAST_FILTER_CMD
, 0,
1391 static inline int iwl_mvm_configure_bcast_filter(struct iwl_mvm
*mvm
,
1392 struct ieee80211_vif
*vif
)
1398 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm
*mvm
,
1399 struct ieee80211_vif
*vif
,
1400 struct ieee80211_bss_conf
*bss_conf
,
1403 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1407 * Re-calculate the tsf id, as the master-slave relations depend on the
1408 * beacon interval, which was not known when the station interface was
1411 if (changes
& BSS_CHANGED_ASSOC
&& bss_conf
->assoc
)
1412 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
1414 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false);
1416 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
1418 if (changes
& BSS_CHANGED_ASSOC
) {
1419 if (bss_conf
->assoc
) {
1420 /* add quota for this interface */
1421 ret
= iwl_mvm_update_quotas(mvm
, vif
);
1423 IWL_ERR(mvm
, "failed to update quotas\n");
1427 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
,
1430 * If we're restarting then the firmware will
1431 * obviously have lost synchronisation with
1432 * the AP. It will attempt to synchronise by
1433 * itself, but we can make it more reliable by
1434 * scheduling a session protection time event.
1436 * The firmware needs to receive a beacon to
1437 * catch up with synchronisation, use 110% of
1438 * the beacon interval.
1440 * Set a large maximum delay to allow for more
1441 * than a single interface.
1443 u32 dur
= (11 * vif
->bss_conf
.beacon_int
) / 10;
1444 iwl_mvm_protect_session(mvm
, vif
, dur
, dur
,
1448 iwl_mvm_sf_update(mvm
, vif
, false);
1449 iwl_mvm_power_vif_assoc(mvm
, vif
);
1451 iwl_mvm_ref(mvm
, IWL_MVM_REF_P2P_CLIENT
);
1452 } else if (mvmvif
->ap_sta_id
!= IWL_MVM_STATION_COUNT
) {
1454 * If update fails - SF might be running in associated
1455 * mode while disassociated - which is forbidden.
1457 WARN_ONCE(iwl_mvm_sf_update(mvm
, vif
, false),
1458 "Failed to update SF upon disassociation\n");
1460 /* remove AP station now that the MAC is unassoc */
1461 ret
= iwl_mvm_rm_sta_id(mvm
, vif
, mvmvif
->ap_sta_id
);
1463 IWL_ERR(mvm
, "failed to remove AP station\n");
1465 if (mvm
->d0i3_ap_sta_id
== mvmvif
->ap_sta_id
)
1466 mvm
->d0i3_ap_sta_id
= IWL_MVM_STATION_COUNT
;
1467 mvmvif
->ap_sta_id
= IWL_MVM_STATION_COUNT
;
1468 /* remove quota for this interface */
1469 ret
= iwl_mvm_update_quotas(mvm
, NULL
);
1471 IWL_ERR(mvm
, "failed to update quotas\n");
1474 iwl_mvm_unref(mvm
, IWL_MVM_REF_P2P_CLIENT
);
1477 iwl_mvm_recalc_multicast(mvm
);
1478 iwl_mvm_configure_bcast_filter(mvm
, vif
);
1480 /* reset rssi values */
1481 mvmvif
->bf_data
.ave_beacon_signal
= 0;
1483 iwl_mvm_bt_coex_vif_change(mvm
);
1484 iwl_mvm_update_smps(mvm
, vif
, IWL_MVM_SMPS_REQ_TT
,
1485 IEEE80211_SMPS_AUTOMATIC
);
1486 } else if (changes
& BSS_CHANGED_BEACON_INFO
) {
1488 * We received a beacon _after_ association so
1489 * remove the session protection.
1491 iwl_mvm_remove_time_event(mvm
, mvmvif
,
1492 &mvmvif
->time_event_data
);
1493 iwl_mvm_sf_update(mvm
, vif
, false);
1494 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
, 0));
1495 } else if (changes
& (BSS_CHANGED_PS
| BSS_CHANGED_P2P_PS
|
1497 ret
= iwl_mvm_power_update_mac(mvm
);
1499 IWL_ERR(mvm
, "failed to update power mode\n");
1501 if (changes
& BSS_CHANGED_TXPOWER
) {
1502 IWL_DEBUG_CALIB(mvm
, "Changing TX Power to %d\n",
1504 iwl_mvm_set_tx_power(mvm
, vif
, bss_conf
->txpower
);
1507 if (changes
& BSS_CHANGED_CQM
) {
1508 IWL_DEBUG_MAC80211(mvm
, "cqm info_changed\n");
1509 /* reset cqm events tracking */
1510 mvmvif
->bf_data
.last_cqm_event
= 0;
1511 if (mvmvif
->bf_data
.bf_enabled
) {
1512 ret
= iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
1515 "failed to update CQM thresholds\n");
1519 if (changes
& BSS_CHANGED_ARP_FILTER
) {
1520 IWL_DEBUG_MAC80211(mvm
, "arp filter changed\n");
1521 iwl_mvm_configure_bcast_filter(mvm
, vif
);
1525 static int iwl_mvm_start_ap_ibss(struct ieee80211_hw
*hw
,
1526 struct ieee80211_vif
*vif
)
1528 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1529 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1532 mutex_lock(&mvm
->mutex
);
1534 /* Send the beacon template */
1535 ret
= iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
);
1540 * Re-calculate the tsf id, as the master-slave relations depend on the
1541 * beacon interval, which was not known when the AP interface was added.
1543 if (vif
->type
== NL80211_IFTYPE_AP
)
1544 iwl_mvm_mac_ctxt_recalc_tsf_id(mvm
, vif
);
1546 /* Add the mac context */
1547 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
1551 /* Perform the binding */
1552 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
1556 /* Send the bcast station. At this stage the TBTT and DTIM time events
1557 * are added and applied to the scheduler */
1558 ret
= iwl_mvm_send_bcast_sta(mvm
, vif
, &mvmvif
->bcast_sta
);
1562 /* must be set before quota calculations */
1563 mvmvif
->ap_ibss_active
= true;
1565 /* power updated needs to be done before quotas */
1566 iwl_mvm_power_update_mac(mvm
);
1568 ret
= iwl_mvm_update_quotas(mvm
, vif
);
1570 goto out_quota_failed
;
1572 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
1573 if (vif
->p2p
&& mvm
->p2p_device_vif
)
1574 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false);
1576 iwl_mvm_ref(mvm
, IWL_MVM_REF_AP_IBSS
);
1578 iwl_mvm_bt_coex_vif_change(mvm
);
1580 mutex_unlock(&mvm
->mutex
);
1584 iwl_mvm_power_update_mac(mvm
);
1585 mvmvif
->ap_ibss_active
= false;
1586 iwl_mvm_send_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
1588 iwl_mvm_binding_remove_vif(mvm
, vif
);
1590 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1592 mutex_unlock(&mvm
->mutex
);
1596 static void iwl_mvm_stop_ap_ibss(struct ieee80211_hw
*hw
,
1597 struct ieee80211_vif
*vif
)
1599 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1600 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1602 iwl_mvm_prepare_mac_removal(mvm
, vif
);
1604 mutex_lock(&mvm
->mutex
);
1606 mvmvif
->ap_ibss_active
= false;
1607 mvm
->ap_last_beacon_gp2
= 0;
1609 iwl_mvm_bt_coex_vif_change(mvm
);
1611 iwl_mvm_unref(mvm
, IWL_MVM_REF_AP_IBSS
);
1613 /* Need to update the P2P Device MAC (only GO, IBSS is single vif) */
1614 if (vif
->p2p
&& mvm
->p2p_device_vif
)
1615 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
, false);
1617 iwl_mvm_update_quotas(mvm
, NULL
);
1618 iwl_mvm_send_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
1619 iwl_mvm_binding_remove_vif(mvm
, vif
);
1621 iwl_mvm_power_update_mac(mvm
);
1623 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
1625 mutex_unlock(&mvm
->mutex
);
1629 iwl_mvm_bss_info_changed_ap_ibss(struct iwl_mvm
*mvm
,
1630 struct ieee80211_vif
*vif
,
1631 struct ieee80211_bss_conf
*bss_conf
,
1634 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1636 /* Changes will be applied when the AP/IBSS is started */
1637 if (!mvmvif
->ap_ibss_active
)
1640 if (changes
& (BSS_CHANGED_ERP_CTS_PROT
| BSS_CHANGED_HT
|
1641 BSS_CHANGED_BANDWIDTH
) &&
1642 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false))
1643 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
1645 /* Need to send a new beacon template to the FW */
1646 if (changes
& BSS_CHANGED_BEACON
&&
1647 iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
))
1648 IWL_WARN(mvm
, "Failed updating beacon data\n");
1651 static void iwl_mvm_bss_info_changed(struct ieee80211_hw
*hw
,
1652 struct ieee80211_vif
*vif
,
1653 struct ieee80211_bss_conf
*bss_conf
,
1656 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1658 mutex_lock(&mvm
->mutex
);
1660 if (changes
& BSS_CHANGED_IDLE
&& !bss_conf
->idle
)
1661 iwl_mvm_sched_scan_stop(mvm
, true);
1663 switch (vif
->type
) {
1664 case NL80211_IFTYPE_STATION
:
1665 iwl_mvm_bss_info_changed_station(mvm
, vif
, bss_conf
, changes
);
1667 case NL80211_IFTYPE_AP
:
1668 case NL80211_IFTYPE_ADHOC
:
1669 iwl_mvm_bss_info_changed_ap_ibss(mvm
, vif
, bss_conf
, changes
);
1672 /* shouldn't happen */
1676 mutex_unlock(&mvm
->mutex
);
1679 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw
*hw
,
1680 struct ieee80211_vif
*vif
,
1681 struct ieee80211_scan_request
*hw_req
)
1683 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1684 struct cfg80211_scan_request
*req
= &hw_req
->req
;
1687 if (req
->n_channels
== 0 ||
1688 req
->n_channels
> mvm
->fw
->ucode_capa
.n_scan_channels
)
1691 mutex_lock(&mvm
->mutex
);
1693 switch (mvm
->scan_status
) {
1694 case IWL_MVM_SCAN_SCHED
:
1695 ret
= iwl_mvm_sched_scan_stop(mvm
, true);
1701 case IWL_MVM_SCAN_NONE
:
1708 iwl_mvm_ref(mvm
, IWL_MVM_REF_SCAN
);
1710 ret
= iwl_mvm_scan_request(mvm
, vif
, req
);
1712 iwl_mvm_unref(mvm
, IWL_MVM_REF_SCAN
);
1714 mutex_unlock(&mvm
->mutex
);
1715 /* make sure to flush the Rx handler before the next scan arrives */
1716 iwl_mvm_wait_for_async_handlers(mvm
);
1720 static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw
*hw
,
1721 struct ieee80211_vif
*vif
)
1723 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1725 mutex_lock(&mvm
->mutex
);
1727 iwl_mvm_cancel_scan(mvm
);
1729 mutex_unlock(&mvm
->mutex
);
1733 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw
*hw
,
1734 struct ieee80211_sta
*sta
, u16 tids
,
1736 enum ieee80211_frame_release_type reason
,
1739 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1741 /* Called when we need to transmit (a) frame(s) from mac80211 */
1743 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
1744 tids
, more_data
, false);
1748 iwl_mvm_mac_release_buffered_frames(struct ieee80211_hw
*hw
,
1749 struct ieee80211_sta
*sta
, u16 tids
,
1751 enum ieee80211_frame_release_type reason
,
1754 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1756 /* Called when we need to transmit (a) frame(s) from agg queue */
1758 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
,
1759 tids
, more_data
, true);
1762 static void iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
,
1763 struct ieee80211_vif
*vif
,
1764 enum sta_notify_cmd cmd
,
1765 struct ieee80211_sta
*sta
)
1767 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1768 struct iwl_mvm_sta
*mvmsta
= iwl_mvm_sta_from_mac80211(sta
);
1772 case STA_NOTIFY_SLEEP
:
1773 if (atomic_read(&mvm
->pending_frames
[mvmsta
->sta_id
]) > 0)
1774 ieee80211_sta_block_awake(hw
, sta
, true);
1775 spin_lock_bh(&mvmsta
->lock
);
1776 for (tid
= 0; tid
< IWL_MAX_TID_COUNT
; tid
++) {
1777 struct iwl_mvm_tid_data
*tid_data
;
1779 tid_data
= &mvmsta
->tid_data
[tid
];
1780 if (tid_data
->state
!= IWL_AGG_ON
&&
1781 tid_data
->state
!= IWL_EMPTYING_HW_QUEUE_DELBA
)
1783 if (iwl_mvm_tid_queued(tid_data
) == 0)
1785 ieee80211_sta_set_buffered(sta
, tid
, true);
1787 spin_unlock_bh(&mvmsta
->lock
);
1789 * The fw updates the STA to be asleep. Tx packets on the Tx
1790 * queues to this station will not be transmitted. The fw will
1791 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
1794 case STA_NOTIFY_AWAKE
:
1795 if (WARN_ON(mvmsta
->sta_id
== IWL_MVM_STATION_COUNT
))
1797 iwl_mvm_sta_modify_ps_wake(mvm
, sta
);
1804 static void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw
*hw
,
1805 struct ieee80211_vif
*vif
,
1806 struct ieee80211_sta
*sta
)
1808 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1809 struct iwl_mvm_sta
*mvm_sta
= (void *)sta
->drv_priv
;
1812 * This is called before mac80211 does RCU synchronisation,
1813 * so here we already invalidate our internal RCU-protected
1814 * station pointer. The rest of the code will thus no longer
1815 * be able to find the station this way, and we don't rely
1816 * on further RCU synchronisation after the sta_state()
1817 * callback deleted the station.
1819 mutex_lock(&mvm
->mutex
);
1820 if (sta
== rcu_access_pointer(mvm
->fw_id_to_mac_id
[mvm_sta
->sta_id
]))
1821 rcu_assign_pointer(mvm
->fw_id_to_mac_id
[mvm_sta
->sta_id
],
1823 mutex_unlock(&mvm
->mutex
);
1826 static int iwl_mvm_mac_sta_state(struct ieee80211_hw
*hw
,
1827 struct ieee80211_vif
*vif
,
1828 struct ieee80211_sta
*sta
,
1829 enum ieee80211_sta_state old_state
,
1830 enum ieee80211_sta_state new_state
)
1832 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1833 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1836 IWL_DEBUG_MAC80211(mvm
, "station %pM state change %d->%d\n",
1837 sta
->addr
, old_state
, new_state
);
1839 /* this would be a mac80211 bug ... but don't crash */
1840 if (WARN_ON_ONCE(!mvmvif
->phy_ctxt
))
1843 /* if a STA is being removed, reuse its ID */
1844 flush_work(&mvm
->sta_drained_wk
);
1846 mutex_lock(&mvm
->mutex
);
1847 if (old_state
== IEEE80211_STA_NOTEXIST
&&
1848 new_state
== IEEE80211_STA_NONE
) {
1850 * Firmware bug - it'll crash if the beacon interval is less
1851 * than 16. We can't avoid connecting at all, so refuse the
1852 * station state change, this will cause mac80211 to abandon
1853 * attempts to connect to this AP, and eventually wpa_s will
1854 * blacklist the AP...
1856 if (vif
->type
== NL80211_IFTYPE_STATION
&&
1857 vif
->bss_conf
.beacon_int
< 16) {
1859 "AP %pM beacon interval is %d, refusing due to firmware bug!\n",
1860 sta
->addr
, vif
->bss_conf
.beacon_int
);
1864 ret
= iwl_mvm_add_sta(mvm
, vif
, sta
);
1865 } else if (old_state
== IEEE80211_STA_NONE
&&
1866 new_state
== IEEE80211_STA_AUTH
) {
1868 * EBS may be disabled due to previous failures reported by FW.
1869 * Reset EBS status here assuming environment has been changed.
1871 mvm
->last_ebs_successful
= true;
1873 } else if (old_state
== IEEE80211_STA_AUTH
&&
1874 new_state
== IEEE80211_STA_ASSOC
) {
1875 ret
= iwl_mvm_update_sta(mvm
, vif
, sta
);
1877 iwl_mvm_rs_rate_init(mvm
, sta
,
1878 mvmvif
->phy_ctxt
->channel
->band
,
1880 } else if (old_state
== IEEE80211_STA_ASSOC
&&
1881 new_state
== IEEE80211_STA_AUTHORIZED
) {
1882 /* enable beacon filtering */
1883 WARN_ON(iwl_mvm_enable_beacon_filter(mvm
, vif
, 0));
1885 } else if (old_state
== IEEE80211_STA_AUTHORIZED
&&
1886 new_state
== IEEE80211_STA_ASSOC
) {
1887 /* disable beacon filtering */
1888 WARN_ON(iwl_mvm_disable_beacon_filter(mvm
, vif
, 0));
1890 } else if (old_state
== IEEE80211_STA_ASSOC
&&
1891 new_state
== IEEE80211_STA_AUTH
) {
1893 } else if (old_state
== IEEE80211_STA_AUTH
&&
1894 new_state
== IEEE80211_STA_NONE
) {
1896 } else if (old_state
== IEEE80211_STA_NONE
&&
1897 new_state
== IEEE80211_STA_NOTEXIST
) {
1898 ret
= iwl_mvm_rm_sta(mvm
, vif
, sta
);
1903 mutex_unlock(&mvm
->mutex
);
1908 static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
1910 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1912 mvm
->rts_threshold
= value
;
1917 static void iwl_mvm_sta_rc_update(struct ieee80211_hw
*hw
,
1918 struct ieee80211_vif
*vif
,
1919 struct ieee80211_sta
*sta
, u32 changed
)
1921 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1923 if (vif
->type
== NL80211_IFTYPE_STATION
&&
1924 changed
& IEEE80211_RC_NSS_CHANGED
)
1925 iwl_mvm_sf_update(mvm
, vif
, false);
1928 static int iwl_mvm_mac_conf_tx(struct ieee80211_hw
*hw
,
1929 struct ieee80211_vif
*vif
, u16 ac
,
1930 const struct ieee80211_tx_queue_params
*params
)
1932 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1933 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1935 mvmvif
->queue_params
[ac
] = *params
;
1938 * No need to update right away, we'll get BSS_CHANGED_QOS
1939 * The exception is P2P_DEVICE interface which needs immediate update.
1941 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1944 mutex_lock(&mvm
->mutex
);
1945 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
, false);
1946 mutex_unlock(&mvm
->mutex
);
1952 static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw
*hw
,
1953 struct ieee80211_vif
*vif
)
1955 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1956 u32 duration
= min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS
,
1957 200 + vif
->bss_conf
.beacon_int
);
1958 u32 min_duration
= min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS
,
1959 100 + vif
->bss_conf
.beacon_int
);
1961 if (WARN_ON_ONCE(vif
->bss_conf
.assoc
))
1964 mutex_lock(&mvm
->mutex
);
1965 /* Try really hard to protect the session and hear a beacon */
1966 iwl_mvm_protect_session(mvm
, vif
, duration
, min_duration
, 500);
1967 mutex_unlock(&mvm
->mutex
);
1970 static int iwl_mvm_mac_sched_scan_start(struct ieee80211_hw
*hw
,
1971 struct ieee80211_vif
*vif
,
1972 struct cfg80211_sched_scan_request
*req
,
1973 struct ieee80211_scan_ies
*ies
)
1975 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1978 mutex_lock(&mvm
->mutex
);
1980 if (!iwl_mvm_is_idle(mvm
)) {
1985 switch (mvm
->scan_status
) {
1986 case IWL_MVM_SCAN_OS
:
1987 IWL_DEBUG_SCAN(mvm
, "Stopping previous scan for sched_scan\n");
1988 ret
= iwl_mvm_cancel_scan(mvm
);
1995 * iwl_mvm_rx_scan_complete() will be called soon but will
1996 * not reset the scan status as it won't be IWL_MVM_SCAN_OS
1997 * any more since we queue the next scan immediately (below).
1998 * We make sure it is called before the next scan starts by
1999 * flushing the async-handlers work.
2002 case IWL_MVM_SCAN_NONE
:
2009 mvm
->scan_status
= IWL_MVM_SCAN_SCHED
;
2011 ret
= iwl_mvm_config_sched_scan(mvm
, vif
, req
, ies
);
2015 ret
= iwl_mvm_config_sched_scan_profiles(mvm
, req
);
2019 ret
= iwl_mvm_sched_scan_start(mvm
, req
);
2023 mvm
->scan_status
= IWL_MVM_SCAN_NONE
;
2025 mutex_unlock(&mvm
->mutex
);
2026 /* make sure to flush the Rx handler before the next scan arrives */
2027 iwl_mvm_wait_for_async_handlers(mvm
);
2031 static int iwl_mvm_mac_sched_scan_stop(struct ieee80211_hw
*hw
,
2032 struct ieee80211_vif
*vif
)
2034 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2037 mutex_lock(&mvm
->mutex
);
2038 ret
= iwl_mvm_sched_scan_stop(mvm
, false);
2039 mutex_unlock(&mvm
->mutex
);
2040 iwl_mvm_wait_for_async_handlers(mvm
);
2045 static int iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
,
2046 enum set_key_cmd cmd
,
2047 struct ieee80211_vif
*vif
,
2048 struct ieee80211_sta
*sta
,
2049 struct ieee80211_key_conf
*key
)
2051 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2054 if (iwlwifi_mod_params
.sw_crypto
) {
2055 IWL_DEBUG_MAC80211(mvm
, "leave - hwcrypto disabled\n");
2059 switch (key
->cipher
) {
2060 case WLAN_CIPHER_SUITE_TKIP
:
2061 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
2063 case WLAN_CIPHER_SUITE_CCMP
:
2064 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
2066 case WLAN_CIPHER_SUITE_AES_CMAC
:
2067 WARN_ON_ONCE(!(hw
->flags
& IEEE80211_HW_MFP_CAPABLE
));
2069 case WLAN_CIPHER_SUITE_WEP40
:
2070 case WLAN_CIPHER_SUITE_WEP104
:
2072 * Support for TX only, at least for now, so accept
2073 * the key and do nothing else. Then mac80211 will
2074 * pass it for TX but we don't have to use it for RX.
2078 /* currently FW supports only one optional cipher scheme */
2079 if (hw
->n_cipher_schemes
&&
2080 hw
->cipher_schemes
->cipher
== key
->cipher
)
2081 key
->flags
|= IEEE80211_KEY_FLAG_PUT_IV_SPACE
;
2086 mutex_lock(&mvm
->mutex
);
2090 if ((vif
->type
== NL80211_IFTYPE_ADHOC
||
2091 vif
->type
== NL80211_IFTYPE_AP
) && !sta
) {
2093 * GTK on AP interface is a TX-only key, return 0;
2094 * on IBSS they're per-station and because we're lazy
2095 * we don't support them for RX, so do the same.
2098 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
2102 IWL_DEBUG_MAC80211(mvm
, "set hwcrypto key\n");
2103 ret
= iwl_mvm_set_sta_key(mvm
, vif
, sta
, key
, false);
2105 IWL_WARN(mvm
, "set key failed\n");
2107 * can't add key for RX, but we don't need it
2108 * in the device for TX so still return 0
2110 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
2116 if (key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
2121 IWL_DEBUG_MAC80211(mvm
, "disable hwcrypto key\n");
2122 ret
= iwl_mvm_remove_sta_key(mvm
, vif
, sta
, key
);
2128 mutex_unlock(&mvm
->mutex
);
2132 static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw
*hw
,
2133 struct ieee80211_vif
*vif
,
2134 struct ieee80211_key_conf
*keyconf
,
2135 struct ieee80211_sta
*sta
,
2136 u32 iv32
, u16
*phase1key
)
2138 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2140 if (keyconf
->hw_key_idx
== STA_KEY_IDX_INVALID
)
2143 iwl_mvm_update_tkip_key(mvm
, vif
, keyconf
, sta
, iv32
, phase1key
);
2147 static int iwl_mvm_roc(struct ieee80211_hw
*hw
,
2148 struct ieee80211_vif
*vif
,
2149 struct ieee80211_channel
*channel
,
2151 enum ieee80211_roc_type type
)
2153 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2154 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2155 struct cfg80211_chan_def chandef
;
2156 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
2159 IWL_DEBUG_MAC80211(mvm
, "enter (%d, %d, %d)\n", channel
->hw_value
,
2162 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
) {
2163 IWL_ERR(mvm
, "vif isn't a P2P_DEVICE: %d\n", vif
->type
);
2167 mutex_lock(&mvm
->mutex
);
2169 for (i
= 0; i
< NUM_PHY_CTX
; i
++) {
2170 phy_ctxt
= &mvm
->phy_ctxts
[i
];
2171 if (phy_ctxt
->ref
== 0 || mvmvif
->phy_ctxt
== phy_ctxt
)
2174 if (phy_ctxt
->ref
&& channel
== phy_ctxt
->channel
) {
2176 * Unbind the P2P_DEVICE from the current PHY context,
2177 * and if the PHY context is not used remove it.
2179 ret
= iwl_mvm_binding_remove_vif(mvm
, vif
);
2180 if (WARN(ret
, "Failed unbinding P2P_DEVICE\n"))
2183 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
2185 /* Bind the P2P_DEVICE to the current PHY Context */
2186 mvmvif
->phy_ctxt
= phy_ctxt
;
2188 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2189 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
2192 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
2193 goto schedule_time_event
;
2197 /* Need to update the PHY context only if the ROC channel changed */
2198 if (channel
== mvmvif
->phy_ctxt
->channel
)
2199 goto schedule_time_event
;
2201 cfg80211_chandef_create(&chandef
, channel
, NL80211_CHAN_NO_HT
);
2204 * Change the PHY context configuration as it is currently referenced
2205 * only by the P2P Device MAC
2207 if (mvmvif
->phy_ctxt
->ref
== 1) {
2208 ret
= iwl_mvm_phy_ctxt_changed(mvm
, mvmvif
->phy_ctxt
,
2214 * The PHY context is shared with other MACs. Need to remove the
2215 * P2P Device from the binding, allocate an new PHY context and
2216 * create a new binding
2218 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
2224 ret
= iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &chandef
,
2227 IWL_ERR(mvm
, "Failed to change PHY context\n");
2231 /* Unbind the P2P_DEVICE from the current PHY context */
2232 ret
= iwl_mvm_binding_remove_vif(mvm
, vif
);
2233 if (WARN(ret
, "Failed unbinding P2P_DEVICE\n"))
2236 iwl_mvm_phy_ctxt_unref(mvm
, mvmvif
->phy_ctxt
);
2238 /* Bind the P2P_DEVICE to the new allocated PHY context */
2239 mvmvif
->phy_ctxt
= phy_ctxt
;
2241 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2242 if (WARN(ret
, "Failed binding P2P_DEVICE\n"))
2245 iwl_mvm_phy_ctxt_ref(mvm
, mvmvif
->phy_ctxt
);
2248 schedule_time_event
:
2249 /* Schedule the time events */
2250 ret
= iwl_mvm_start_p2p_roc(mvm
, vif
, duration
, type
);
2253 mutex_unlock(&mvm
->mutex
);
2254 IWL_DEBUG_MAC80211(mvm
, "leave\n");
2258 static int iwl_mvm_cancel_roc(struct ieee80211_hw
*hw
)
2260 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2262 IWL_DEBUG_MAC80211(mvm
, "enter\n");
2264 mutex_lock(&mvm
->mutex
);
2265 iwl_mvm_stop_p2p_roc(mvm
);
2266 mutex_unlock(&mvm
->mutex
);
2268 IWL_DEBUG_MAC80211(mvm
, "leave\n");
2272 static int iwl_mvm_add_chanctx(struct ieee80211_hw
*hw
,
2273 struct ieee80211_chanctx_conf
*ctx
)
2275 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2276 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2277 struct iwl_mvm_phy_ctxt
*phy_ctxt
;
2280 IWL_DEBUG_MAC80211(mvm
, "Add channel context\n");
2282 mutex_lock(&mvm
->mutex
);
2283 phy_ctxt
= iwl_mvm_get_free_phy_ctxt(mvm
);
2289 ret
= iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->min_def
,
2290 ctx
->rx_chains_static
,
2291 ctx
->rx_chains_dynamic
);
2293 IWL_ERR(mvm
, "Failed to add PHY context\n");
2297 iwl_mvm_phy_ctxt_ref(mvm
, phy_ctxt
);
2298 *phy_ctxt_id
= phy_ctxt
->id
;
2300 mutex_unlock(&mvm
->mutex
);
2304 static void iwl_mvm_remove_chanctx(struct ieee80211_hw
*hw
,
2305 struct ieee80211_chanctx_conf
*ctx
)
2307 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2308 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2309 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
2311 mutex_lock(&mvm
->mutex
);
2312 iwl_mvm_phy_ctxt_unref(mvm
, phy_ctxt
);
2313 mutex_unlock(&mvm
->mutex
);
2316 static void iwl_mvm_change_chanctx(struct ieee80211_hw
*hw
,
2317 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 if (WARN_ONCE((phy_ctxt
->ref
> 1) &&
2325 (changed
& ~(IEEE80211_CHANCTX_CHANGE_WIDTH
|
2326 IEEE80211_CHANCTX_CHANGE_RX_CHAINS
|
2327 IEEE80211_CHANCTX_CHANGE_RADAR
|
2328 IEEE80211_CHANCTX_CHANGE_MIN_WIDTH
)),
2329 "Cannot change PHY. Ref=%d, changed=0x%X\n",
2330 phy_ctxt
->ref
, changed
))
2333 mutex_lock(&mvm
->mutex
);
2334 iwl_mvm_bt_coex_vif_change(mvm
);
2335 iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->min_def
,
2336 ctx
->rx_chains_static
,
2337 ctx
->rx_chains_dynamic
);
2338 mutex_unlock(&mvm
->mutex
);
2341 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw
*hw
,
2342 struct ieee80211_vif
*vif
,
2343 struct ieee80211_chanctx_conf
*ctx
)
2345 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2346 u16
*phy_ctxt_id
= (u16
*)ctx
->drv_priv
;
2347 struct iwl_mvm_phy_ctxt
*phy_ctxt
= &mvm
->phy_ctxts
[*phy_ctxt_id
];
2348 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2351 mutex_lock(&mvm
->mutex
);
2353 mvmvif
->phy_ctxt
= phy_ctxt
;
2355 switch (vif
->type
) {
2356 case NL80211_IFTYPE_AP
:
2357 /* Unless it's a CSA flow we have nothing to do here */
2358 if (vif
->csa_active
) {
2359 mvmvif
->ap_ibss_active
= true;
2362 case NL80211_IFTYPE_ADHOC
:
2364 * The AP binding flow is handled as part of the start_ap flow
2365 * (in bss_info_changed), similarly for IBSS.
2369 case NL80211_IFTYPE_STATION
:
2370 case NL80211_IFTYPE_MONITOR
:
2377 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
2382 * Power state must be updated before quotas,
2383 * otherwise fw will complain.
2385 iwl_mvm_power_update_mac(mvm
);
2387 /* Setting the quota at this stage is only required for monitor
2388 * interfaces. For the other types, the bss_info changed flow
2389 * will handle quota settings.
2391 if (vif
->type
== NL80211_IFTYPE_MONITOR
) {
2392 mvmvif
->monitor_active
= true;
2393 ret
= iwl_mvm_update_quotas(mvm
, vif
);
2395 goto out_remove_binding
;
2398 /* Handle binding during CSA */
2399 if (vif
->type
== NL80211_IFTYPE_AP
) {
2400 iwl_mvm_update_quotas(mvm
, vif
);
2401 iwl_mvm_mac_ctxt_changed(mvm
, vif
, false);
2407 iwl_mvm_binding_remove_vif(mvm
, vif
);
2408 iwl_mvm_power_update_mac(mvm
);
2410 mutex_unlock(&mvm
->mutex
);
2412 mvmvif
->phy_ctxt
= NULL
;
2416 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw
*hw
,
2417 struct ieee80211_vif
*vif
,
2418 struct ieee80211_chanctx_conf
*ctx
)
2420 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2421 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2423 mutex_lock(&mvm
->mutex
);
2425 iwl_mvm_remove_time_event(mvm
, mvmvif
, &mvmvif
->time_event_data
);
2427 switch (vif
->type
) {
2428 case NL80211_IFTYPE_ADHOC
:
2430 case NL80211_IFTYPE_MONITOR
:
2431 mvmvif
->monitor_active
= false;
2432 iwl_mvm_update_quotas(mvm
, NULL
);
2434 case NL80211_IFTYPE_AP
:
2435 /* This part is triggered only during CSA */
2436 if (!vif
->csa_active
|| !mvmvif
->ap_ibss_active
)
2439 mvmvif
->ap_ibss_active
= false;
2440 iwl_mvm_update_quotas(mvm
, NULL
);
2441 /*TODO: bt_coex notification here? */
2446 iwl_mvm_binding_remove_vif(mvm
, vif
);
2449 mvmvif
->phy_ctxt
= NULL
;
2450 iwl_mvm_power_update_mac(mvm
);
2451 mutex_unlock(&mvm
->mutex
);
2454 static int iwl_mvm_set_tim(struct ieee80211_hw
*hw
,
2455 struct ieee80211_sta
*sta
,
2458 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2459 struct iwl_mvm_sta
*mvm_sta
= (void *)sta
->drv_priv
;
2461 if (!mvm_sta
|| !mvm_sta
->vif
) {
2462 IWL_ERR(mvm
, "Station is not associated to a vif\n");
2466 return iwl_mvm_mac_ctxt_beacon_changed(mvm
, mvm_sta
->vif
);
2469 #ifdef CONFIG_NL80211_TESTMODE
2470 static const struct nla_policy iwl_mvm_tm_policy
[IWL_MVM_TM_ATTR_MAX
+ 1] = {
2471 [IWL_MVM_TM_ATTR_CMD
] = { .type
= NLA_U32
},
2472 [IWL_MVM_TM_ATTR_NOA_DURATION
] = { .type
= NLA_U32
},
2473 [IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
] = { .type
= NLA_U32
},
2476 static int __iwl_mvm_mac_testmode_cmd(struct iwl_mvm
*mvm
,
2477 struct ieee80211_vif
*vif
,
2478 void *data
, int len
)
2480 struct nlattr
*tb
[IWL_MVM_TM_ATTR_MAX
+ 1];
2484 err
= nla_parse(tb
, IWL_MVM_TM_ATTR_MAX
, data
, len
, iwl_mvm_tm_policy
);
2488 if (!tb
[IWL_MVM_TM_ATTR_CMD
])
2491 switch (nla_get_u32(tb
[IWL_MVM_TM_ATTR_CMD
])) {
2492 case IWL_MVM_TM_CMD_SET_NOA
:
2493 if (!vif
|| vif
->type
!= NL80211_IFTYPE_AP
|| !vif
->p2p
||
2494 !vif
->bss_conf
.enable_beacon
||
2495 !tb
[IWL_MVM_TM_ATTR_NOA_DURATION
])
2498 noa_duration
= nla_get_u32(tb
[IWL_MVM_TM_ATTR_NOA_DURATION
]);
2499 if (noa_duration
>= vif
->bss_conf
.beacon_int
)
2502 mvm
->noa_duration
= noa_duration
;
2505 return iwl_mvm_update_quotas(mvm
, NULL
);
2506 case IWL_MVM_TM_CMD_SET_BEACON_FILTER
:
2507 /* must be associated client vif - ignore authorized */
2508 if (!vif
|| vif
->type
!= NL80211_IFTYPE_STATION
||
2509 !vif
->bss_conf
.assoc
|| !vif
->bss_conf
.dtim_period
||
2510 !tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
])
2513 if (nla_get_u32(tb
[IWL_MVM_TM_ATTR_BEACON_FILTER_STATE
]))
2514 return iwl_mvm_enable_beacon_filter(mvm
, vif
, 0);
2515 return iwl_mvm_disable_beacon_filter(mvm
, vif
, 0);
2521 static int iwl_mvm_mac_testmode_cmd(struct ieee80211_hw
*hw
,
2522 struct ieee80211_vif
*vif
,
2523 void *data
, int len
)
2525 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2528 mutex_lock(&mvm
->mutex
);
2529 err
= __iwl_mvm_mac_testmode_cmd(mvm
, vif
, data
, len
);
2530 mutex_unlock(&mvm
->mutex
);
2536 static void iwl_mvm_channel_switch_beacon(struct ieee80211_hw
*hw
,
2537 struct ieee80211_vif
*vif
,
2538 struct cfg80211_chan_def
*chandef
)
2540 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2542 mutex_lock(&mvm
->mutex
);
2543 if (WARN(mvm
->csa_vif
&& mvm
->csa_vif
->csa_active
,
2544 "Another CSA is already in progress"))
2547 IWL_DEBUG_MAC80211(mvm
, "CSA started to freq %d\n",
2548 chandef
->center_freq1
);
2552 mutex_unlock(&mvm
->mutex
);
2555 static void iwl_mvm_mac_flush(struct ieee80211_hw
*hw
,
2556 struct ieee80211_vif
*vif
, u32 queues
, bool drop
)
2558 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
2559 struct iwl_mvm_vif
*mvmvif
;
2560 struct iwl_mvm_sta
*mvmsta
;
2562 if (!vif
|| vif
->type
!= NL80211_IFTYPE_STATION
)
2565 mutex_lock(&mvm
->mutex
);
2566 mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
2567 mvmsta
= iwl_mvm_sta_from_staid_protected(mvm
, mvmvif
->ap_sta_id
);
2569 if (WARN_ON_ONCE(!mvmsta
))
2573 if (iwl_mvm_flush_tx_path(mvm
, mvmsta
->tfd_queue_msk
, true))
2574 IWL_ERR(mvm
, "flush request fail\n");
2576 iwl_trans_wait_tx_queue_empty(mvm
->trans
,
2577 mvmsta
->tfd_queue_msk
);
2580 mutex_unlock(&mvm
->mutex
);
2583 const struct ieee80211_ops iwl_mvm_hw_ops
= {
2584 .tx
= iwl_mvm_mac_tx
,
2585 .ampdu_action
= iwl_mvm_mac_ampdu_action
,
2586 .start
= iwl_mvm_mac_start
,
2587 .restart_complete
= iwl_mvm_mac_restart_complete
,
2588 .stop
= iwl_mvm_mac_stop
,
2589 .add_interface
= iwl_mvm_mac_add_interface
,
2590 .remove_interface
= iwl_mvm_mac_remove_interface
,
2591 .config
= iwl_mvm_mac_config
,
2592 .prepare_multicast
= iwl_mvm_prepare_multicast
,
2593 .configure_filter
= iwl_mvm_configure_filter
,
2594 .bss_info_changed
= iwl_mvm_bss_info_changed
,
2595 .hw_scan
= iwl_mvm_mac_hw_scan
,
2596 .cancel_hw_scan
= iwl_mvm_mac_cancel_hw_scan
,
2597 .sta_pre_rcu_remove
= iwl_mvm_sta_pre_rcu_remove
,
2598 .sta_state
= iwl_mvm_mac_sta_state
,
2599 .sta_notify
= iwl_mvm_mac_sta_notify
,
2600 .allow_buffered_frames
= iwl_mvm_mac_allow_buffered_frames
,
2601 .release_buffered_frames
= iwl_mvm_mac_release_buffered_frames
,
2602 .set_rts_threshold
= iwl_mvm_mac_set_rts_threshold
,
2603 .sta_rc_update
= iwl_mvm_sta_rc_update
,
2604 .conf_tx
= iwl_mvm_mac_conf_tx
,
2605 .mgd_prepare_tx
= iwl_mvm_mac_mgd_prepare_tx
,
2606 .flush
= iwl_mvm_mac_flush
,
2607 .sched_scan_start
= iwl_mvm_mac_sched_scan_start
,
2608 .sched_scan_stop
= iwl_mvm_mac_sched_scan_stop
,
2609 .set_key
= iwl_mvm_mac_set_key
,
2610 .update_tkip_key
= iwl_mvm_mac_update_tkip_key
,
2611 .remain_on_channel
= iwl_mvm_roc
,
2612 .cancel_remain_on_channel
= iwl_mvm_cancel_roc
,
2613 .add_chanctx
= iwl_mvm_add_chanctx
,
2614 .remove_chanctx
= iwl_mvm_remove_chanctx
,
2615 .change_chanctx
= iwl_mvm_change_chanctx
,
2616 .assign_vif_chanctx
= iwl_mvm_assign_vif_chanctx
,
2617 .unassign_vif_chanctx
= iwl_mvm_unassign_vif_chanctx
,
2619 .start_ap
= iwl_mvm_start_ap_ibss
,
2620 .stop_ap
= iwl_mvm_stop_ap_ibss
,
2621 .join_ibss
= iwl_mvm_start_ap_ibss
,
2622 .leave_ibss
= iwl_mvm_stop_ap_ibss
,
2624 .set_tim
= iwl_mvm_set_tim
,
2626 .channel_switch_beacon
= iwl_mvm_channel_switch_beacon
,
2628 CFG80211_TESTMODE_CMD(iwl_mvm_mac_testmode_cmd
)
2630 #ifdef CONFIG_PM_SLEEP
2632 .suspend
= iwl_mvm_suspend
,
2633 .resume
= iwl_mvm_resume
,
2634 .set_wakeup
= iwl_mvm_set_wakeup
,
2635 .set_rekey_data
= iwl_mvm_set_rekey_data
,
2636 #if IS_ENABLED(CONFIG_IPV6)
2637 .ipv6_addr_change
= iwl_mvm_ipv6_addr_change
,
2639 .set_default_unicast_key
= iwl_mvm_set_default_unicast_key
,