xref: /wlan-driver/qca-wifi-host-cmn/umac/twt/core/src/wlan_twt_priv.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: Declare private data structures and APIs which shall be used
21  * internally only in twt component.
22  *
23  * Note: This API should be never accessed out of twt component.
24  */
25 
26 #ifndef _WLAN_TWT_PRIV_H_
27 #define _WLAN_TWT_PRIV_H_
28 
29 #include <wlan_twt_public_structs.h>
30 #include <wlan_twt_ext_defs.h>
31 #include <wlan_twt_ext_type.h>
32 
33 /**
34  * struct twt_tgt_caps -
35  * @twt_requestor: twt requestor
36  * @twt_responder: twt responder
37  * @legacy_bcast_twt_support: legacy bcast twt support
38  * @twt_bcast_req_support: bcast requestor support
39  * @twt_bcast_res_support: bcast responder support
40  * @twt_nudge_enabled: twt nudge enabled
41  * @all_twt_enabled: all twt enabled
42  * @twt_stats_enabled: twt stats enabled
43  * @twt_ack_supported: twt ack supported
44  * @restricted_twt_support: Restricted TWT supported
45  */
46 struct twt_tgt_caps {
47 	bool twt_requestor;
48 	bool twt_responder;
49 	bool legacy_bcast_twt_support;
50 	bool twt_bcast_req_support;
51 	bool twt_bcast_res_support;
52 	bool twt_nudge_enabled;
53 	bool all_twt_enabled;
54 	bool twt_stats_enabled;
55 	bool twt_ack_supported;
56 	bool restricted_twt_support;
57 };
58 
59 /**
60  * struct twt_psoc_priv_obj -
61  * @cfg_params: cfg params
62  * @twt_caps: twt caps
63  * @enable_context: enable context
64  * @disable_context: disable context
65  * @twt_pmo_disabled: twt pmo disabled
66  */
67 struct twt_psoc_priv_obj {
68 	psoc_twt_ext_cfg_params_t cfg_params;
69 	struct twt_tgt_caps twt_caps;
70 	struct twt_en_dis_context enable_context;
71 	struct twt_en_dis_context disable_context;
72 	uint32_t twt_pmo_disabled;
73 };
74 
75 /**
76  * struct twt_vdev_priv_obj -
77  * @twt_wait_for_notify: wait for notify
78  * @dialog_id: TWT dialog id
79  * @peer_macaddr: Peer mac address
80  * @is_ps_disabled: Whether power save is disabled or not
81  * @next_action: next action of TWT worker queue
82  */
83 struct twt_vdev_priv_obj {
84 	bool twt_wait_for_notify;
85 	uint32_t dialog_id;
86 	struct qdf_mac_addr peer_macaddr;
87 	bool is_ps_disabled;
88 	enum HOST_TWT_NEXT_WORK_ACTION next_action;
89 };
90 
91 /**
92  * struct twt_session -
93  * @dialog_id: dialog id
94  * @state: state
95  * @setup_done: setup done
96  * @active_cmd: active command
97  * @twt_ack_ctx: twt ack context
98  * @wake_dur: TWT wake duration
99  * @wake_interval: TWT wake interval
100  */
101 struct twt_session {
102 	uint8_t dialog_id;
103 	uint8_t state;
104 	bool setup_done;
105 	enum wlan_twt_commands active_cmd;
106 	void *twt_ack_ctx;
107 	uint32_t wake_dur;
108 	uint32_t wake_interval;
109 };
110 
111 /**
112  * struct twt_peer_priv_obj -
113  * @twt_peer_lock: peer lock
114  * @peer_capability: peer capability
115  * @num_twt_sessions: number of twt sessions
116  * @session_info: session info
117  */
118 struct twt_peer_priv_obj {
119 #ifdef WLAN_TWT_SPINLOCK
120 	qdf_spinlock_t twt_peer_lock;
121 #else
122 	qdf_mutex_t twt_peer_lock;
123 #endif
124 	uint8_t peer_capability;
125 	uint8_t num_twt_sessions;
126 	struct twt_session session_info
127 		[WLAN_MAX_TWT_SESSIONS_PER_PEER];
128 };
129 
130 #ifdef WLAN_TWT_SPINLOCK
131 /**
132  * twt_lock_create - Create TWT peer mutex/spinlock
133  * @twt_lock: lock object
134  *
135  * Creates TWT peer mutex/spinlock
136  *
137  * Return: void
138  */
139 static inline void
twt_lock_create(qdf_spinlock_t * twt_lock)140 twt_lock_create(qdf_spinlock_t *twt_lock)
141 {
142 	qdf_spinlock_create(twt_lock);
143 }
144 
145 /**
146  * twt_lock_destroy - Destroy TWT mutex/spinlock
147  * @twt_lock: lock object
148  *
149  * Destroy TWT peer mutex/spinlock
150  *
151  * Return: void
152  */
153 static inline void
twt_lock_destroy(qdf_spinlock_t * twt_lock)154 twt_lock_destroy(qdf_spinlock_t *twt_lock)
155 {
156 	qdf_spinlock_destroy(twt_lock);
157 }
158 
159 /**
160  * twt_lock_acquire - acquire TWT mutex/spinlock
161  * @twt_lock: lock object
162  *
163  * acquire TWT mutex/spinlock
164  *
165  * return: void
166  */
twt_lock_acquire(qdf_spinlock_t * twt_lock)167 static inline void twt_lock_acquire(qdf_spinlock_t *twt_lock)
168 {
169 	qdf_spin_lock_bh(twt_lock);
170 }
171 
172 /**
173  * twt_lock_release - release TWT mutex/spinlock
174  * @twt_lock: lock object
175  *
176  * release TWT mutex/spinlock
177  *
178  * return: void
179  */
twt_lock_release(qdf_spinlock_t * twt_lock)180 static inline void twt_lock_release(qdf_spinlock_t *twt_lock)
181 {
182 	qdf_spin_unlock_bh(twt_lock);
183 }
184 #else
185 static inline void
twt_lock_create(qdf_mutex_t * twt_lock)186 twt_lock_create(qdf_mutex_t *twt_lock)
187 {
188 	qdf_mutex_create(twt_lock);
189 }
190 
191 static inline void
twt_lock_destroy(qdf_mutex_t * twt_lock)192 twt_lock_destroy(qdf_mutex_t *twt_lock)
193 {
194 	qdf_mutex_destroy(twt_lock);
195 }
196 
twt_lock_acquire(qdf_mutex_t * twt_lock)197 static inline void twt_lock_acquire(qdf_mutex_t *twt_lock)
198 {
199 	qdf_mutex_acquire(twt_lock);
200 }
201 
twt_lock_release(qdf_mutex_t * twt_lock)202 static inline void twt_lock_release(qdf_mutex_t *twt_lock)
203 {
204 	qdf_mutex_release(twt_lock);
205 }
206 #endif /* WLAN_TWT_SPINLOCK */
207 
208 #endif /* End  of _WLAN_TWT_PRIV_H_ */
209 
210