18c2ecf20Sopenharmony_ci/****************************************************************************** 28c2ecf20Sopenharmony_ci * 38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * GPL LICENSE SUMMARY 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 98c2ecf20Sopenharmony_ci * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 108c2ecf20Sopenharmony_ci * Copyright (C) 2019 - 2020 Intel Corporation 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 138c2ecf20Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 148c2ecf20Sopenharmony_ci * published by the Free Software Foundation. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 178c2ecf20Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 188c2ecf20Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 198c2ecf20Sopenharmony_ci * General Public License for more details. 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * The full GNU General Public License is included in this distribution 228c2ecf20Sopenharmony_ci * in the file called COPYING. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * Contact Information: 258c2ecf20Sopenharmony_ci * Intel Linux Wireless <linuxwifi@intel.com> 268c2ecf20Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * BSD LICENSE 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 318c2ecf20Sopenharmony_ci * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH 328c2ecf20Sopenharmony_ci * Copyright (C) 2019 - 2020 Intel Corporation 338c2ecf20Sopenharmony_ci * All rights reserved. 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 368c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 378c2ecf20Sopenharmony_ci * are met: 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * * Redistributions of source code must retain the above copyright 408c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 418c2ecf20Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 428c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 438c2ecf20Sopenharmony_ci * the documentation and/or other materials provided with the 448c2ecf20Sopenharmony_ci * distribution. 458c2ecf20Sopenharmony_ci * * Neither the name Intel Corporation nor the names of its 468c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived 478c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 488c2ecf20Sopenharmony_ci * 498c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 508c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 518c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 528c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 538c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 548c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 558c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 568c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 578c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 588c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 598c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 608c2ecf20Sopenharmony_ci * 618c2ecf20Sopenharmony_ci *****************************************************************************/ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#ifndef __time_event_h__ 648c2ecf20Sopenharmony_ci#define __time_event_h__ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#include "fw-api.h" 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#include "mvm.h" 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/** 718c2ecf20Sopenharmony_ci * DOC: Time Events - what is it? 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * Time Events are a fw feature that allows the driver to control the presence 748c2ecf20Sopenharmony_ci * of the device on the channel. Since the fw supports multiple channels 758c2ecf20Sopenharmony_ci * concurrently, the fw may choose to jump to another channel at any time. 768c2ecf20Sopenharmony_ci * In order to make sure that the fw is on a specific channel at a certain time 778c2ecf20Sopenharmony_ci * and for a certain duration, the driver needs to issue a time event. 788c2ecf20Sopenharmony_ci * 798c2ecf20Sopenharmony_ci * The simplest example is for BSS association. The driver issues a time event, 808c2ecf20Sopenharmony_ci * waits for it to start, and only then tells mac80211 that we can start the 818c2ecf20Sopenharmony_ci * association. This way, we make sure that the association will be done 828c2ecf20Sopenharmony_ci * smoothly and won't be interrupted by channel switch decided within the fw. 838c2ecf20Sopenharmony_ci */ 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci /** 868c2ecf20Sopenharmony_ci * DOC: The flow against the fw 878c2ecf20Sopenharmony_ci * 888c2ecf20Sopenharmony_ci * When the driver needs to make sure we are in a certain channel, at a certain 898c2ecf20Sopenharmony_ci * time and for a certain duration, it sends a Time Event. The flow against the 908c2ecf20Sopenharmony_ci * fw goes like this: 918c2ecf20Sopenharmony_ci * 1) Driver sends a TIME_EVENT_CMD to the fw 928c2ecf20Sopenharmony_ci * 2) Driver gets the response for that command. This response contains the 938c2ecf20Sopenharmony_ci * Unique ID (UID) of the event. 948c2ecf20Sopenharmony_ci * 3) The fw sends notification when the event starts. 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * Of course the API provides various options that allow to cover parameters 978c2ecf20Sopenharmony_ci * of the flow. 988c2ecf20Sopenharmony_ci * What is the duration of the event? 998c2ecf20Sopenharmony_ci * What is the start time of the event? 1008c2ecf20Sopenharmony_ci * Is there an end-time for the event? 1018c2ecf20Sopenharmony_ci * How much can the event be delayed? 1028c2ecf20Sopenharmony_ci * Can the event be split? 1038c2ecf20Sopenharmony_ci * If yes what is the maximal number of chunks? 1048c2ecf20Sopenharmony_ci * etc... 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/** 1088c2ecf20Sopenharmony_ci * DOC: Abstraction to the driver 1098c2ecf20Sopenharmony_ci * 1108c2ecf20Sopenharmony_ci * In order to simplify the use of time events to the rest of the driver, 1118c2ecf20Sopenharmony_ci * we abstract the use of time events. This component provides the functions 1128c2ecf20Sopenharmony_ci * needed by the driver. 1138c2ecf20Sopenharmony_ci */ 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci#define IWL_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS 600 1168c2ecf20Sopenharmony_ci#define IWL_MVM_TE_SESSION_PROTECTION_MIN_TIME_MS 400 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci/** 1198c2ecf20Sopenharmony_ci * iwl_mvm_protect_session - start / extend the session protection. 1208c2ecf20Sopenharmony_ci * @mvm: the mvm component 1218c2ecf20Sopenharmony_ci * @vif: the virtual interface for which the session is issued 1228c2ecf20Sopenharmony_ci * @duration: the duration of the session in TU. 1238c2ecf20Sopenharmony_ci * @min_duration: will start a new session if the current session will end 1248c2ecf20Sopenharmony_ci * in less than min_duration. 1258c2ecf20Sopenharmony_ci * @max_delay: maximum delay before starting the time event (in TU) 1268c2ecf20Sopenharmony_ci * @wait_for_notif: true if it is required that a time event notification be 1278c2ecf20Sopenharmony_ci * waited for (that the time event has been scheduled before returning) 1288c2ecf20Sopenharmony_ci * 1298c2ecf20Sopenharmony_ci * This function can be used to start a session protection which means that the 1308c2ecf20Sopenharmony_ci * fw will stay on the channel for %duration_ms milliseconds. This function 1318c2ecf20Sopenharmony_ci * can block (sleep) until the session starts. This function can also be used 1328c2ecf20Sopenharmony_ci * to extend a currently running session. 1338c2ecf20Sopenharmony_ci * This function is meant to be used for BSS association for example, where we 1348c2ecf20Sopenharmony_ci * want to make sure that the fw stays on the channel during the association. 1358c2ecf20Sopenharmony_ci */ 1368c2ecf20Sopenharmony_civoid iwl_mvm_protect_session(struct iwl_mvm *mvm, 1378c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 1388c2ecf20Sopenharmony_ci u32 duration, u32 min_duration, 1398c2ecf20Sopenharmony_ci u32 max_delay, bool wait_for_notif); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/** 1428c2ecf20Sopenharmony_ci * iwl_mvm_stop_session_protection - cancel the session protection. 1438c2ecf20Sopenharmony_ci * @mvm: the mvm component 1448c2ecf20Sopenharmony_ci * @vif: the virtual interface for which the session is issued 1458c2ecf20Sopenharmony_ci * 1468c2ecf20Sopenharmony_ci * This functions cancels the session protection which is an act of good 1478c2ecf20Sopenharmony_ci * citizenship. If it is not needed any more it should be canceled because 1488c2ecf20Sopenharmony_ci * the other bindings wait for the medium during that time. 1498c2ecf20Sopenharmony_ci * This funtions doesn't sleep. 1508c2ecf20Sopenharmony_ci */ 1518c2ecf20Sopenharmony_civoid iwl_mvm_stop_session_protection(struct iwl_mvm *mvm, 1528c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci/* 1558c2ecf20Sopenharmony_ci * iwl_mvm_rx_time_event_notif - handles %TIME_EVENT_NOTIFICATION. 1568c2ecf20Sopenharmony_ci */ 1578c2ecf20Sopenharmony_civoid iwl_mvm_rx_time_event_notif(struct iwl_mvm *mvm, 1588c2ecf20Sopenharmony_ci struct iwl_rx_cmd_buffer *rxb); 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/** 1618c2ecf20Sopenharmony_ci * iwl_mvm_start_p2p_roc - start remain on channel for p2p device functionality 1628c2ecf20Sopenharmony_ci * @mvm: the mvm component 1638c2ecf20Sopenharmony_ci * @vif: the virtual interface for which the roc is requested. It is assumed 1648c2ecf20Sopenharmony_ci * that the vif type is NL80211_IFTYPE_P2P_DEVICE 1658c2ecf20Sopenharmony_ci * @duration: the requested duration in millisecond for the fw to be on the 1668c2ecf20Sopenharmony_ci * channel that is bound to the vif. 1678c2ecf20Sopenharmony_ci * @type: the remain on channel request type 1688c2ecf20Sopenharmony_ci * 1698c2ecf20Sopenharmony_ci * This function can be used to issue a remain on channel session, 1708c2ecf20Sopenharmony_ci * which means that the fw will stay in the channel for the request %duration 1718c2ecf20Sopenharmony_ci * milliseconds. The function is async, meaning that it only issues the ROC 1728c2ecf20Sopenharmony_ci * request but does not wait for it to start. Once the FW is ready to serve the 1738c2ecf20Sopenharmony_ci * ROC request, it will issue a notification to the driver that it is on the 1748c2ecf20Sopenharmony_ci * requested channel. Once the FW completes the ROC request it will issue 1758c2ecf20Sopenharmony_ci * another notification to the driver. 1768c2ecf20Sopenharmony_ci */ 1778c2ecf20Sopenharmony_ciint iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, 1788c2ecf20Sopenharmony_ci int duration, enum ieee80211_roc_type type); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci/** 1818c2ecf20Sopenharmony_ci * iwl_mvm_stop_roc - stop remain on channel functionality 1828c2ecf20Sopenharmony_ci * @mvm: the mvm component 1838c2ecf20Sopenharmony_ci * @vif: the virtual interface for which the roc is stopped 1848c2ecf20Sopenharmony_ci * 1858c2ecf20Sopenharmony_ci * This function can be used to cancel an ongoing ROC session. 1868c2ecf20Sopenharmony_ci * The function is async, it will instruct the FW to stop serving the ROC 1878c2ecf20Sopenharmony_ci * session, but will not wait for the actual stopping of the session. 1888c2ecf20Sopenharmony_ci */ 1898c2ecf20Sopenharmony_civoid iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif); 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci/** 1928c2ecf20Sopenharmony_ci * iwl_mvm_remove_time_event - general function to clean up of time event 1938c2ecf20Sopenharmony_ci * @mvm: the mvm component 1948c2ecf20Sopenharmony_ci * @vif: the vif to which the time event belongs 1958c2ecf20Sopenharmony_ci * @te_data: the time event data that corresponds to that time event 1968c2ecf20Sopenharmony_ci * 1978c2ecf20Sopenharmony_ci * This function can be used to cancel a time event regardless its type. 1988c2ecf20Sopenharmony_ci * It is useful for cleaning up time events running before removing an 1998c2ecf20Sopenharmony_ci * interface. 2008c2ecf20Sopenharmony_ci */ 2018c2ecf20Sopenharmony_civoid iwl_mvm_remove_time_event(struct iwl_mvm *mvm, 2028c2ecf20Sopenharmony_ci struct iwl_mvm_vif *mvmvif, 2038c2ecf20Sopenharmony_ci struct iwl_mvm_time_event_data *te_data); 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/** 2068c2ecf20Sopenharmony_ci * iwl_mvm_te_clear_data - remove time event from list 2078c2ecf20Sopenharmony_ci * @mvm: the mvm component 2088c2ecf20Sopenharmony_ci * @te_data: the time event data to remove 2098c2ecf20Sopenharmony_ci * 2108c2ecf20Sopenharmony_ci * This function is mostly internal, it is made available here only 2118c2ecf20Sopenharmony_ci * for firmware restart purposes. 2128c2ecf20Sopenharmony_ci */ 2138c2ecf20Sopenharmony_civoid iwl_mvm_te_clear_data(struct iwl_mvm *mvm, 2148c2ecf20Sopenharmony_ci struct iwl_mvm_time_event_data *te_data); 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_civoid iwl_mvm_cleanup_roc_te(struct iwl_mvm *mvm); 2178c2ecf20Sopenharmony_civoid iwl_mvm_roc_done_wk(struct work_struct *wk); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_civoid iwl_mvm_remove_csa_period(struct iwl_mvm *mvm, 2208c2ecf20Sopenharmony_ci struct ieee80211_vif *vif); 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_ci/** 2238c2ecf20Sopenharmony_ci * iwl_mvm_schedule_csa_period - request channel switch absence period 2248c2ecf20Sopenharmony_ci * @mvm: the mvm component 2258c2ecf20Sopenharmony_ci * @vif: the virtual interface for which the channel switch is issued 2268c2ecf20Sopenharmony_ci * @duration: the duration of the NoA in TU. 2278c2ecf20Sopenharmony_ci * @apply_time: NoA start time in GP2. 2288c2ecf20Sopenharmony_ci * 2298c2ecf20Sopenharmony_ci * This function is used to schedule NoA time event and is used to perform 2308c2ecf20Sopenharmony_ci * the channel switch flow. 2318c2ecf20Sopenharmony_ci */ 2328c2ecf20Sopenharmony_ciint iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm, 2338c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 2348c2ecf20Sopenharmony_ci u32 duration, u32 apply_time); 2358c2ecf20Sopenharmony_ci 2368c2ecf20Sopenharmony_ci/** 2378c2ecf20Sopenharmony_ci * iwl_mvm_te_scheduled - check if the fw received the TE cmd 2388c2ecf20Sopenharmony_ci * @te_data: the time event data that corresponds to that time event 2398c2ecf20Sopenharmony_ci * 2408c2ecf20Sopenharmony_ci * This function returns true iff this TE is added to the fw. 2418c2ecf20Sopenharmony_ci */ 2428c2ecf20Sopenharmony_cistatic inline bool 2438c2ecf20Sopenharmony_ciiwl_mvm_te_scheduled(struct iwl_mvm_time_event_data *te_data) 2448c2ecf20Sopenharmony_ci{ 2458c2ecf20Sopenharmony_ci if (!te_data) 2468c2ecf20Sopenharmony_ci return false; 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_ci return !!te_data->uid; 2498c2ecf20Sopenharmony_ci} 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci/** 2528c2ecf20Sopenharmony_ci * iwl_mvm_schedule_session_protection - schedule a session protection 2538c2ecf20Sopenharmony_ci * @mvm: the mvm component 2548c2ecf20Sopenharmony_ci * @vif: the virtual interface for which the protection issued 2558c2ecf20Sopenharmony_ci * @duration: the duration of the protection 2568c2ecf20Sopenharmony_ci * @wait_for_notif: if true, will block until the start of the protection 2578c2ecf20Sopenharmony_ci */ 2588c2ecf20Sopenharmony_civoid iwl_mvm_schedule_session_protection(struct iwl_mvm *mvm, 2598c2ecf20Sopenharmony_ci struct ieee80211_vif *vif, 2608c2ecf20Sopenharmony_ci u32 duration, u32 min_duration, 2618c2ecf20Sopenharmony_ci bool wait_for_notif); 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci/** 2648c2ecf20Sopenharmony_ci * iwl_mvm_rx_session_protect_notif - handles %SESSION_PROTECTION_NOTIF 2658c2ecf20Sopenharmony_ci */ 2668c2ecf20Sopenharmony_civoid iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm, 2678c2ecf20Sopenharmony_ci struct iwl_rx_cmd_buffer *rxb); 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci#endif /* __time_event_h__ */ 270