xref: /wlan-dirver/qca-wifi-host-cmn/umac/twt/core/src/wlan_twt_priv.h (revision d0c05845839e5f2ba5a8dcebe0cd3e4cd4e8dfcf)
1 /*
2  * Copyright (c) 2022 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  */
45 struct twt_tgt_caps {
46 	bool twt_requestor;
47 	bool twt_responder;
48 	bool legacy_bcast_twt_support;
49 	bool twt_bcast_req_support;
50 	bool twt_bcast_res_support;
51 	bool twt_nudge_enabled;
52 	bool all_twt_enabled;
53 	bool twt_stats_enabled;
54 	bool twt_ack_supported;
55 };
56 
57 /**
58  * struct twt_psoc_priv_obj -
59  * @cfg_params: cfg params
60  * @twt_caps: twt caps
61  * @enable_context: enable context
62  * @disable_context: disable context
63  */
64 struct twt_psoc_priv_obj {
65 	psoc_twt_ext_cfg_params_t cfg_params;
66 	struct twt_tgt_caps twt_caps;
67 	struct twt_en_dis_context enable_context;
68 	struct twt_en_dis_context disable_context;
69 };
70 
71 /**
72  * struct twt_vdev_priv_obj -
73  * @twt_wait_for_notify: wait for notify
74  * @dialog_id: TWT dialog id
75  * @peer_macaddr: Peer mac address
76  * @next_action: next action of TWT worker queue
77  */
78 struct twt_vdev_priv_obj {
79 	bool twt_wait_for_notify;
80 	uint32_t dialog_id;
81 	struct qdf_mac_addr peer_macaddr;
82 	enum HOST_TWT_NEXT_WORK_ACTION next_action;
83 };
84 
85 /**
86  * struct twt_session -
87  * @dialog_id: dialog id
88  * @state: state
89  * @setup_done: setup done
90  * @active_cmd: active command
91  * @twt_ack_ctx: twt ack context
92  */
93 struct twt_session {
94 	uint8_t dialog_id;
95 	uint8_t state;
96 	bool setup_done;
97 	enum wlan_twt_commands active_cmd;
98 	void *twt_ack_ctx;
99 };
100 
101 /**
102  * struct twt_peer_priv_obj -
103  * @twt_peer_lock: peer lock
104  * @peer_capability: peer capability
105  * @num_twt_sessions: number of twt sessions
106  * @session_info: session info
107  */
108 struct twt_peer_priv_obj {
109 #ifdef WLAN_TWT_SPINLOCK
110 	qdf_spinlock_t twt_peer_lock;
111 #else
112 	qdf_mutex_t twt_peer_lock;
113 #endif
114 	uint8_t peer_capability;
115 	uint8_t num_twt_sessions;
116 	struct twt_session session_info
117 		[WLAN_MAX_TWT_SESSIONS_PER_PEER];
118 };
119 
120 #ifdef WLAN_TWT_SPINLOCK
121 /**
122  * twt_lock_create - Create TWT peer mutex/spinlock
123  * @twt_lock: lock object
124  *
125  * Creates TWT peer mutex/spinlock
126  *
127  * Return: void
128  */
129 static inline void
130 twt_lock_create(qdf_spinlock_t *twt_lock)
131 {
132 	qdf_spinlock_create(twt_lock);
133 }
134 
135 /**
136  * twt_lock_destroy - Destroy TWT mutex/spinlock
137  * @twt_lock: lock object
138  *
139  * Destroy TWT peer mutex/spinlock
140  *
141  * Return: void
142  */
143 static inline void
144 twt_lock_destroy(qdf_spinlock_t *twt_lock)
145 {
146 	qdf_spinlock_destroy(twt_lock);
147 }
148 
149 /**
150  * twt_lock_acquire - acquire TWT mutex/spinlock
151  * @twt_lock: lock object
152  *
153  * acquire TWT mutex/spinlock
154  *
155  * return: void
156  */
157 static inline void twt_lock_acquire(qdf_spinlock_t *twt_lock)
158 {
159 	qdf_spin_lock_bh(twt_lock);
160 }
161 
162 /**
163  * twt_lock_release - release TWT mutex/spinlock
164  * @twt_lock: lock object
165  *
166  * release TWT mutex/spinlock
167  *
168  * return: void
169  */
170 static inline void twt_lock_release(qdf_spinlock_t *twt_lock)
171 {
172 	qdf_spin_unlock_bh(twt_lock);
173 }
174 #else
175 static inline void
176 twt_lock_create(qdf_mutex_t *twt_lock)
177 {
178 	qdf_mutex_create(twt_lock);
179 }
180 
181 static inline void
182 twt_lock_destroy(qdf_mutex_t *twt_lock)
183 {
184 	qdf_mutex_destroy(twt_lock);
185 }
186 
187 static inline void twt_lock_acquire(qdf_mutex_t *twt_lock)
188 {
189 	qdf_mutex_acquire(twt_lock);
190 }
191 
192 static inline void twt_lock_release(qdf_mutex_t *twt_lock)
193 {
194 	qdf_mutex_release(twt_lock);
195 }
196 #endif /* WLAN_TWT_SPINLOCK */
197 
198 #endif /* End  of _WLAN_TWT_PRIV_H_ */
199 
200