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) 2014 Intel Mobile Communications GmbH
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) 2014 Intel Mobile Communications GmbH
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 *****************************************************************************/
65 #include "time-event.h"
67 void iwl_mvm_teardown_tdls_peers(struct iwl_mvm *mvm)
69 struct ieee80211_sta *sta;
70 struct iwl_mvm_sta *mvmsta;
73 lockdep_assert_held(&mvm->mutex);
75 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
76 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
77 lockdep_is_held(&mvm->mutex));
78 if (!sta || IS_ERR(sta) || !sta->tdls)
81 mvmsta = iwl_mvm_sta_from_mac80211(sta);
82 ieee80211_tdls_oper_request(mvmsta->vif, sta->addr,
83 NL80211_TDLS_TEARDOWN,
84 WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED,
89 int iwl_mvm_tdls_sta_count(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
91 struct ieee80211_sta *sta;
92 struct iwl_mvm_sta *mvmsta;
96 lockdep_assert_held(&mvm->mutex);
98 for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
99 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
100 lockdep_is_held(&mvm->mutex));
101 if (!sta || IS_ERR(sta) || !sta->tdls)
105 mvmsta = iwl_mvm_sta_from_mac80211(sta);
106 if (mvmsta->vif != vif)
116 void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
119 int tdls_sta_cnt = iwl_mvm_tdls_sta_count(mvm, vif);
122 * Disable ps when the first TDLS sta is added and re-enable it
123 * when the last TDLS sta is removed
125 if ((tdls_sta_cnt == 1 && sta_added) ||
126 (tdls_sta_cnt == 0 && !sta_added))
127 iwl_mvm_power_update_mac(mvm);
130 void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
131 struct ieee80211_vif *vif)
133 struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
134 u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int;
137 * iwl_mvm_protect_session() reads directly from the device
138 * (the system time), so make sure it is available.
140 if (iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PROTECT_TDLS))
143 mutex_lock(&mvm->mutex);
144 /* Protect the session to hear the TDLS setup response on the channel */
145 iwl_mvm_protect_session(mvm, vif, duration, duration, 100, true);
146 mutex_unlock(&mvm->mutex);
148 iwl_mvm_unref(mvm, IWL_MVM_REF_PROTECT_TDLS);