blob: 4d62a5d4254d00c6c4525a23ad89f11bc99910e0 [file] [log] [blame]
Johannes Berg8ca151b2013-01-24 14:25:36 +01001/******************************************************************************
2 *
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.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
9 *
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.
13 *
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.
18 *
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,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * Intel Linux Wireless <ilw@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2012 - 2013 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
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
45 * distribution.
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.
49 *
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.
61 *
62 *****************************************************************************/
63
64#include <linux/jiffies.h>
65#include <net/mac80211.h>
66
67#include "iwl-notif-wait.h"
68#include "iwl-trans.h"
69#include "fw-api.h"
70#include "time-event.h"
71#include "mvm.h"
72#include "iwl-io.h"
73#include "iwl-prph.h"
74
75/* A TimeUnit is 1024 microsecond */
76#define TU_TO_JIFFIES(_tu) (usecs_to_jiffies((_tu) * 1024))
77#define MSEC_TO_TU(_msec) (_msec*1000/1024)
78
Ilan Peer456f6dd2013-02-04 14:09:37 +020079/* For ROC use a TE type which has priority high enough to be scheduled when
80 * there is a concurrent BSS or GO/AP. Currently, use a TE type that has
81 * priority similar to the TE priority used for action scans by the FW.
82 * TODO: This needs to be changed, based on the reason for the ROC, i.e., use
83 * TE_P2P_DEVICE_DISCOVERABLE for remain on channel without mgmt skb, and use
84 * TE_P2P_DEVICE_ACTION_SCAN
85 */
86#define IWL_MVM_ROC_TE_TYPE TE_P2P_DEVICE_ACTION_SCAN
87
Johannes Berg8ca151b2013-01-24 14:25:36 +010088void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
89 struct iwl_mvm_time_event_data *te_data)
90{
91 lockdep_assert_held(&mvm->time_event_lock);
92
93 if (te_data->id == TE_MAX)
94 return;
95
96 list_del(&te_data->list);
97 te_data->running = false;
98 te_data->uid = 0;
99 te_data->id = TE_MAX;
100 te_data->vif = NULL;
101}
102
103void iwl_mvm_roc_done_wk(struct work_struct *wk)
104{
105 struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, roc_done_wk);
106
107 synchronize_net();
108
109 /*
110 * Flush the offchannel queue -- this is called when the time
111 * event finishes or is cancelled, so that frames queued for it
112 * won't get stuck on the queue and be transmitted in the next
113 * time event.
114 * We have to send the command asynchronously since this cannot
115 * be under the mutex for locking reasons, but that's not an
116 * issue as it will have to complete before the next command is
117 * executed, and a new time event means a new command.
118 */
119 iwl_mvm_flush_tx_path(mvm, BIT(IWL_OFFCHANNEL_QUEUE), false);
120}
121
122static void iwl_mvm_roc_finished(struct iwl_mvm *mvm)
123{
124 /*
125 * First, clear the ROC_RUNNING status bit. This will cause the TX
126 * path to drop offchannel transmissions. That would also be done
127 * by mac80211, but it is racy, in particular in the case that the
128 * time event actually completed in the firmware (which is handled
129 * in iwl_mvm_te_handle_notif).
130 */
131 clear_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
132
133 /*
134 * Of course, our status bit is just as racy as mac80211, so in
135 * addition, fire off the work struct which will drop all frames
136 * from the hardware queues that made it through the race. First
137 * it will of course synchronize the TX path to make sure that
138 * any *new* TX will be rejected.
139 */
140 schedule_work(&mvm->roc_done_wk);
141}
142
143/*
144 * Handles a FW notification for an event that is known to the driver.
145 *
146 * @mvm: the mvm component
147 * @te_data: the time event data
148 * @notif: the notification data corresponding the time event data.
149 */
150static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
151 struct iwl_mvm_time_event_data *te_data,
152 struct iwl_time_event_notif *notif)
153{
154 lockdep_assert_held(&mvm->time_event_lock);
155
156 IWL_DEBUG_TE(mvm, "Handle time event notif - UID = 0x%x action %d\n",
157 le32_to_cpu(notif->unique_id),
158 le32_to_cpu(notif->action));
159
160 /*
161 * The FW sends the start/end time event notifications even for events
162 * that it fails to schedule. This is indicated in the status field of
163 * the notification. This happens in cases that the scheduler cannot
164 * find a schedule that can handle the event (for example requesting a
165 * P2P Device discoveribility, while there are other higher priority
166 * events in the system).
167 */
168 WARN_ONCE(!le32_to_cpu(notif->status),
169 "Failed to schedule time event\n");
170
171 if (le32_to_cpu(notif->action) == TE_NOTIF_HOST_END) {
172 IWL_DEBUG_TE(mvm,
173 "TE ended - current time %lu, estimated end %lu\n",
174 jiffies, te_data->end_jiffies);
175
176 if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
177 ieee80211_remain_on_channel_expired(mvm->hw);
178 iwl_mvm_roc_finished(mvm);
179 }
180
181 /*
182 * By now, we should have finished association
183 * and know the dtim period.
184 */
185 if (te_data->vif->type == NL80211_IFTYPE_STATION &&
186 (!te_data->vif->bss_conf.assoc ||
187 !te_data->vif->bss_conf.dtim_period))
188 IWL_ERR(mvm,
189 "No assocation and the time event is over already...\n");
190
191 iwl_mvm_te_clear_data(mvm, te_data);
192 } else if (le32_to_cpu(notif->action) == TE_NOTIF_HOST_START) {
193 te_data->running = true;
194 te_data->end_jiffies = jiffies +
195 TU_TO_JIFFIES(te_data->duration);
196
197 if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
198 set_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
199 ieee80211_ready_on_channel(mvm->hw);
200 }
201 } else {
202 IWL_WARN(mvm, "Got TE with unknown action\n");
203 }
204}
205
206/*
207 * The Rx handler for time event notifications
208 */
209int iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm,
210 struct iwl_rx_cmd_buffer *rxb,
211 struct iwl_device_cmd *cmd)
212{
213 struct iwl_rx_packet *pkt = rxb_addr(rxb);
214 struct iwl_time_event_notif *notif = (void *)pkt->data;
215 struct iwl_mvm_time_event_data *te_data, *tmp;
216
217 IWL_DEBUG_TE(mvm, "Time event notification - UID = 0x%x action %d\n",
218 le32_to_cpu(notif->unique_id),
219 le32_to_cpu(notif->action));
220
221 spin_lock_bh(&mvm->time_event_lock);
222 list_for_each_entry_safe(te_data, tmp, &mvm->time_event_list, list) {
223 if (le32_to_cpu(notif->unique_id) == te_data->uid)
224 iwl_mvm_te_handle_notif(mvm, te_data, notif);
225 }
226 spin_unlock_bh(&mvm->time_event_lock);
227
228 return 0;
229}
230
231static bool iwl_mvm_time_event_notif(struct iwl_notif_wait_data *notif_wait,
232 struct iwl_rx_packet *pkt, void *data)
233{
234 struct iwl_mvm *mvm =
235 container_of(notif_wait, struct iwl_mvm, notif_wait);
236 struct iwl_mvm_time_event_data *te_data = data;
237 struct ieee80211_vif *vif = te_data->vif;
238 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
239 struct iwl_time_event_notif *notif;
240 struct iwl_time_event_resp *resp;
241
242 u32 mac_id_n_color = FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color);
243
244 /* until we do something else */
245 WARN_ON(te_data->id != TE_BSS_STA_AGGRESSIVE_ASSOC);
246
247 switch (pkt->hdr.cmd) {
248 case TIME_EVENT_CMD:
249 resp = (void *)pkt->data;
250 /* TODO: I can't check that since the fw is buggy - it doesn't
251 * put the right values when we remove a TE. We can be here
252 * when we remove a TE because the remove TE command is sent in
253 * ASYNC...
254 * WARN_ON(mac_id_n_color != le32_to_cpu(resp->id_and_color));
255 */
256 te_data->uid = le32_to_cpu(resp->unique_id);
257 IWL_DEBUG_TE(mvm, "Got response - UID = 0x%x\n", te_data->uid);
258 return false;
259
260 case TIME_EVENT_NOTIFICATION:
261 notif = (void *)pkt->data;
262 WARN_ON(le32_to_cpu(notif->status) != 1);
263 WARN_ON(mac_id_n_color != le32_to_cpu(notif->id_and_color));
264 /* check if this is our Time Event that is starting */
265 if (le32_to_cpu(notif->unique_id) != te_data->uid)
266 return false;
267 IWL_DEBUG_TE(mvm, "Event %d is starting - time is %d\n",
268 te_data->uid, le32_to_cpu(notif->timestamp));
269
270 WARN_ONCE(!le32_to_cpu(notif->status),
271 "Failed to schedule protected session TE\n");
272
273 te_data->running = true;
274 te_data->end_jiffies = jiffies +
275 TU_TO_JIFFIES(te_data->duration);
276 return true;
277
278 default:
279 WARN_ON(1);
280 return false;
281 };
282}
283
284void iwl_mvm_protect_session(struct iwl_mvm *mvm,
285 struct ieee80211_vif *vif,
286 u32 duration, u32 min_duration)
287{
288 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
289 struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
290 static const u8 time_event_notif[] = { TIME_EVENT_CMD,
291 TIME_EVENT_NOTIFICATION };
292 struct iwl_notification_wait wait_time_event;
293 struct iwl_time_event_cmd time_cmd = {};
294 int ret;
295
296 lockdep_assert_held(&mvm->mutex);
297
298 if (te_data->running &&
299 time_after(te_data->end_jiffies,
300 jiffies + TU_TO_JIFFIES(min_duration))) {
301 IWL_DEBUG_TE(mvm, "We have enough time in the current TE: %u\n",
302 jiffies_to_msecs(te_data->end_jiffies - jiffies));
303 return;
304 }
305
306 if (te_data->running) {
307 IWL_DEBUG_TE(mvm, "extend 0x%x: only %u ms left\n",
308 te_data->uid,
309 jiffies_to_msecs(te_data->end_jiffies - jiffies));
310 /*
311 * we don't have enough time
312 * cancel the current TE and issue a new one
313 * Of course it would be better to remove the old one only
314 * when the new one is added, but we don't care if we are off
315 * channel for a bit. All we need to do, is not to return
316 * before we actually begin to be on the channel.
317 */
318 iwl_mvm_stop_session_protection(mvm, vif);
319 }
320
321 iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
322 time_event_notif,
323 ARRAY_SIZE(time_event_notif),
324 iwl_mvm_time_event_notif,
325 &mvmvif->time_event_data);
326
327 time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
328 time_cmd.id_and_color =
329 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
330 time_cmd.id = cpu_to_le32(TE_BSS_STA_AGGRESSIVE_ASSOC);
331
332 time_cmd.apply_time =
333 cpu_to_le32(iwl_read_prph(mvm->trans, DEVICE_SYSTEM_TIME_REG));
334 time_cmd.dep_policy = TE_INDEPENDENT;
335 time_cmd.is_present = cpu_to_le32(1);
336 time_cmd.max_frags = cpu_to_le32(TE_FRAG_NONE);
337 time_cmd.max_delay = cpu_to_le32(500);
338 /* TODO: why do we need to interval = bi if it is not periodic? */
339 time_cmd.interval = cpu_to_le32(1);
340 time_cmd.interval_reciprocal = cpu_to_le32(iwl_mvm_reciprocal(1));
341 time_cmd.duration = cpu_to_le32(duration);
342 time_cmd.repeat = cpu_to_le32(1);
343 time_cmd.notify = cpu_to_le32(TE_NOTIF_HOST_START | TE_NOTIF_HOST_END);
344
345 te_data->vif = vif;
346 te_data->duration = duration;
347
348 spin_lock_bh(&mvm->time_event_lock);
349 te_data->id = le32_to_cpu(time_cmd.id);
350 list_add_tail(&te_data->list, &mvm->time_event_list);
351 spin_unlock_bh(&mvm->time_event_lock);
352
353 ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_SYNC,
354 sizeof(time_cmd), &time_cmd);
355 if (ret) {
356 IWL_ERR(mvm, "Couldn't send TIME_EVENT_CMD: %d\n", ret);
357 goto out_remove_notif;
358 }
359
360 ret = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1 * HZ);
361 if (ret) {
362 IWL_ERR(mvm, "%s - failed on timeout\n", __func__);
363 spin_lock_bh(&mvm->time_event_lock);
364 iwl_mvm_te_clear_data(mvm, te_data);
365 spin_unlock_bh(&mvm->time_event_lock);
366 }
367
368 return;
369
370out_remove_notif:
371 iwl_remove_notification(&mvm->notif_wait, &wait_time_event);
372}
373
374/*
375 * Explicit request to remove a time event. The removal of a time event needs to
376 * be synchronized with the flow of a time event's end notification, which also
377 * removes the time event from the op mode data structures.
378 */
379void iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
380 struct iwl_mvm_vif *mvmvif,
381 struct iwl_mvm_time_event_data *te_data)
382{
383 struct iwl_time_event_cmd time_cmd = {};
384 u32 id, uid;
385 int ret;
386
387 /*
388 * It is possible that by the time we got to this point the time
389 * event was already removed.
390 */
391 spin_lock_bh(&mvm->time_event_lock);
392
393 /* Save time event uid before clearing its data */
394 uid = te_data->uid;
395 id = te_data->id;
396
397 /*
398 * The clear_data function handles time events that were already removed
399 */
400 iwl_mvm_te_clear_data(mvm, te_data);
401 spin_unlock_bh(&mvm->time_event_lock);
402
403 /*
404 * It is possible that by the time we try to remove it, the time event
405 * has already ended and removed. In such a case there is no need to
406 * send a removal command.
407 */
408 if (id == TE_MAX) {
409 IWL_DEBUG_TE(mvm, "TE 0x%x has already ended\n", uid);
410 return;
411 }
412
413 /* When we remove a TE, the UID is to be set in the id field */
414 time_cmd.id = cpu_to_le32(uid);
415 time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_REMOVE);
416 time_cmd.id_and_color =
417 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
418
419 IWL_DEBUG_TE(mvm, "Removing TE 0x%x\n", le32_to_cpu(time_cmd.id));
420 ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_ASYNC,
421 sizeof(time_cmd), &time_cmd);
422 if (WARN_ON(ret))
423 return;
424}
425
426void iwl_mvm_stop_session_protection(struct iwl_mvm *mvm,
427 struct ieee80211_vif *vif)
428{
429 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
430 struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
431
432 lockdep_assert_held(&mvm->mutex);
433 iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
434}
435
436static bool iwl_mvm_roc_te_notif(struct iwl_notif_wait_data *notif_wait,
437 struct iwl_rx_packet *pkt, void *data)
438{
439 struct iwl_mvm *mvm =
440 container_of(notif_wait, struct iwl_mvm, notif_wait);
441 struct iwl_mvm_time_event_data *te_data = data;
442 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
443 struct iwl_time_event_resp *resp;
444
445 u32 mac_id_n_color = FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color);
446
447 /* until we do something else */
Ilan Peer456f6dd2013-02-04 14:09:37 +0200448 WARN_ON(te_data->id != IWL_MVM_ROC_TE_TYPE);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100449
450 switch (pkt->hdr.cmd) {
451 case TIME_EVENT_CMD:
452 resp = (void *)pkt->data;
453 WARN_ON(mac_id_n_color != le32_to_cpu(resp->id_and_color));
454 te_data->uid = le32_to_cpu(resp->unique_id);
455 IWL_DEBUG_TE(mvm, "Got response - UID = 0x%x\n", te_data->uid);
456 return true;
457
458 default:
459 WARN_ON(1);
460 return false;
461 };
462}
463
464int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
465 int duration)
466{
467 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
468 struct iwl_mvm_time_event_data *te_data = &mvmvif->time_event_data;
469 static const u8 roc_te_notif[] = { TIME_EVENT_CMD };
470 struct iwl_notification_wait wait_time_event;
471 struct iwl_time_event_cmd time_cmd = {};
472 int ret;
473
474 lockdep_assert_held(&mvm->mutex);
475 if (te_data->running) {
476 IWL_WARN(mvm, "P2P_DEVICE remain on channel already running\n");
477 return -EBUSY;
478 }
479
480 /*
481 * Flush the done work, just in case it's still pending, so that
482 * the work it does can complete and we can accept new frames.
483 */
484 flush_work(&mvm->roc_done_wk);
485
486 iwl_init_notification_wait(&mvm->notif_wait, &wait_time_event,
487 roc_te_notif,
488 ARRAY_SIZE(roc_te_notif),
489 iwl_mvm_roc_te_notif,
490 &mvmvif->time_event_data);
491
492 time_cmd.action = cpu_to_le32(FW_CTXT_ACTION_ADD);
493 time_cmd.id_and_color =
494 cpu_to_le32(FW_CMD_ID_AND_COLOR(mvmvif->id, mvmvif->color));
Ilan Peer456f6dd2013-02-04 14:09:37 +0200495 time_cmd.id = cpu_to_le32(IWL_MVM_ROC_TE_TYPE);
Johannes Berg8ca151b2013-01-24 14:25:36 +0100496
497 time_cmd.apply_time = cpu_to_le32(0);
498 time_cmd.dep_policy = cpu_to_le32(TE_INDEPENDENT);
499 time_cmd.is_present = cpu_to_le32(1);
500
501 time_cmd.interval = cpu_to_le32(1);
502
503 /*
Ilan Peer456f6dd2013-02-04 14:09:37 +0200504 * IWL_MVM_ROC_TE_TYPE can have lower priority than other events
Johannes Berg8ca151b2013-01-24 14:25:36 +0100505 * that are being scheduled by the driver/fw, and thus it might not be
506 * scheduled. To improve the chances of it being scheduled, allow it to
507 * be fragmented.
508 * In addition, for the same reasons, allow to delay the scheduling of
509 * the time event.
510 */
511 time_cmd.max_frags = cpu_to_le32(MSEC_TO_TU(duration)/20);
512 time_cmd.max_delay = cpu_to_le32(MSEC_TO_TU(duration/2));
513 time_cmd.duration = cpu_to_le32(MSEC_TO_TU(duration));
514 time_cmd.repeat = cpu_to_le32(1);
515 time_cmd.notify = cpu_to_le32(TE_NOTIF_HOST_START | TE_NOTIF_HOST_END);
516
517 /* Push the te data to the tracked te list */
518 te_data->vif = vif;
519 te_data->duration = MSEC_TO_TU(duration);
520
521 spin_lock_bh(&mvm->time_event_lock);
522 te_data->id = le32_to_cpu(time_cmd.id);
523 list_add_tail(&te_data->list, &mvm->time_event_list);
524 spin_unlock_bh(&mvm->time_event_lock);
525
526 ret = iwl_mvm_send_cmd_pdu(mvm, TIME_EVENT_CMD, CMD_SYNC,
527 sizeof(time_cmd), &time_cmd);
528 if (ret) {
529 IWL_ERR(mvm, "Couldn't send TIME_EVENT_CMD: %d\n", ret);
530 goto out_remove_notif;
531 }
532
533 ret = iwl_wait_notification(&mvm->notif_wait, &wait_time_event, 1 * HZ);
534 if (ret) {
535 IWL_ERR(mvm, "%s - failed on timeout\n", __func__);
536 iwl_mvm_te_clear_data(mvm, te_data);
537 }
538
539 return ret;
540
541out_remove_notif:
542 iwl_remove_notification(&mvm->notif_wait, &wait_time_event);
543 return ret;
544}
545
546void iwl_mvm_stop_p2p_roc(struct iwl_mvm *mvm)
547{
548 struct iwl_mvm_vif *mvmvif;
549 struct iwl_mvm_time_event_data *te_data;
550
551 lockdep_assert_held(&mvm->mutex);
552
553 /*
554 * Iterate over the list of time events and find the time event that is
555 * associated with a P2P_DEVICE interface.
556 * This assumes that a P2P_DEVICE interface can have only a single time
557 * event at any given time and this time event coresponds to a ROC
558 * request
559 */
560 mvmvif = NULL;
561 spin_lock_bh(&mvm->time_event_lock);
562 list_for_each_entry(te_data, &mvm->time_event_list, list) {
563 if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
564 mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
565 break;
566 }
567 }
568 spin_unlock_bh(&mvm->time_event_lock);
569
570 if (!mvmvif) {
571 IWL_WARN(mvm, "P2P_DEVICE no remain on channel event\n");
572 return;
573 }
574
575 iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
576
577 iwl_mvm_roc_finished(mvm);
578}