summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel/iwlwifi/mld/session-protect.h
blob: 642bec8451a16ce449c2482160438c106121b222 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/*
 * Copyright (C) 2024-2025 Intel Corporation
 */

#ifndef __session_protect_h__
#define __session_protect_h__

#include "mld.h"
#include "hcmd.h"
#include <net/mac80211.h>
#include "fw/api/mac-cfg.h"

/**
 * DOC: session protection
 *
 * Session protection is an API from the firmware that allows the driver to
 * request time on medium. This is needed before the association when we need
 * to be on medium for the association frame exchange. Once we configure the
 * firmware as 'associated', the firmware will allocate time on medium without
 * needed a session protection.
 *
 * TDLS discover uses this API as well even after association to ensure that
 * other activities internal to the firmware will not interrupt our presence
 * on medium.
 */

/**
 * struct iwl_mld_session_protect - session protection parameters
 * @end_jiffies: expected end_jiffies of current session protection.
 *	0 if not active
 * @duration: the duration in tu of current session
 * @session_requested: A session protection command was sent and wasn't yet
 *	answered
 */
struct iwl_mld_session_protect {
	unsigned long end_jiffies;
	u32 duration;
	bool session_requested;
};

#define IWL_MLD_SESSION_PROTECTION_ASSOC_TIME_MS 900
#define IWL_MLD_SESSION_PROTECTION_MIN_TIME_MS 400

/**
 * iwl_mld_handle_session_prot_notif - handles %SESSION_PROTECTION_NOTIF
 * @mld: the mld component
 * @pkt: the RX packet containing the notification
 */
void iwl_mld_handle_session_prot_notif(struct iwl_mld *mld,
				       struct iwl_rx_packet *pkt);

/**
 * iwl_mld_schedule_session_protection - schedule a session protection
 * @mld: the mld component
 * @vif: the virtual interface for which the protection issued
 * @duration: the requested duration of the protection
 * @min_duration: the minimum duration of the protection
 * @link_id: The link to schedule a session protection for
 */
void iwl_mld_schedule_session_protection(struct iwl_mld *mld,
					 struct ieee80211_vif *vif,
					 u32 duration, u32 min_duration,
					 int link_id);

/**
 * iwl_mld_start_session_protection - start a session protection
 * @mld: the mld component
 * @vif: the virtual interface for which the protection issued
 * @duration: the requested duration of the protection
 * @min_duration: the minimum duration of the protection
 * @link_id: The link to schedule a session protection for
 * @timeout: timeout for waiting
 *
 * This schedules the session protection, and waits for it to start
 * (with timeout)
 *
 * Returns: 0 if successful, error code otherwise
 */
int iwl_mld_start_session_protection(struct iwl_mld *mld,
				     struct ieee80211_vif *vif,
				     u32 duration, u32 min_duration,
				     int link_id, unsigned long timeout);

/**
 * iwl_mld_cancel_session_protection - cancel the session protection.
 * @mld: the mld component
 * @vif: the virtual interface for which the session is issued
 * @link_id: cancel the session protection for given link
 *
 * This functions cancels the session protection which is an act of good
 * citizenship. If it is not needed any more it should be canceled because
 * the other mac contexts wait for the medium during that time.
 *
 * Returns: 0 if successful, error code otherwise
 *
 */
int iwl_mld_cancel_session_protection(struct iwl_mld *mld,
				      struct ieee80211_vif *vif,
				      int link_id);

#endif /* __session_protect_h__ */