mac80211.c (55eb1c5fa4b260491d8be3299d4546d0b34465f4) mac80211.c (1ab26632332eac61cc24464a74fd9bcf5ec5167b)
1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2/*
3 * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
6 */
7#include <linux/kernel.h>
8#include <linux/slab.h>

--- 1202 unchanged lines hidden (view full) ---

1211
1212 /*
1213 * The worker might have been waiting for the mutex, let it run and
1214 * discover that its list is now empty.
1215 */
1216 cancel_work_sync(&mvm->async_handlers_wk);
1217}
1218
1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2/*
3 * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
4 * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
5 * Copyright (C) 2016-2017 Intel Deutschland GmbH
6 */
7#include <linux/kernel.h>
8#include <linux/slab.h>

--- 1202 unchanged lines hidden (view full) ---

1211
1212 /*
1213 * The worker might have been waiting for the mutex, let it run and
1214 * discover that its list is now empty.
1215 */
1216 cancel_work_sync(&mvm->async_handlers_wk);
1217}
1218
1219static struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
1219struct iwl_mvm_phy_ctxt *iwl_mvm_get_free_phy_ctxt(struct iwl_mvm *mvm)
1220{
1221 u16 i;
1222
1223 lockdep_assert_held(&mvm->mutex);
1224
1225 for (i = 0; i < NUM_PHY_CTX; i++)
1226 if (!mvm->phy_ctxts[i].ref)
1227 return &mvm->phy_ctxts[i];

--- 117 unchanged lines hidden (view full) ---

1345 CHANNEL_SWITCH_TIME_EVENT_CMD),
1346 0, sizeof(cmd), &cmd));
1347 mvmvif->csa_failed = true;
1348 mutex_unlock(&mvm->mutex);
1349
1350 iwl_mvm_post_channel_switch(hw, vif);
1351}
1352
1220{
1221 u16 i;
1222
1223 lockdep_assert_held(&mvm->mutex);
1224
1225 for (i = 0; i < NUM_PHY_CTX; i++)
1226 if (!mvm->phy_ctxts[i].ref)
1227 return &mvm->phy_ctxts[i];

--- 117 unchanged lines hidden (view full) ---

1345 CHANNEL_SWITCH_TIME_EVENT_CMD),
1346 0, sizeof(cmd), &cmd));
1347 mvmvif->csa_failed = true;
1348 mutex_unlock(&mvm->mutex);
1349
1350 iwl_mvm_post_channel_switch(hw, vif);
1351}
1352
1353static void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk)
1353void iwl_mvm_channel_switch_disconnect_wk(struct work_struct *wk)
1354{
1355 struct iwl_mvm_vif *mvmvif;
1356 struct ieee80211_vif *vif;
1357
1358 mvmvif = container_of(wk, struct iwl_mvm_vif, csa_work.work);
1359 vif = container_of((void *)mvmvif, struct ieee80211_vif, drv_priv);
1360
1361 /* Trigger disconnect (should clear the CSA state) */

--- 17 unchanged lines hidden (view full) ---

1379 /* data is bw wide so the start is half the width */
1380 data_start = chandef->center_freq1 - bw / 2;
1381 /* control is 20Mhz width */
1382 control_start = chandef->chan->center_freq - 10;
1383
1384 return (control_start - data_start) / 80;
1385}
1386
1354{
1355 struct iwl_mvm_vif *mvmvif;
1356 struct ieee80211_vif *vif;
1357
1358 mvmvif = container_of(wk, struct iwl_mvm_vif, csa_work.work);
1359 vif = container_of((void *)mvmvif, struct ieee80211_vif, drv_priv);
1360
1361 /* Trigger disconnect (should clear the CSA state) */

--- 17 unchanged lines hidden (view full) ---

1379 /* data is bw wide so the start is half the width */
1380 data_start = chandef->center_freq1 - bw / 2;
1381 /* control is 20Mhz width */
1382 control_start = chandef->chan->center_freq - 10;
1383
1384 return (control_start - data_start) / 80;
1385}
1386
1387static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1388 struct ieee80211_vif *vif)
1387/*
1388 * Returns true if addding the interface is done
1389 * (either with success or failure)
1390 */
1391bool iwl_mvm_mac_add_interface_common(struct iwl_mvm *mvm,
1392 struct ieee80211_hw *hw,
1393 struct ieee80211_vif *vif, int *ret)
1389{
1394{
1390 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1391 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1395 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1392 int ret;
1393
1396
1397 lockdep_assert_held(&mvm->mutex);
1398
1394 mvmvif->mvm = mvm;
1395 RCU_INIT_POINTER(mvmvif->probe_resp_data, NULL);
1396
1397 /*
1398 * Not much to do here. The stack will not allow interface
1399 * types or combinations that we didn't advertise, so we
1400 * don't really have to check the types.
1401 */
1402
1399 mvmvif->mvm = mvm;
1400 RCU_INIT_POINTER(mvmvif->probe_resp_data, NULL);
1401
1402 /*
1403 * Not much to do here. The stack will not allow interface
1404 * types or combinations that we didn't advertise, so we
1405 * don't really have to check the types.
1406 */
1407
1403 mutex_lock(&mvm->mutex);
1404
1405 /* make sure that beacon statistics don't go backwards with FW reset */
1406 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1407 mvmvif->beacon_stats.accu_num_beacons +=
1408 mvmvif->beacon_stats.num_beacons;
1409
1410 /* Allocate resources for the MAC context, and add it to the fw */
1408 /* make sure that beacon statistics don't go backwards with FW reset */
1409 if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1410 mvmvif->beacon_stats.accu_num_beacons +=
1411 mvmvif->beacon_stats.num_beacons;
1412
1413 /* Allocate resources for the MAC context, and add it to the fw */
1411 ret = iwl_mvm_mac_ctxt_init(mvm, vif);
1412 if (ret)
1413 goto out_unlock;
1414 *ret = iwl_mvm_mac_ctxt_init(mvm, vif);
1415 if (*ret)
1416 return true;
1414
1415 rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif);
1416
1417 /*
1418 * The AP binding flow can be done only after the beacon
1419 * template is configured (which happens only in the mac80211
1420 * start_ap() flow), and adding the broadcast station can happen
1421 * only after the binding.
1422 * In addition, since modifying the MAC before adding a bcast
1423 * station is not allowed by the FW, delay the adding of MAC context to
1424 * the point where we can also add the bcast station.
1425 * In short: there's not much we can do at this point, other than
1426 * allocating resources :)
1427 */
1428 if (vif->type == NL80211_IFTYPE_AP ||
1429 vif->type == NL80211_IFTYPE_ADHOC) {
1417
1418 rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif);
1419
1420 /*
1421 * The AP binding flow can be done only after the beacon
1422 * template is configured (which happens only in the mac80211
1423 * start_ap() flow), and adding the broadcast station can happen
1424 * only after the binding.
1425 * In addition, since modifying the MAC before adding a bcast
1426 * station is not allowed by the FW, delay the adding of MAC context to
1427 * the point where we can also add the bcast station.
1428 * In short: there's not much we can do at this point, other than
1429 * allocating resources :)
1430 */
1431 if (vif->type == NL80211_IFTYPE_AP ||
1432 vif->type == NL80211_IFTYPE_ADHOC) {
1430 ret = iwl_mvm_alloc_bcast_sta(mvm, vif);
1431 if (ret) {
1432 IWL_ERR(mvm, "Failed to allocate bcast sta\n");
1433 goto out_unlock;
1434 }
1435
1436 /*
1437 * Only queue for this station is the mcast queue,
1438 * which shouldn't be in TFD mask anyway
1439 */
1440 ret = iwl_mvm_allocate_int_sta(mvm, &mvmvif->mcast_sta,
1441 0, vif->type,
1442 IWL_STA_MULTICAST);
1443 if (ret)
1444 goto out_unlock;
1445
1446 iwl_mvm_vif_dbgfs_register(mvm, vif);
1433 iwl_mvm_vif_dbgfs_register(mvm, vif);
1447 goto out_unlock;
1434 return true;
1448 }
1449
1450 mvmvif->features |= hw->netdev_features;
1435 }
1436
1437 mvmvif->features |= hw->netdev_features;
1438 return false;
1439}
1451
1440
1441static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm *mvm,
1442 struct ieee80211_vif *vif)
1443{
1444 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1445 int ret;
1446
1447 lockdep_assert_held(&mvm->mutex);
1448
1449 ret = iwl_mvm_alloc_bcast_sta(mvm, vif);
1450 if (ret) {
1451 IWL_ERR(mvm, "Failed to allocate bcast sta\n");
1452 return ret;
1453 }
1454
1455 /*
1456 * Only queue for this station is the mcast queue,
1457 * which shouldn't be in TFD mask anyway
1458 */
1459 return iwl_mvm_allocate_int_sta(mvm, &mvmvif->mcast_sta, 0, vif->type,
1460 IWL_STA_MULTICAST);
1461}
1462
1463static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
1464 struct ieee80211_vif *vif)
1465{
1466 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
1467 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1468 int ret;
1469
1470 mutex_lock(&mvm->mutex);
1471
1472 /* Common for MLD and non-MLD API */
1473 if (iwl_mvm_mac_add_interface_common(mvm, hw, vif, &ret))
1474 goto out;
1475
1452 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
1453 if (ret)
1454 goto out_unlock;
1455
1456 ret = iwl_mvm_power_update_mac(mvm);
1457 if (ret)
1458 goto out_remove_mac;
1459

--- 51 unchanged lines hidden (view full) ---

1511 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
1512 vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
1513 !mvm->csme_vif && mvm->mei_registered) {
1514 iwl_mei_set_nic_info(vif->addr, mvm->nvm_data->hw_addr);
1515 iwl_mei_set_netdev(ieee80211_vif_to_wdev(vif)->netdev);
1516 mvm->csme_vif = vif;
1517 }
1518
1476 ret = iwl_mvm_mac_ctxt_add(mvm, vif);
1477 if (ret)
1478 goto out_unlock;
1479
1480 ret = iwl_mvm_power_update_mac(mvm);
1481 if (ret)
1482 goto out_remove_mac;
1483

