xref: /linux/drivers/net/wireless/intel/iwlwifi/mld/session-protect.h (revision 1a9239bb4253f9076b5b4b2a1a4e8d7defd77a95)
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /*
3  * Copyright (C) 2024-2025 Intel Corporation
4  */
5 
6 #ifndef __session_protect_h__
7 #define __session_protect_h__
8 
9 #include "mld.h"
10 #include "hcmd.h"
11 #include <net/mac80211.h>
12 #include "fw/api/mac-cfg.h"
13 
14 /**
15  * DOC: session protection
16  *
17  * Session protection is an API from the firmware that allows the driver to
18  * request time on medium. This is needed before the association when we need
19  * to be on medium for the association frame exchange. Once we configure the
20  * firmware as 'associated', the firmware will allocate time on medium without
21  * needed a session protection.
22  *
23  * TDLS discover uses this API as well even after association to ensure that
24  * other activities internal to the firmware will not interrupt our presence
25  * on medium.
26  */
27 
28 /**
29  * struct iwl_mld_session_protect - session protection parameters
30  * @end_jiffies: expected end_jiffies of current session protection.
31  *	0 if not active
32  * @duration: the duration in tu of current session
33  * @session_requested: A session protection command was sent and wasn't yet
34  *	answered
35  */
36 struct iwl_mld_session_protect {
37 	unsigned long end_jiffies;
38 	u32 duration;
39 	bool session_requested;
40 };
41 
42 #define IWL_MLD_SESSION_PROTECTION_ASSOC_TIME_MS 900
43 #define IWL_MLD_SESSION_PROTECTION_MIN_TIME_MS 400
44 
45 /**
46  * iwl_mld_handle_session_prot_notif - handles %SESSION_PROTECTION_NOTIF
47  * @mld: the mld component
48  * @pkt: the RX packet containing the notification
49  */
50 void iwl_mld_handle_session_prot_notif(struct iwl_mld *mld,
51 				       struct iwl_rx_packet *pkt);
52 
53 /**
54  * iwl_mld_schedule_session_protection - schedule a session protection
55  * @mld: the mld component
56  * @vif: the virtual interface for which the protection issued
57  * @duration: the requested duration of the protection
58  * @min_duration: the minimum duration of the protection
59  * @link_id: The link to schedule a session protection for
60  */
61 void iwl_mld_schedule_session_protection(struct iwl_mld *mld,
62 					 struct ieee80211_vif *vif,
63 					 u32 duration, u32 min_duration,
64 					 int link_id);
65 
66 /**
67  * iwl_mld_start_session_protection - start a session protection
68  * @mld: the mld component
69  * @vif: the virtual interface for which the protection issued
70  * @duration: the requested duration of the protection
71  * @min_duration: the minimum duration of the protection
72  * @link_id: The link to schedule a session protection for
73  * @timeout: timeout for waiting
74  *
75  * This schedules the session protection, and waits for it to start
76  * (with timeout)
77  *
78  * Returns: 0 if successful, error code otherwise
79  */
80 int iwl_mld_start_session_protection(struct iwl_mld *mld,
81 				     struct ieee80211_vif *vif,
82 				     u32 duration, u32 min_duration,
83 				     int link_id, unsigned long timeout);
84 
85 /**
86  * iwl_mld_cancel_session_protection - cancel the session protection.
87  * @mld: the mld component
88  * @vif: the virtual interface for which the session is issued
89  * @link_id: cancel the session protection for given link
90  *
91  * This functions cancels the session protection which is an act of good
92  * citizenship. If it is not needed any more it should be canceled because
93  * the other mac contexts wait for the medium during that time.
94  *
95  * Returns: 0 if successful, error code otherwise
96  *
97  */
98 int iwl_mld_cancel_session_protection(struct iwl_mld *mld,
99 				      struct ieee80211_vif *vif,
100 				      int link_id);
101 
102 #endif /* __session_protect_h__ */
103