xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/include/802.11ah.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Basic types and constants relating to 802.11ah standard.
3  * This is a portion of 802.11ah definition. The rest are in 802.11.h.
4  *
5  * Copyright (C) 2020, Broadcom.
6  *
7  *      Unless you and Broadcom execute a separate written software license
8  * agreement governing use of this software, this software is licensed to you
9  * under the terms of the GNU General Public License version 2 (the "GPL"),
10  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
11  * following added to such license:
12  *
13  *      As a special exception, the copyright holders of this software give you
14  * permission to link this software with independent modules, and to copy and
15  * distribute the resulting executable under terms of your choice, provided that
16  * you also meet, for each linked independent module, the terms and conditions of
17  * the license of that module.  An independent module is a module which is not
18  * derived from this software.  The special exception does not apply to any
19  * modifications of the software.
20  *
21  *
22  * <<Broadcom-WL-IPTag/Open:>>
23  */
24 
25 #ifndef _802_11ah_h_
26 #define _802_11ah_h_
27 
28 #include <typedefs.h>
29 
30 /* This marks the start of a packed structure section. */
31 #include <packed_section_start.h>
32 
33 /**
34  * TWT IE (sec 9.4.2.200)
35  */
36 
37 /* TWT element - top (Figure 9-589av) */
38 BWL_PRE_PACKED_STRUCT struct twt_ie_top {
39 	uint8 id;
40 	uint8 len;
41 	uint8 ctrl;		/* Control */
42 } BWL_POST_PACKED_STRUCT;
43 
44 typedef struct twt_ie_top twt_ie_top_t;
45 
46 /* S1G Action IDs */
47 #define S1G_ACTION_TWT_SETUP	6u
48 #define S1G_ACTION_TWT_TEARDOWN	7u
49 #define S1G_ACTION_TWT_INFO	11u
50 
51 /* S1G Action frame offsets */
52 #define S1G_AF_CAT_OFF	0u
53 #define S1G_AF_ACT_OFF	1u
54 
55 /* TWT Setup */
56 #define S1G_AF_TWT_SETUP_TOKEN_OFF	2u
57 #define S1G_AF_TWT_SETUP_TWT_IE_OFF	3u
58 
59 /* TWT Teardown */
60 #define S1G_AF_TWT_TEARDOWN_FLOW_OFF	2u
61 
62 /* TWT Information */
63 #define S1G_AF_TWT_INFO_OFF	2u
64 
65 #define TWT_BCAST_WAKE_TIME_OFFSET	10u
66 #define TWT_BCAST_WAKE_TIME_SHIFT	10u
67 #define TWT_BCAST_WAKE_TIME_MASK	0x03FFFC00u
68 #define TWT_BCAST_WAKE_TIME_ZERO_BIT_SZ	10u
69 
70 /* Control field (Figure 9-589aw) */
71 #define TWT_CTRL_NDP_PAGING_IND		0x01u	/* NDP Paging Indication */
72 #define TWT_CTRL_RESP_PM_MODE		0x02u	/* Respondor PM Mode */
73 #define TWT_CTRL_NEGO_TYPE_IDX		2u
74 #define TWT_CTRL_NEGO_TYPE_MASK		0x0Cu	/* TWT Negotiation Type */
75 #define TWT_CTRL_NEGO_TYPE_SHIFT	2u
76 #define TWT_CTRL_INFO_FRM_DISABLED	0x10u	/* TWT info frame disabled */
77 #define TWT_CTRL_WAKEDUR_UNIT		0x20u	/* Wake duration unit */
78 
79 /* TWT Negotiation Type (Table 9-262j1) */
80 typedef enum twt_ctrl_nego_type {
81 	TWT_CTRL_NEGO_TYPE_0	= 0,	/* Individual TWT Setup */
82 	TWT_CTRL_NEGO_TYPE_1	= 1,	/* Wake TBTT Negotiation */
83 	TWT_CTRL_NEGO_TYPE_2	= 2,	/* Broadcast TWT IE in Beacon */
84 	TWT_CTRL_NEGO_TYPE_3	= 3,	/* Broadcast TWT memberships */
85 } twt_ctrl_nego_type_t;
86 
87 /* Request Type field (Figure 9-589ay) */
88 #define TWT_REQ_TYPE_REQUEST		0x0001u	/* Request */
89 #define TWT_REQ_TYPE_SETUP_CMD_MASK	0x000eu	/* Setup Command */
90 #define TWT_REQ_TYPE_SETUP_CMD_SHIFT	1u
91 #define TWT_REQ_TYPE_TRIGGER		0x0010u	/* Trigger */
92 #define TWT_REQ_TYPE_IMPLICIT		0x0020u	/* Implicit */
93 #define TWT_REQ_TYPE_LAST_BCAST_PARAM	0x0020u	/* Last Broadcast Parameter Set */
94 #define TWT_REQ_TYPE_FLOW_TYPE		0x0040u	/* Flow Type */
95 #define TWT_REQ_TYPE_FLOW_ID_MASK	0x0380u	/* Flow Identifier */
96 #define TWT_REQ_TYPE_FLOW_ID_SHIFT	7u
97 #define TWT_REQ_TYPE_BTWT_RECOMM_MASK	0x0380u	/* Broadcast TWT Recommendation */
98 #define TWT_REQ_TYPE_BTWT_RECOMM_SHIFT	7u
99 #define TWT_REQ_TYPE_WAKE_EXP_MASK	0x7c00u	/* Wake Interval Exponent */
100 #define TWT_REQ_TYPE_WAKE_EXP_SHIFT	10u
101 #define TWT_REQ_TYPE_PROTECTION		0x8000u	/* Protection */
102 
103 /* Setup Command field (Table 9-262k) */
104 #define TWT_SETUP_CMD_REQUEST_TWT	0u	/* Request TWT */
105 #define TWT_SETUP_CMD_SUGGEST_TWT	1u	/* Suggest TWT */
106 #define TWT_SETUP_CMD_DEMAND_TWT	2u	/* Demand TWT */
107 #define TWT_SETUP_CMD_GROUPING_TWT	3u	/* Grouping TWT */
108 #define TWT_SETUP_CMD_ACCEPT_TWT	4u	/* Accept TWT */
109 #define TWT_SETUP_CMD_ALTERNATE_TWT		5u	/* Alternate TWT */
110 #define TWT_SETUP_CMD_DICTATE_TWT	6u	/* Dictate TWT */
111 #define TWT_SETUP_CMD_REJECT_TWT	7u	/* Reject TWT */
112 
113 /* Broadcast TWT Recommendation field (Table 9-262k1) */
114 #define TWT_BCAST_FRAME_RECOMM_0	0u	/* No constrains on frames in Broadcast TWT SP */
115 #define TWT_BCAST_FRAME_RECOMM_1	1u	/* Do not contain RUs for random access */
116 #define TWT_BCAST_FRAME_RECOMM_2	2u	/* Can contain RUs for random access */
117 #define TWT_BCAST_FRAME_RECOMM_3	3u
118 
119 /* Request Type subfield - 2 octets */
120 typedef uint16 twt_request_type_t;	/* 16 bit request type */
121 
122 /* Target Wake Time - 8 octets or 0 octet */
123 typedef uint64 twt_target_wake_time_t;	/* 64 bit TSF time of TWT Responding STA */
124 typedef uint16 twt_bcast_wake_time_t;	/* 16 bit Wake Time of Bcast scheduling STA */
125 typedef uint16 twt_bcast_twt_info_t;	/* 16 bit Broadcast TWT Info subfield */
126 
127 /* TWT Group Assignment Info - 9 octets (long format) or 3 octets (short format) or 0 octet */
128 /* Group Assignment Info field - short format - Zero Offset Preset field is 0 */
129 BWL_PRE_PACKED_STRUCT struct twt_grp_short {
130 	uint8 grpid_n_0off;	/* Group ID and Zero Offset Present */
131 	uint16 unit_n_off;	/* TWT Unit and TWT Offset */
132 } BWL_POST_PACKED_STRUCT;
133 
134 typedef struct twt_grp_short twt_grp_short_t;
135 
136 /* Group Assignment Info field - long format - Zero Offset Preset field is 1 */
137 #define TWT_ZERO_OFF_GRP_LEN 6u
138 BWL_PRE_PACKED_STRUCT struct twt_grp_long {
139 	uint8 grpid_n_0off;	/* Group ID and Zero Offset Present */
140 	uint8 grp_0off[TWT_ZERO_OFF_GRP_LEN];	/* Zero Offset of Group */
141 	uint16 unit_n_off;	/* Unit and Offset */
142 } BWL_POST_PACKED_STRUCT;
143 
144 typedef struct twt_grp_long twt_grp_long_t;
145 
146 /* TWT Unit and TWT Offset field */
147 #define TWT_UNIT_MASK		0x000fu		/* TWT Unit */
148 #define TWT_OFFSET_MASK		0xfff0u		/* TWT Offset */
149 #define TWT_OFFSET_SHIFT	4u
150 
151 /* TWT Unit field (table 8-248m) */
152 #define TWT_UNIT_32us		0u
153 #define TWT_UNIT_256us		1u
154 #define TWT_UNIT_1024us		2u
155 #define TWT_UNIT_8ms192us	3u
156 #define TWT_UNIT_32ms768us	4u
157 #define TWT_UNIT_262ms144us	5u
158 #define TWT_UNIT_1s048576us	6u
159 #define TWT_UNIT_8s388608us	7u
160 #define TWT_UNIT_33s554432us	8u
161 #define TWT_UNIT_268s435456us	9u
162 #define TWT_UNIT_1073s741824us	10u
163 #define TWT_UNIT_8589s934592us	11u
164 
165 /* TWT element - bottom */
166 BWL_PRE_PACKED_STRUCT struct twt_ie_itwt_bottom {
167 	uint8 nom_wake_dur;		/* Nominal Minimum Wake Duration */
168 	uint16 wake_int_mant;		/* TWT Wake Interval Mantissa */
169 	uint8 channel;			/* TWT Channel */
170 	/* NDP Paging field */
171 } BWL_POST_PACKED_STRUCT;
172 
173 typedef struct twt_ie_itwt_bottom twt_ie_itwt_bottom_t;
174 
175 /* TWT element - bottom */
176 BWL_PRE_PACKED_STRUCT struct twt_ie_btwt_bottom {
177 	uint8 nom_wake_dur;		/* Nominal Minimum Wake Duration */
178 	uint16 wake_int_mant;		/* TWT Wake Interval Mantissa */
179 	twt_bcast_twt_info_t btwt_info;	/* Broadcast TWT Info */
180 	/* NDP Paging field */
181 } BWL_POST_PACKED_STRUCT;
182 
183 typedef struct twt_ie_btwt_bottom twt_ie_btwt_bottom_t;
184 
185 /* TWT IE structure for broadcast TWT */
186 typedef struct twt_last_bcast_ie {
187 	twt_ie_top_t top;			/* Element id, len, control fields */
188 	twt_request_type_t req_type;	/* request type field */
189 	twt_bcast_wake_time_t twt;	/* twt field */
190 	twt_ie_btwt_bottom_t btwt_bottom;	/* wake dur, int, BID Info */
191 } twt_last_bcast_ie_t;
192 
193 /* Nominal Minimum Wake Duration */
194 #define TWT_WAKE_DUR_UNIT_256us		256u	/* Nom.Min. Wake Duration is in 256us units */
195 #define TWT_WAKE_DUR_UNIT_1ms		1024u	/* Nom. Min. Wake Duration is in 1ms units */
196 
197 /* to be deprecated */
198 #define TWT_NOM_WAKE_DUR_UNIT	 256u	/* Nominal Minimum Wake Duration is in 256us units */
199 
200 /* TWT IE field lengths */
201 #define TWT_IE_NOM_MIN_TWT_WK_DUR_SZ		1u	/* 1 byte */
202 #define TWT_IE_TWT_WAKE_INT_MANT_SZ		2u	/* 2 bytes */
203 #define TWT_IE_BCAST_TWT_INFO_SZ		2u	/* 2 byte */
204 #define TWT_IE_TWT_CHANNEL_SZ			1u	/* 1 byte */
205 
206 /* Broadcast TWT info subfield format (figure 9-589ay1) */
207 #define TWT_BTWT_PERSIST_EXPO_MASK		0x0007u	/* Broadcast TWT Persistence Exponent */
208 #define TWT_BCAST_TWT_ID_MASK			0x00F8u	/* Broadcast TWT ID */
209 #define TWT_BCAST_TWT_ID_SHIFT			3u
210 #define TWT_BTWT_PERSIST_MANT_MASK		0xFF00u	/* Broadcast TWT Persistence Mantissa */
211 #define TWT_BTWT_PERSIST_MANT_SHIFT		8u
212 
213 #define TWT_BTWT_PERSIST_INDEFINITE		0xFFu
214 
215 /* NDP Paging field - 4 octets or 0 octet */
216 typedef uint32 twt_ndp_paging_t;
217 
218 #define TWT_NDP_PAGING_PID		0x000001ffu	/* P-ID */
219 #define TWT_NDP_PAGING_MAX_PERIOD	0x0001fe00u	/* Max NDP Paging Period */
220 #define TWT_NDP_PAGING_PART_TSF_OFF	0x001e0000u	/* Partial TSF Offset */
221 #define TWT_NDP_PAGING_ACTION		0x00e00000u	/* Action */
222 #define TWT_NDP_PAGING_MIN_SLEEP	0x3f000000u	/* Min Sleep Duration */
223 
224 /* Action field (table 8-248n) */
225 #define TWT_ACTION_SEND_PSP_TRIG	0u	/* Send a PS-Poll or uplink trigger frame */
226 #define TWT_ACTION_WAKE_MIN_SLEEP	1u	/* Wake up at the time indicated by
227 						 * Min Sleep Duration
228 						 */
229 #define TWT_ACTION_WAKE_RCV_BCN		2u	/* Wake up to receive the Beacon */
230 #define TWT_ACTION_WAKE_RCV_DTIM	3u	/* Wake up to receive the DTIM Beacon */
231 #define TWT_ACTION_WAKE_IND_TIME	4u	/* Wakeup at the time indicated by the sum of
232 						 * the Min Sleep Duration field and the ASD subfield
233 						 * in the APDI field of the NDP Paging frame
234 						 */
235 
236 /* TWT Teardown for Negotiation type 0 or 1 */
237 #define TWT_TEARDOWN_FLOW_ID_MASK		0x07u
238 /* TWT Teardown for Negotiation type 3 */
239 #define TWT_TEARDOWN_BTWT_ID_MASK		0x1Fu
240 
241 #define TWT_TEARDOWN_NEGO_TYPE_MASK		0x60u
242 #define TWT_TEARDOWN_NEGO_TYPE_SHIFT		5u
243 /* Teardown All TWT indication */
244 #define TWT_TEARDOWN_ALL_TWT			0x80u
245 
246 /* TWT Information field byte 0 */
247 #define TWT_INFO_FLOW_ID_MASK		0x07u
248 #define TWT_INFO_RESP_REQ		0x08u
249 #define TWT_INFO_NEXT_TWT_REQ		0x10u
250 #define TWT_INFO_NEXT_TWT_SIZE_MASK	0x60u
251 #define TWT_INFO_NEXT_TWT_SIZE_SHIFT	0x5u
252 #define TWT_INFO_ALL_TWT		0x80u
253 
254 /* Next TWT Subfield Size field encoding */
255 #define TWT_INFO_NEXT_TWT_SIZE_0_IDX	0u	/* 0 byte */
256 #define TWT_INFO_NEXT_TWT_SIZE_32_IDX	1u	/* 4 bytes */
257 #define TWT_INFO_NEXT_TWT_SIZE_48_IDX	2u	/* 6 bytes */
258 #define TWT_INFO_NEXT_TWT_SIZE_64_IDX	3u	/* 8 bytes */
259 
260 /* Next TWT Subfield Size field */
261 #define TWT_INFO_NEXT_TWT_SIZE_0	0u	/* 0 byte */
262 #define TWT_INFO_NEXT_TWT_SIZE_32	4u	/* 4 bytes */
263 #define TWT_INFO_NEXT_TWT_SIZE_48	6u	/* 6 bytes */
264 #define TWT_INFO_NEXT_TWT_SIZE_64	8u	/* 8 bytes */
265 
266 /* Old macro definitions - To be removed - Start here */
267 #define TWT_BCAST_MAX_VALID_FLOW_ID	3u
268 #define TWT_CTRL_BCAST			0x04u	/* Broadcast */
269 #define TWT_CTRL_WAKE_TBTT_NEGO		0x08u	/* Wake TBTT Negotiation */
270 #define TWT_SETUP_CMD_GRPING_TWT	3u	/* Grouping TWT */
271 #define TWT_SETUP_CMD_ALTER_TWT		5u	/* Alternate TWT */
272 #define TWT_IE_BCAST_TWT_ID_SZ		1u	/* 1 byte */
273 #define TWT_INFO_BROADCAST_RESCHED	0x80u
274 
275 typedef struct twt_ie_itwt_bottom twt_ie_bottom_t;
276 /* Old macro definitions - To be removed - End here */
277 
278 /* This marks the end of a packed structure section. */
279 #include <packed_section_end.h>
280 
281 #endif /* _802_11ah_h_ */
282