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 - 2013 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 - 2013 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 <net/mac80211.h>
72 #include "iwl-op-mode.h"
76 #include "time-event.h"
77 #include "iwl-eeprom-parse.h"
78 #include "fw-api-scan.h"
79 #include "iwl-phy-db.h"
81 static const struct ieee80211_iface_limit iwl_mvm_limits
[] = {
84 .types
= BIT(NL80211_IFTYPE_STATION
) |
85 BIT(NL80211_IFTYPE_AP
),
89 .types
= BIT(NL80211_IFTYPE_P2P_CLIENT
) |
90 BIT(NL80211_IFTYPE_P2P_GO
),
94 .types
= BIT(NL80211_IFTYPE_P2P_DEVICE
),
98 static const struct ieee80211_iface_combination iwl_mvm_iface_combinations
[] = {
100 .num_different_channels
= 1,
102 .limits
= iwl_mvm_limits
,
103 .n_limits
= ARRAY_SIZE(iwl_mvm_limits
),
107 #ifdef CONFIG_PM_SLEEP
108 static const struct nl80211_wowlan_tcp_data_token_feature
109 iwl_mvm_wowlan_tcp_token_feature
= {
112 .bufsize
= IWL_WOWLAN_REMOTE_WAKE_MAX_TOKENS
,
115 static const struct wiphy_wowlan_tcp_support iwl_mvm_wowlan_tcp_support
= {
116 .tok
= &iwl_mvm_wowlan_tcp_token_feature
,
117 .data_payload_max
= IWL_WOWLAN_TCP_MAX_PACKET_LEN
-
118 sizeof(struct ethhdr
) -
119 sizeof(struct iphdr
) -
120 sizeof(struct tcphdr
),
121 .data_interval_max
= 65535, /* __le16 in API */
122 .wake_payload_max
= IWL_WOWLAN_REMOTE_WAKE_MAX_PACKET_LEN
-
123 sizeof(struct ethhdr
) -
124 sizeof(struct iphdr
) -
125 sizeof(struct tcphdr
),
130 int iwl_mvm_mac_setup_register(struct iwl_mvm
*mvm
)
132 struct ieee80211_hw
*hw
= mvm
->hw
;
135 /* Tell mac80211 our characteristics */
136 hw
->flags
= IEEE80211_HW_SIGNAL_DBM
|
137 IEEE80211_HW_SPECTRUM_MGMT
|
138 IEEE80211_HW_REPORTS_TX_ACK_STATUS
|
139 IEEE80211_HW_QUEUE_CONTROL
|
140 IEEE80211_HW_WANT_MONITOR_VIF
|
141 IEEE80211_HW_SUPPORTS_PS
|
142 IEEE80211_HW_SUPPORTS_DYNAMIC_PS
|
143 IEEE80211_HW_AMPDU_AGGREGATION
|
144 IEEE80211_HW_TIMING_BEACON_ONLY
;
146 hw
->queues
= IWL_MVM_FIRST_AGG_QUEUE
;
147 hw
->offchannel_tx_hw_queue
= IWL_MVM_OFFCHANNEL_QUEUE
;
148 hw
->rate_control_algorithm
= "iwl-mvm-rs";
151 * Enable 11w if advertised by firmware and software crypto
152 * is not enabled (as the firmware will interpret some mgmt
153 * packets, so enabling it with software crypto isn't safe)
155 if (mvm
->fw
->ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_MFP
&&
156 !iwlwifi_mod_params
.sw_crypto
)
157 hw
->flags
|= IEEE80211_HW_MFP_CAPABLE
;
159 hw
->sta_data_size
= sizeof(struct iwl_mvm_sta
);
160 hw
->vif_data_size
= sizeof(struct iwl_mvm_vif
);
161 hw
->chanctx_data_size
= sizeof(struct iwl_mvm_phy_ctxt
);
163 hw
->wiphy
->interface_modes
= BIT(NL80211_IFTYPE_STATION
) |
164 BIT(NL80211_IFTYPE_P2P_CLIENT
) |
165 BIT(NL80211_IFTYPE_AP
) |
166 BIT(NL80211_IFTYPE_P2P_GO
) |
167 BIT(NL80211_IFTYPE_P2P_DEVICE
);
169 hw
->wiphy
->flags
|= WIPHY_FLAG_CUSTOM_REGULATORY
|
170 WIPHY_FLAG_DISABLE_BEACON_HINTS
|
173 hw
->wiphy
->iface_combinations
= iwl_mvm_iface_combinations
;
174 hw
->wiphy
->n_iface_combinations
=
175 ARRAY_SIZE(iwl_mvm_iface_combinations
);
177 hw
->wiphy
->max_remain_on_channel_duration
= 10000;
178 hw
->max_listen_interval
= IWL_CONN_MAX_LISTEN_INTERVAL
;
180 /* Extract MAC address */
181 memcpy(mvm
->addresses
[0].addr
, mvm
->nvm_data
->hw_addr
, ETH_ALEN
);
182 hw
->wiphy
->addresses
= mvm
->addresses
;
183 hw
->wiphy
->n_addresses
= 1;
185 /* Extract additional MAC addresses if available */
186 num_mac
= (mvm
->nvm_data
->n_hw_addrs
> 1) ?
187 min(IWL_MVM_MAX_ADDRESSES
, mvm
->nvm_data
->n_hw_addrs
) : 1;
189 for (i
= 1; i
< num_mac
; i
++) {
190 memcpy(mvm
->addresses
[i
].addr
, mvm
->addresses
[i
-1].addr
,
192 mvm
->addresses
[i
].addr
[5]++;
193 hw
->wiphy
->n_addresses
++;
196 /* we create the 802.11 header and a max-length SSID element */
197 hw
->wiphy
->max_scan_ie_len
=
198 mvm
->fw
->ucode_capa
.max_probe_length
- 24 - 34;
199 hw
->wiphy
->max_scan_ssids
= PROBE_OPTION_MAX
;
201 if (mvm
->nvm_data
->bands
[IEEE80211_BAND_2GHZ
].n_channels
)
202 hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
] =
203 &mvm
->nvm_data
->bands
[IEEE80211_BAND_2GHZ
];
204 if (mvm
->nvm_data
->bands
[IEEE80211_BAND_5GHZ
].n_channels
)
205 hw
->wiphy
->bands
[IEEE80211_BAND_5GHZ
] =
206 &mvm
->nvm_data
->bands
[IEEE80211_BAND_5GHZ
];
208 hw
->wiphy
->hw_version
= mvm
->trans
->hw_id
;
210 if (iwlmvm_mod_params
.power_scheme
!= IWL_POWER_SCHEME_CAM
)
211 hw
->wiphy
->flags
|= WIPHY_FLAG_PS_ON_BY_DEFAULT
;
213 hw
->wiphy
->flags
&= ~WIPHY_FLAG_PS_ON_BY_DEFAULT
;
215 hw
->wiphy
->features
|= NL80211_FEATURE_P2P_GO_CTWIN
|
216 NL80211_FEATURE_P2P_GO_OPPPS
;
218 mvm
->rts_threshold
= IEEE80211_MAX_RTS_THRESHOLD
;
220 #ifdef CONFIG_PM_SLEEP
221 if (mvm
->fw
->img
[IWL_UCODE_WOWLAN
].sec
[0].len
&&
222 mvm
->trans
->ops
->d3_suspend
&&
223 mvm
->trans
->ops
->d3_resume
&&
224 device_can_wakeup(mvm
->trans
->dev
)) {
225 hw
->wiphy
->wowlan
.flags
= WIPHY_WOWLAN_MAGIC_PKT
|
226 WIPHY_WOWLAN_DISCONNECT
|
227 WIPHY_WOWLAN_EAP_IDENTITY_REQ
|
228 WIPHY_WOWLAN_RFKILL_RELEASE
;
229 if (!iwlwifi_mod_params
.sw_crypto
)
230 hw
->wiphy
->wowlan
.flags
|=
231 WIPHY_WOWLAN_SUPPORTS_GTK_REKEY
|
232 WIPHY_WOWLAN_GTK_REKEY_FAILURE
|
233 WIPHY_WOWLAN_4WAY_HANDSHAKE
;
235 hw
->wiphy
->wowlan
.n_patterns
= IWL_WOWLAN_MAX_PATTERNS
;
236 hw
->wiphy
->wowlan
.pattern_min_len
= IWL_WOWLAN_MIN_PATTERN_LEN
;
237 hw
->wiphy
->wowlan
.pattern_max_len
= IWL_WOWLAN_MAX_PATTERN_LEN
;
238 hw
->wiphy
->wowlan
.tcp
= &iwl_mvm_wowlan_tcp_support
;
242 ret
= iwl_mvm_leds_init(mvm
);
246 ret
= ieee80211_register_hw(mvm
->hw
);
248 iwl_mvm_leds_exit(mvm
);
253 static void iwl_mvm_mac_tx(struct ieee80211_hw
*hw
,
254 struct ieee80211_tx_control
*control
,
257 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
259 if (test_bit(IWL_MVM_STATUS_HW_RFKILL
, &mvm
->status
)) {
260 IWL_DEBUG_DROP(mvm
, "Dropping - RF KILL\n");
264 if (IEEE80211_SKB_CB(skb
)->hw_queue
== IWL_MVM_OFFCHANNEL_QUEUE
&&
265 !test_bit(IWL_MVM_STATUS_ROC_RUNNING
, &mvm
->status
))
269 if (iwl_mvm_tx_skb(mvm
, skb
, control
->sta
))
274 if (iwl_mvm_tx_skb_non_sta(mvm
, skb
))
278 ieee80211_free_txskb(hw
, skb
);
281 static inline bool iwl_enable_rx_ampdu(const struct iwl_cfg
*cfg
)
283 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_RXAGG
)
288 static inline bool iwl_enable_tx_ampdu(const struct iwl_cfg
*cfg
)
290 if (iwlwifi_mod_params
.disable_11n
& IWL_DISABLE_HT_TXAGG
)
292 if (iwlwifi_mod_params
.disable_11n
& IWL_ENABLE_HT_TXAGG
)
295 /* enabled by default */
299 static int iwl_mvm_mac_ampdu_action(struct ieee80211_hw
*hw
,
300 struct ieee80211_vif
*vif
,
301 enum ieee80211_ampdu_mlme_action action
,
302 struct ieee80211_sta
*sta
, u16 tid
,
303 u16
*ssn
, u8 buf_size
)
305 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
308 IWL_DEBUG_HT(mvm
, "A-MPDU action on addr %pM tid %d: action %d\n",
309 sta
->addr
, tid
, action
);
311 if (!(mvm
->nvm_data
->sku_cap_11n_enable
))
314 mutex_lock(&mvm
->mutex
);
317 case IEEE80211_AMPDU_RX_START
:
318 if (!iwl_enable_rx_ampdu(mvm
->cfg
)) {
322 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, *ssn
, true);
324 case IEEE80211_AMPDU_RX_STOP
:
325 ret
= iwl_mvm_sta_rx_agg(mvm
, sta
, tid
, 0, false);
327 case IEEE80211_AMPDU_TX_START
:
328 if (!iwl_enable_tx_ampdu(mvm
->cfg
)) {
332 ret
= iwl_mvm_sta_tx_agg_start(mvm
, vif
, sta
, tid
, ssn
);
334 case IEEE80211_AMPDU_TX_STOP_CONT
:
335 ret
= iwl_mvm_sta_tx_agg_stop(mvm
, vif
, sta
, tid
);
337 case IEEE80211_AMPDU_TX_STOP_FLUSH
:
338 case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT
:
339 ret
= iwl_mvm_sta_tx_agg_flush(mvm
, vif
, sta
, tid
);
341 case IEEE80211_AMPDU_TX_OPERATIONAL
:
342 ret
= iwl_mvm_sta_tx_agg_oper(mvm
, vif
, sta
, tid
, buf_size
);
349 mutex_unlock(&mvm
->mutex
);
354 static void iwl_mvm_cleanup_iterator(void *data
, u8
*mac
,
355 struct ieee80211_vif
*vif
)
357 struct iwl_mvm
*mvm
= data
;
358 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
360 mvmvif
->uploaded
= false;
361 mvmvif
->ap_sta_id
= IWL_MVM_STATION_COUNT
;
363 spin_lock_bh(&mvm
->time_event_lock
);
364 iwl_mvm_te_clear_data(mvm
, &mvmvif
->time_event_data
);
365 spin_unlock_bh(&mvm
->time_event_lock
);
367 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
368 mvmvif
->phy_ctxt
= NULL
;
371 static void iwl_mvm_restart_cleanup(struct iwl_mvm
*mvm
)
373 iwl_trans_stop_device(mvm
->trans
);
374 iwl_trans_stop_hw(mvm
->trans
, false);
376 mvm
->scan_status
= IWL_MVM_SCAN_NONE
;
378 /* just in case one was running */
379 ieee80211_remain_on_channel_expired(mvm
->hw
);
381 ieee80211_iterate_active_interfaces_atomic(
382 mvm
->hw
, IEEE80211_IFACE_ITER_RESUME_ALL
,
383 iwl_mvm_cleanup_iterator
, mvm
);
385 memset(mvm
->fw_key_table
, 0, sizeof(mvm
->fw_key_table
));
386 memset(mvm
->sta_drained
, 0, sizeof(mvm
->sta_drained
));
388 ieee80211_wake_queues(mvm
->hw
);
393 static int iwl_mvm_mac_start(struct ieee80211_hw
*hw
)
395 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
398 mutex_lock(&mvm
->mutex
);
400 /* Clean up some internal and mac80211 state on restart */
401 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
))
402 iwl_mvm_restart_cleanup(mvm
);
404 ret
= iwl_mvm_up(mvm
);
405 mutex_unlock(&mvm
->mutex
);
410 static void iwl_mvm_mac_restart_complete(struct ieee80211_hw
*hw
)
412 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
415 mutex_lock(&mvm
->mutex
);
417 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART
, &mvm
->status
);
418 ret
= iwl_mvm_update_quotas(mvm
, NULL
);
420 IWL_ERR(mvm
, "Failed to update quotas after restart (%d)\n",
423 mutex_unlock(&mvm
->mutex
);
426 static void iwl_mvm_mac_stop(struct ieee80211_hw
*hw
)
428 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
430 flush_work(&mvm
->async_handlers_wk
);
432 mutex_lock(&mvm
->mutex
);
433 /* async_handlers_wk is now blocked */
436 * The work item could be running or queued if the
437 * ROC time event stops just as we get here.
439 cancel_work_sync(&mvm
->roc_done_wk
);
441 iwl_trans_stop_device(mvm
->trans
);
442 iwl_trans_stop_hw(mvm
->trans
, false);
444 iwl_mvm_async_handlers_purge(mvm
);
445 /* async_handlers_list is empty and will stay empty: HW is stopped */
447 /* the fw is stopped, the aux sta is dead: clean up driver state */
448 iwl_mvm_dealloc_int_sta(mvm
, &mvm
->aux_sta
);
450 mutex_unlock(&mvm
->mutex
);
453 * The worker might have been waiting for the mutex, let it run and
454 * discover that its list is now empty.
456 cancel_work_sync(&mvm
->async_handlers_wk
);
459 static void iwl_mvm_pm_disable_iterator(void *data
, u8
*mac
,
460 struct ieee80211_vif
*vif
)
462 struct iwl_mvm
*mvm
= data
;
465 ret
= iwl_mvm_power_disable(mvm
, vif
);
467 IWL_ERR(mvm
, "failed to disable power management\n");
470 static void iwl_mvm_power_update_iterator(void *data
, u8
*mac
,
471 struct ieee80211_vif
*vif
)
473 struct iwl_mvm
*mvm
= data
;
475 iwl_mvm_power_update_mode(mvm
, vif
);
478 static int iwl_mvm_mac_add_interface(struct ieee80211_hw
*hw
,
479 struct ieee80211_vif
*vif
)
481 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
482 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
486 * Not much to do here. The stack will not allow interface
487 * types or combinations that we didn't advertise, so we
488 * don't really have to check the types.
491 mutex_lock(&mvm
->mutex
);
493 /* Allocate resources for the MAC context, and add it the the fw */
494 ret
= iwl_mvm_mac_ctxt_init(mvm
, vif
);
499 * The AP binding flow can be done only after the beacon
500 * template is configured (which happens only in the mac80211
501 * start_ap() flow), and adding the broadcast station can happen
502 * only after the binding.
503 * In addition, since modifying the MAC before adding a bcast
504 * station is not allowed by the FW, delay the adding of MAC context to
505 * the point where we can also add the bcast station.
506 * In short: there's not much we can do at this point, other than
507 * allocating resources :)
509 if (vif
->type
== NL80211_IFTYPE_AP
) {
510 u32 qmask
= iwl_mvm_mac_get_queues_mask(mvm
, vif
);
511 ret
= iwl_mvm_allocate_int_sta(mvm
, &mvmvif
->bcast_sta
,
514 IWL_ERR(mvm
, "Failed to allocate bcast sta\n");
522 * TODO: remove this temporary code.
523 * Currently MVM FW supports power management only on single MAC.
524 * If new interface added, disable PM on existing interface.
525 * P2P device is a special case, since it is handled by FW similary to
526 * scan. If P2P deviced is added, PM remains enabled on existing
528 * Note: the method below does not count the new interface being added
531 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
533 if (mvm
->vif_count
> 1) {
534 IWL_DEBUG_MAC80211(mvm
,
535 "Disable power on existing interfaces\n");
536 ieee80211_iterate_active_interfaces_atomic(
538 IEEE80211_IFACE_ITER_NORMAL
,
539 iwl_mvm_pm_disable_iterator
, mvm
);
542 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
547 * Update power state on the new interface. Admittedly, based on
548 * mac80211 logics this power update will disable power management
550 iwl_mvm_power_update_mode(mvm
, vif
);
553 * P2P_DEVICE interface does not have a channel context assigned to it,
554 * so a dedicated PHY context is allocated to it and the corresponding
555 * MAC context is bound to it at this stage.
557 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
558 struct ieee80211_channel
*chan
;
559 struct cfg80211_chan_def chandef
;
561 mvmvif
->phy_ctxt
= &mvm
->phy_ctxt_roc
;
564 * The channel used here isn't relevant as it's
565 * going to be overwritten as part of the ROC flow.
566 * For now use the first channel we have.
568 chan
= &mvm
->hw
->wiphy
->bands
[IEEE80211_BAND_2GHZ
]->channels
[0];
569 cfg80211_chandef_create(&chandef
, chan
, NL80211_CHAN_NO_HT
);
570 ret
= iwl_mvm_phy_ctxt_add(mvm
, mvmvif
->phy_ctxt
,
575 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
579 ret
= iwl_mvm_add_bcast_sta(mvm
, vif
, &mvmvif
->bcast_sta
);
583 /* Save a pointer to p2p device vif, so it can later be used to
584 * update the p2p device MAC when a GO is started/stopped */
585 mvm
->p2p_device_vif
= vif
;
588 iwl_mvm_vif_dbgfs_register(mvm
, vif
);
592 iwl_mvm_binding_remove_vif(mvm
, vif
);
594 iwl_mvm_phy_ctxt_remove(mvm
, mvmvif
->phy_ctxt
);
596 mvmvif
->phy_ctxt
= NULL
;
597 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
600 * TODO: remove this temporary code.
601 * Currently MVM FW supports power management only on single MAC.
602 * Check if only one additional interface remains after releasing
603 * current one. Update power mode on the remaining interface.
605 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
607 IWL_DEBUG_MAC80211(mvm
, "Currently %d interfaces active\n",
609 if (mvm
->vif_count
== 1) {
610 ieee80211_iterate_active_interfaces(
611 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
612 iwl_mvm_power_update_iterator
, mvm
);
614 iwl_mvm_mac_ctxt_release(mvm
, vif
);
616 mutex_unlock(&mvm
->mutex
);
621 static void iwl_mvm_prepare_mac_removal(struct iwl_mvm
*mvm
,
622 struct ieee80211_vif
*vif
)
626 for (ac
= 0; ac
< IEEE80211_NUM_ACS
; ac
++)
627 if (vif
->hw_queue
[ac
] != IEEE80211_INVAL_HW_QUEUE
)
628 tfd_msk
|= BIT(vif
->hw_queue
[ac
]);
630 if (vif
->cab_queue
!= IEEE80211_INVAL_HW_QUEUE
)
631 tfd_msk
|= BIT(vif
->cab_queue
);
634 mutex_lock(&mvm
->mutex
);
635 iwl_mvm_flush_tx_path(mvm
, tfd_msk
, true);
636 mutex_unlock(&mvm
->mutex
);
639 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
641 * Flush the ROC worker which will flush the OFFCHANNEL queue.
642 * We assume here that all the packets sent to the OFFCHANNEL
643 * queue are sent in ROC session.
645 flush_work(&mvm
->roc_done_wk
);
648 * By now, all the AC queues are empty. The AGG queues are
649 * empty too. We already got all the Tx responses for all the
650 * packets in the queues. The drain work can have been
651 * triggered. Flush it. This work item takes the mutex, so kill
652 * it before we take it.
654 flush_work(&mvm
->sta_drained_wk
);
658 static void iwl_mvm_mac_remove_interface(struct ieee80211_hw
*hw
,
659 struct ieee80211_vif
*vif
)
661 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
662 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
664 iwl_mvm_prepare_mac_removal(mvm
, vif
);
666 mutex_lock(&mvm
->mutex
);
668 iwl_mvm_vif_dbgfs_clean(mvm
, vif
);
671 * For AP/GO interface, the tear down of the resources allocated to the
672 * interface is be handled as part of the stop_ap flow.
674 if (vif
->type
== NL80211_IFTYPE_AP
) {
675 iwl_mvm_dealloc_int_sta(mvm
, &mvmvif
->bcast_sta
);
679 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
680 mvm
->p2p_device_vif
= NULL
;
681 iwl_mvm_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
682 iwl_mvm_binding_remove_vif(mvm
, vif
);
683 iwl_mvm_phy_ctxt_remove(mvm
, mvmvif
->phy_ctxt
);
684 mvmvif
->phy_ctxt
= NULL
;
688 * TODO: remove this temporary code.
689 * Currently MVM FW supports power management only on single MAC.
690 * Check if only one additional interface remains after removing
691 * current one. Update power mode on the remaining interface.
693 if (mvm
->vif_count
&& vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
)
695 IWL_DEBUG_MAC80211(mvm
, "Currently %d interfaces active\n",
697 if (mvm
->vif_count
== 1) {
698 ieee80211_iterate_active_interfaces(
699 mvm
->hw
, IEEE80211_IFACE_ITER_NORMAL
,
700 iwl_mvm_power_update_iterator
, mvm
);
703 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
706 iwl_mvm_mac_ctxt_release(mvm
, vif
);
707 mutex_unlock(&mvm
->mutex
);
710 static int iwl_mvm_mac_config(struct ieee80211_hw
*hw
, u32 changed
)
715 static void iwl_mvm_configure_filter(struct ieee80211_hw
*hw
,
716 unsigned int changed_flags
,
717 unsigned int *total_flags
,
723 static int iwl_mvm_configure_mcast_filter(struct iwl_mvm
*mvm
,
724 struct ieee80211_vif
*vif
)
726 struct iwl_mcast_filter_cmd mcast_filter_cmd
= {
730 memcpy(mcast_filter_cmd
.bssid
, vif
->bss_conf
.bssid
, ETH_ALEN
);
732 return iwl_mvm_send_cmd_pdu(mvm
, MCAST_FILTER_CMD
, CMD_SYNC
,
733 sizeof(mcast_filter_cmd
),
737 static void iwl_mvm_bss_info_changed_station(struct iwl_mvm
*mvm
,
738 struct ieee80211_vif
*vif
,
739 struct ieee80211_bss_conf
*bss_conf
,
742 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
745 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
);
747 IWL_ERR(mvm
, "failed to update MAC %pM\n", vif
->addr
);
749 if (changes
& BSS_CHANGED_ASSOC
) {
750 if (bss_conf
->assoc
) {
751 /* add quota for this interface */
752 ret
= iwl_mvm_update_quotas(mvm
, vif
);
754 IWL_ERR(mvm
, "failed to update quotas\n");
757 iwl_mvm_bt_coex_vif_assoc(mvm
, vif
);
758 iwl_mvm_configure_mcast_filter(mvm
, vif
);
759 } else if (mvmvif
->ap_sta_id
!= IWL_MVM_STATION_COUNT
) {
760 /* remove AP station now that the MAC is unassoc */
761 ret
= iwl_mvm_rm_sta_id(mvm
, vif
, mvmvif
->ap_sta_id
);
763 IWL_ERR(mvm
, "failed to remove AP station\n");
764 mvmvif
->ap_sta_id
= IWL_MVM_STATION_COUNT
;
765 /* remove quota for this interface */
766 ret
= iwl_mvm_update_quotas(mvm
, NULL
);
768 IWL_ERR(mvm
, "failed to update quotas\n");
770 } else if (changes
& BSS_CHANGED_DTIM_PERIOD
) {
772 * We received a beacon _after_ association so
773 * remove the session protection.
775 iwl_mvm_remove_time_event(mvm
, mvmvif
,
776 &mvmvif
->time_event_data
);
777 } else if (changes
& BSS_CHANGED_PS
) {
779 * TODO: remove this temporary code.
780 * Currently MVM FW supports power management only on single
781 * MAC. Avoid power mode update if more than one interface
784 IWL_DEBUG_MAC80211(mvm
, "Currently %d interfaces active\n",
786 if (mvm
->vif_count
== 1) {
787 ret
= iwl_mvm_power_update_mode(mvm
, vif
);
789 IWL_ERR(mvm
, "failed to update power mode\n");
794 static int iwl_mvm_start_ap(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
796 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
797 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
800 mutex_lock(&mvm
->mutex
);
802 /* Send the beacon template */
803 ret
= iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
);
807 /* Add the mac context */
808 ret
= iwl_mvm_mac_ctxt_add(mvm
, vif
);
812 /* Perform the binding */
813 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
817 mvmvif
->ap_active
= true;
819 /* Send the bcast station. At this stage the TBTT and DTIM time events
820 * are added and applied to the scheduler */
821 ret
= iwl_mvm_send_bcast_sta(mvm
, vif
, &mvmvif
->bcast_sta
);
825 ret
= iwl_mvm_update_quotas(mvm
, vif
);
829 /* Need to update the P2P Device MAC */
830 if (vif
->p2p
&& mvm
->p2p_device_vif
)
831 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
);
833 mutex_unlock(&mvm
->mutex
);
837 iwl_mvm_send_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
839 iwl_mvm_binding_remove_vif(mvm
, vif
);
841 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
843 mutex_unlock(&mvm
->mutex
);
847 static void iwl_mvm_stop_ap(struct ieee80211_hw
*hw
, struct ieee80211_vif
*vif
)
849 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
850 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
852 iwl_mvm_prepare_mac_removal(mvm
, vif
);
854 mutex_lock(&mvm
->mutex
);
856 mvmvif
->ap_active
= false;
858 /* Need to update the P2P Device MAC */
859 if (vif
->p2p
&& mvm
->p2p_device_vif
)
860 iwl_mvm_mac_ctxt_changed(mvm
, mvm
->p2p_device_vif
);
862 iwl_mvm_update_quotas(mvm
, NULL
);
863 iwl_mvm_send_rm_bcast_sta(mvm
, &mvmvif
->bcast_sta
);
864 iwl_mvm_binding_remove_vif(mvm
, vif
);
865 iwl_mvm_mac_ctxt_remove(mvm
, vif
);
867 mutex_unlock(&mvm
->mutex
);
870 static void iwl_mvm_bss_info_changed_ap(struct iwl_mvm
*mvm
,
871 struct ieee80211_vif
*vif
,
872 struct ieee80211_bss_conf
*bss_conf
,
875 /* Need to send a new beacon template to the FW */
876 if (changes
& BSS_CHANGED_BEACON
) {
877 if (iwl_mvm_mac_ctxt_beacon_changed(mvm
, vif
))
878 IWL_WARN(mvm
, "Failed updating beacon data\n");
882 static void iwl_mvm_bss_info_changed(struct ieee80211_hw
*hw
,
883 struct ieee80211_vif
*vif
,
884 struct ieee80211_bss_conf
*bss_conf
,
887 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
889 mutex_lock(&mvm
->mutex
);
892 case NL80211_IFTYPE_STATION
:
893 iwl_mvm_bss_info_changed_station(mvm
, vif
, bss_conf
, changes
);
895 case NL80211_IFTYPE_AP
:
896 iwl_mvm_bss_info_changed_ap(mvm
, vif
, bss_conf
, changes
);
899 /* shouldn't happen */
903 mutex_unlock(&mvm
->mutex
);
906 static int iwl_mvm_mac_hw_scan(struct ieee80211_hw
*hw
,
907 struct ieee80211_vif
*vif
,
908 struct cfg80211_scan_request
*req
)
910 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
913 if (req
->n_channels
== 0 || req
->n_channels
> MAX_NUM_SCAN_CHANNELS
)
916 mutex_lock(&mvm
->mutex
);
918 if (mvm
->scan_status
== IWL_MVM_SCAN_NONE
)
919 ret
= iwl_mvm_scan_request(mvm
, vif
, req
);
923 mutex_unlock(&mvm
->mutex
);
928 static void iwl_mvm_mac_cancel_hw_scan(struct ieee80211_hw
*hw
,
929 struct ieee80211_vif
*vif
)
931 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
933 mutex_lock(&mvm
->mutex
);
935 iwl_mvm_cancel_scan(mvm
);
937 mutex_unlock(&mvm
->mutex
);
941 iwl_mvm_mac_allow_buffered_frames(struct ieee80211_hw
*hw
,
942 struct ieee80211_sta
*sta
, u16 tid
,
944 enum ieee80211_frame_release_type reason
,
947 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
949 /* TODO: how do we tell the fw to send frames for a specific TID */
952 * The fw will send EOSP notification when the last frame will be
955 iwl_mvm_sta_modify_sleep_tx_count(mvm
, sta
, reason
, num_frames
);
958 static void iwl_mvm_mac_sta_notify(struct ieee80211_hw
*hw
,
959 struct ieee80211_vif
*vif
,
960 enum sta_notify_cmd cmd
,
961 struct ieee80211_sta
*sta
)
963 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
964 struct iwl_mvm_sta
*mvmsta
= (void *)sta
->drv_priv
;
967 case STA_NOTIFY_SLEEP
:
968 if (atomic_read(&mvm
->pending_frames
[mvmsta
->sta_id
]) > 0)
969 ieee80211_sta_block_awake(hw
, sta
, true);
971 * The fw updates the STA to be asleep. Tx packets on the Tx
972 * queues to this station will not be transmitted. The fw will
973 * send a Tx response with TX_STATUS_FAIL_DEST_PS.
976 case STA_NOTIFY_AWAKE
:
977 if (WARN_ON(mvmsta
->sta_id
== IWL_MVM_STATION_COUNT
))
979 iwl_mvm_sta_modify_ps_wake(mvm
, sta
);
986 static int iwl_mvm_mac_sta_state(struct ieee80211_hw
*hw
,
987 struct ieee80211_vif
*vif
,
988 struct ieee80211_sta
*sta
,
989 enum ieee80211_sta_state old_state
,
990 enum ieee80211_sta_state new_state
)
992 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
993 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
996 IWL_DEBUG_MAC80211(mvm
, "station %pM state change %d->%d\n",
997 sta
->addr
, old_state
, new_state
);
999 /* this would be a mac80211 bug ... but don't crash */
1000 if (WARN_ON_ONCE(!mvmvif
->phy_ctxt
))
1003 /* if a STA is being removed, reuse its ID */
1004 flush_work(&mvm
->sta_drained_wk
);
1006 mutex_lock(&mvm
->mutex
);
1007 if (old_state
== IEEE80211_STA_NOTEXIST
&&
1008 new_state
== IEEE80211_STA_NONE
) {
1010 * Firmware bug - it'll crash if the beacon interval is less
1011 * than 16. We can't avoid connecting at all, so refuse the
1012 * station state change, this will cause mac80211 to abandon
1013 * attempts to connect to this AP, and eventually wpa_s will
1014 * blacklist the AP...
1016 if (vif
->type
== NL80211_IFTYPE_STATION
&&
1017 vif
->bss_conf
.beacon_int
< 16) {
1019 "AP %pM beacon interval is %d, refusing due to firmware bug!\n",
1020 sta
->addr
, vif
->bss_conf
.beacon_int
);
1024 ret
= iwl_mvm_add_sta(mvm
, vif
, sta
);
1025 } else if (old_state
== IEEE80211_STA_NONE
&&
1026 new_state
== IEEE80211_STA_AUTH
) {
1028 } else if (old_state
== IEEE80211_STA_AUTH
&&
1029 new_state
== IEEE80211_STA_ASSOC
) {
1030 ret
= iwl_mvm_update_sta(mvm
, vif
, sta
);
1032 iwl_mvm_rs_rate_init(mvm
, sta
,
1033 mvmvif
->phy_ctxt
->channel
->band
);
1034 } else if (old_state
== IEEE80211_STA_ASSOC
&&
1035 new_state
== IEEE80211_STA_AUTHORIZED
) {
1037 } else if (old_state
== IEEE80211_STA_AUTHORIZED
&&
1038 new_state
== IEEE80211_STA_ASSOC
) {
1040 } else if (old_state
== IEEE80211_STA_ASSOC
&&
1041 new_state
== IEEE80211_STA_AUTH
) {
1043 } else if (old_state
== IEEE80211_STA_AUTH
&&
1044 new_state
== IEEE80211_STA_NONE
) {
1046 } else if (old_state
== IEEE80211_STA_NONE
&&
1047 new_state
== IEEE80211_STA_NOTEXIST
) {
1048 ret
= iwl_mvm_rm_sta(mvm
, vif
, sta
);
1053 mutex_unlock(&mvm
->mutex
);
1058 static int iwl_mvm_mac_set_rts_threshold(struct ieee80211_hw
*hw
, u32 value
)
1060 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1062 mvm
->rts_threshold
= value
;
1067 static int iwl_mvm_mac_conf_tx(struct ieee80211_hw
*hw
,
1068 struct ieee80211_vif
*vif
, u16 ac
,
1069 const struct ieee80211_tx_queue_params
*params
)
1071 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1072 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1074 mvmvif
->queue_params
[ac
] = *params
;
1077 * No need to update right away, we'll get BSS_CHANGED_QOS
1078 * The exception is P2P_DEVICE interface which needs immediate update.
1080 if (vif
->type
== NL80211_IFTYPE_P2P_DEVICE
) {
1083 mutex_lock(&mvm
->mutex
);
1084 ret
= iwl_mvm_mac_ctxt_changed(mvm
, vif
);
1085 mutex_unlock(&mvm
->mutex
);
1091 static void iwl_mvm_mac_mgd_prepare_tx(struct ieee80211_hw
*hw
,
1092 struct ieee80211_vif
*vif
)
1094 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1095 u32 duration
= min(IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS
,
1096 200 + vif
->bss_conf
.beacon_int
);
1097 u32 min_duration
= min(IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS
,
1098 100 + vif
->bss_conf
.beacon_int
);
1100 if (WARN_ON_ONCE(vif
->bss_conf
.assoc
))
1103 mutex_lock(&mvm
->mutex
);
1104 /* Try really hard to protect the session and hear a beacon */
1105 iwl_mvm_protect_session(mvm
, vif
, duration
, min_duration
);
1106 mutex_unlock(&mvm
->mutex
);
1109 static int iwl_mvm_mac_set_key(struct ieee80211_hw
*hw
,
1110 enum set_key_cmd cmd
,
1111 struct ieee80211_vif
*vif
,
1112 struct ieee80211_sta
*sta
,
1113 struct ieee80211_key_conf
*key
)
1115 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1118 if (iwlwifi_mod_params
.sw_crypto
) {
1119 IWL_DEBUG_MAC80211(mvm
, "leave - hwcrypto disabled\n");
1123 switch (key
->cipher
) {
1124 case WLAN_CIPHER_SUITE_TKIP
:
1125 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_MMIC
;
1127 case WLAN_CIPHER_SUITE_CCMP
:
1128 key
->flags
|= IEEE80211_KEY_FLAG_GENERATE_IV
;
1130 case WLAN_CIPHER_SUITE_AES_CMAC
:
1131 WARN_ON_ONCE(!(hw
->flags
& IEEE80211_HW_MFP_CAPABLE
));
1133 case WLAN_CIPHER_SUITE_WEP40
:
1134 case WLAN_CIPHER_SUITE_WEP104
:
1136 * Support for TX only, at least for now, so accept
1137 * the key and do nothing else. Then mac80211 will
1138 * pass it for TX but we don't have to use it for RX.
1145 mutex_lock(&mvm
->mutex
);
1149 if (vif
->type
== NL80211_IFTYPE_AP
&& !sta
) {
1150 /* GTK on AP interface is a TX-only key, return 0 */
1152 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
1156 IWL_DEBUG_MAC80211(mvm
, "set hwcrypto key\n");
1157 ret
= iwl_mvm_set_sta_key(mvm
, vif
, sta
, key
, false);
1159 IWL_WARN(mvm
, "set key failed\n");
1161 * can't add key for RX, but we don't need it
1162 * in the device for TX so still return 0
1164 key
->hw_key_idx
= STA_KEY_IDX_INVALID
;
1170 if (key
->hw_key_idx
== STA_KEY_IDX_INVALID
) {
1175 IWL_DEBUG_MAC80211(mvm
, "disable hwcrypto key\n");
1176 ret
= iwl_mvm_remove_sta_key(mvm
, vif
, sta
, key
);
1182 mutex_unlock(&mvm
->mutex
);
1186 static void iwl_mvm_mac_update_tkip_key(struct ieee80211_hw
*hw
,
1187 struct ieee80211_vif
*vif
,
1188 struct ieee80211_key_conf
*keyconf
,
1189 struct ieee80211_sta
*sta
,
1190 u32 iv32
, u16
*phase1key
)
1192 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1194 iwl_mvm_update_tkip_key(mvm
, vif
, keyconf
, sta
, iv32
, phase1key
);
1198 static int iwl_mvm_roc(struct ieee80211_hw
*hw
,
1199 struct ieee80211_vif
*vif
,
1200 struct ieee80211_channel
*channel
,
1202 enum ieee80211_roc_type type
)
1204 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1205 struct cfg80211_chan_def chandef
;
1208 if (vif
->type
!= NL80211_IFTYPE_P2P_DEVICE
) {
1209 IWL_ERR(mvm
, "vif isn't a P2P_DEVICE: %d\n", vif
->type
);
1213 IWL_DEBUG_MAC80211(mvm
, "enter (%d, %d, %d)\n", channel
->hw_value
,
1216 mutex_lock(&mvm
->mutex
);
1218 cfg80211_chandef_create(&chandef
, channel
, NL80211_CHAN_NO_HT
);
1219 ret
= iwl_mvm_phy_ctxt_changed(mvm
, &mvm
->phy_ctxt_roc
,
1222 /* Schedule the time events */
1223 ret
= iwl_mvm_start_p2p_roc(mvm
, vif
, duration
, type
);
1225 mutex_unlock(&mvm
->mutex
);
1226 IWL_DEBUG_MAC80211(mvm
, "leave\n");
1231 static int iwl_mvm_cancel_roc(struct ieee80211_hw
*hw
)
1233 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1235 IWL_DEBUG_MAC80211(mvm
, "enter\n");
1237 mutex_lock(&mvm
->mutex
);
1238 iwl_mvm_stop_p2p_roc(mvm
);
1239 mutex_unlock(&mvm
->mutex
);
1241 IWL_DEBUG_MAC80211(mvm
, "leave\n");
1245 static int iwl_mvm_add_chanctx(struct ieee80211_hw
*hw
,
1246 struct ieee80211_chanctx_conf
*ctx
)
1248 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1249 struct iwl_mvm_phy_ctxt
*phy_ctxt
= (void *)ctx
->drv_priv
;
1252 mutex_lock(&mvm
->mutex
);
1254 IWL_DEBUG_MAC80211(mvm
, "Add PHY context\n");
1255 ret
= iwl_mvm_phy_ctxt_add(mvm
, phy_ctxt
, &ctx
->def
,
1256 ctx
->rx_chains_static
,
1257 ctx
->rx_chains_dynamic
);
1258 mutex_unlock(&mvm
->mutex
);
1262 static void iwl_mvm_remove_chanctx(struct ieee80211_hw
*hw
,
1263 struct ieee80211_chanctx_conf
*ctx
)
1265 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1266 struct iwl_mvm_phy_ctxt
*phy_ctxt
= (void *)ctx
->drv_priv
;
1268 mutex_lock(&mvm
->mutex
);
1269 iwl_mvm_phy_ctxt_remove(mvm
, phy_ctxt
);
1270 mutex_unlock(&mvm
->mutex
);
1273 static void iwl_mvm_change_chanctx(struct ieee80211_hw
*hw
,
1274 struct ieee80211_chanctx_conf
*ctx
,
1277 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1278 struct iwl_mvm_phy_ctxt
*phy_ctxt
= (void *)ctx
->drv_priv
;
1280 mutex_lock(&mvm
->mutex
);
1281 iwl_mvm_phy_ctxt_changed(mvm
, phy_ctxt
, &ctx
->def
,
1282 ctx
->rx_chains_static
,
1283 ctx
->rx_chains_dynamic
);
1284 mutex_unlock(&mvm
->mutex
);
1287 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw
*hw
,
1288 struct ieee80211_vif
*vif
,
1289 struct ieee80211_chanctx_conf
*ctx
)
1291 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1292 struct iwl_mvm_phy_ctxt
*phyctx
= (void *)ctx
->drv_priv
;
1293 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1296 mutex_lock(&mvm
->mutex
);
1298 mvmvif
->phy_ctxt
= phyctx
;
1300 switch (vif
->type
) {
1301 case NL80211_IFTYPE_AP
:
1303 * The AP binding flow is handled as part of the start_ap flow
1304 * (in bss_info_changed).
1308 case NL80211_IFTYPE_STATION
:
1309 case NL80211_IFTYPE_ADHOC
:
1310 case NL80211_IFTYPE_MONITOR
:
1317 ret
= iwl_mvm_binding_add_vif(mvm
, vif
);
1322 * Setting the quota at this stage is only required for monitor
1323 * interfaces. For the other types, the bss_info changed flow
1324 * will handle quota settings.
1326 if (vif
->type
== NL80211_IFTYPE_MONITOR
) {
1327 mvmvif
->monitor_active
= true;
1328 ret
= iwl_mvm_update_quotas(mvm
, vif
);
1330 goto out_remove_binding
;
1336 iwl_mvm_binding_remove_vif(mvm
, vif
);
1338 mutex_unlock(&mvm
->mutex
);
1340 mvmvif
->phy_ctxt
= NULL
;
1344 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw
*hw
,
1345 struct ieee80211_vif
*vif
,
1346 struct ieee80211_chanctx_conf
*ctx
)
1348 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1349 struct iwl_mvm_vif
*mvmvif
= iwl_mvm_vif_from_mac80211(vif
);
1351 mutex_lock(&mvm
->mutex
);
1353 iwl_mvm_remove_time_event(mvm
, mvmvif
, &mvmvif
->time_event_data
);
1355 if (vif
->type
== NL80211_IFTYPE_AP
)
1358 switch (vif
->type
) {
1359 case NL80211_IFTYPE_MONITOR
:
1360 mvmvif
->monitor_active
= false;
1361 iwl_mvm_update_quotas(mvm
, NULL
);
1367 iwl_mvm_binding_remove_vif(mvm
, vif
);
1369 mvmvif
->phy_ctxt
= NULL
;
1370 mutex_unlock(&mvm
->mutex
);
1373 static int iwl_mvm_set_tim(struct ieee80211_hw
*hw
,
1374 struct ieee80211_sta
*sta
,
1377 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1378 struct iwl_mvm_sta
*mvm_sta
= (void *)sta
->drv_priv
;
1380 if (!mvm_sta
|| !mvm_sta
->vif
) {
1381 IWL_ERR(mvm
, "Station is not associated to a vif\n");
1385 return iwl_mvm_mac_ctxt_beacon_changed(mvm
, mvm_sta
->vif
);
1388 static void iwl_mvm_mac_rssi_callback(struct ieee80211_hw
*hw
,
1389 struct ieee80211_vif
*vif
,
1390 enum ieee80211_rssi_event rssi_event
)
1392 struct iwl_mvm
*mvm
= IWL_MAC80211_GET_MVM(hw
);
1394 iwl_mvm_bt_rssi_event(mvm
, vif
, rssi_event
);
1397 struct ieee80211_ops iwl_mvm_hw_ops
= {
1398 .tx
= iwl_mvm_mac_tx
,
1399 .ampdu_action
= iwl_mvm_mac_ampdu_action
,
1400 .start
= iwl_mvm_mac_start
,
1401 .restart_complete
= iwl_mvm_mac_restart_complete
,
1402 .stop
= iwl_mvm_mac_stop
,
1403 .add_interface
= iwl_mvm_mac_add_interface
,
1404 .remove_interface
= iwl_mvm_mac_remove_interface
,
1405 .config
= iwl_mvm_mac_config
,
1406 .configure_filter
= iwl_mvm_configure_filter
,
1407 .bss_info_changed
= iwl_mvm_bss_info_changed
,
1408 .hw_scan
= iwl_mvm_mac_hw_scan
,
1409 .cancel_hw_scan
= iwl_mvm_mac_cancel_hw_scan
,
1410 .sta_state
= iwl_mvm_mac_sta_state
,
1411 .sta_notify
= iwl_mvm_mac_sta_notify
,
1412 .allow_buffered_frames
= iwl_mvm_mac_allow_buffered_frames
,
1413 .set_rts_threshold
= iwl_mvm_mac_set_rts_threshold
,
1414 .conf_tx
= iwl_mvm_mac_conf_tx
,
1415 .mgd_prepare_tx
= iwl_mvm_mac_mgd_prepare_tx
,
1416 .set_key
= iwl_mvm_mac_set_key
,
1417 .update_tkip_key
= iwl_mvm_mac_update_tkip_key
,
1418 .remain_on_channel
= iwl_mvm_roc
,
1419 .cancel_remain_on_channel
= iwl_mvm_cancel_roc
,
1420 .rssi_callback
= iwl_mvm_mac_rssi_callback
,
1422 .add_chanctx
= iwl_mvm_add_chanctx
,
1423 .remove_chanctx
= iwl_mvm_remove_chanctx
,
1424 .change_chanctx
= iwl_mvm_change_chanctx
,
1425 .assign_vif_chanctx
= iwl_mvm_assign_vif_chanctx
,
1426 .unassign_vif_chanctx
= iwl_mvm_unassign_vif_chanctx
,
1428 .start_ap
= iwl_mvm_start_ap
,
1429 .stop_ap
= iwl_mvm_stop_ap
,
1431 .set_tim
= iwl_mvm_set_tim
,
1433 #ifdef CONFIG_PM_SLEEP
1435 .suspend
= iwl_mvm_suspend
,
1436 .resume
= iwl_mvm_resume
,
1437 .set_wakeup
= iwl_mvm_set_wakeup
,
1438 .set_rekey_data
= iwl_mvm_set_rekey_data
,
1439 #if IS_ENABLED(CONFIG_IPV6)
1440 .ipv6_addr_change
= iwl_mvm_ipv6_addr_change
,
1442 .set_default_unicast_key
= iwl_mvm_set_default_unicast_key
,