--- 51 unchanged lines hidden (view full) ---

1535 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) &&
1536 vif->type == NL80211_IFTYPE_STATION && !vif->p2p &&
1537 !mvm->csme_vif && mvm->mei_registered) {
1538 iwl_mei_set_nic_info(vif->addr, mvm->nvm_data->hw_addr);
1539 iwl_mei_set_netdev(ieee80211_vif_to_wdev(vif)->netdev);
1540 mvm->csme_vif = vif;
1541 }
1542
1543out:
1544 if (!ret && (vif->type == NL80211_IFTYPE_AP ||
1545 vif->type == NL80211_IFTYPE_ADHOC))
1546 ret = iwl_mvm_alloc_bcast_mcast_sta(mvm, vif);
1547
1519 goto out_unlock;
1520
1521 out_unbind:
1522 iwl_mvm_binding_remove_vif(mvm, vif);
1523 out_unref_phy:
1524 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1525 out_free_bf:
1526 if (mvm->bf_allowed_vif == mvmvif) {

--- 4162 unchanged lines hidden ---
1548 goto out_unlock;
1549
1550 out_unbind:
1551 iwl_mvm_binding_remove_vif(mvm, vif);
1552 out_unref_phy:
1553 iwl_mvm_phy_ctxt_unref(mvm, mvmvif->phy_ctxt);
1554 out_free_bf:
1555 if (mvm->bf_allowed_vif == mvmvif) {

--- 4162 unchanged lines hidden ---