xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/include/p2p.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Fundamental types and constants relating to WFA P2P (aka WiFi Direct)
3  *
4  * Copyright (C) 2020, Broadcom.
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions of
16  * the license of that module.  An independent module is a module which is not
17  * derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *
21  * <<Broadcom-WL-IPTag/Dual:>>
22  */
23 
24 #ifndef _P2P_H_
25 #define _P2P_H_
26 
27 #ifndef _TYPEDEFS_H_
28 #include <typedefs.h>
29 #endif
30 #include <wlioctl.h>
31 #include <802.11.h>
32 
33 /* This marks the start of a packed structure section. */
34 #include <packed_section_start.h>
35 
36 /* WiFi P2P OUI values */
37 #define P2P_VER			WFA_OUI_TYPE_P2P	/* P2P version: 9=WiFi P2P v1.0 */
38 
39 #define P2P_IE_ID		0xdd			/* P2P IE element ID */
40 
41 /* WiFi P2P IE */
42 BWL_PRE_PACKED_STRUCT struct wifi_p2p_ie {
43 	uint8	id;		/* IE ID: 0xDD */
44 	uint8	len;		/* IE length */
45 	uint8	OUI[3];		/* WiFi P2P specific OUI: P2P_OUI */
46 	uint8	oui_type;	/* Identifies P2P version: P2P_VER */
47 	uint8	subelts[1];	/* variable length subelements */
48 } BWL_POST_PACKED_STRUCT;
49 typedef struct wifi_p2p_ie wifi_p2p_ie_t;
50 
51 #define P2P_IE_FIXED_LEN	6
52 
53 #define P2P_ATTR_ID_OFF		0
54 #define P2P_ATTR_LEN_OFF	1
55 #define P2P_ATTR_DATA_OFF	3
56 
57 #define P2P_ATTR_ID_LEN		1	/* ID filed length */
58 #define P2P_ATTR_LEN_LEN	2	/* length field length */
59 #define P2P_ATTR_HDR_LEN	3 /* ID + 2-byte length field spec 1.02 */
60 
61 #define P2P_WFDS_HASH_LEN		6
62 #define P2P_WFDS_MAX_SVC_NAME_LEN	32
63 
64 /* P2P IE Subelement IDs from WiFi P2P Technical Spec 1.00 */
65 #define P2P_SEID_STATUS			0	/* Status */
66 #define P2P_SEID_MINOR_RC		1	/* Minor Reason Code */
67 #define P2P_SEID_P2P_INFO		2	/* P2P Capability (capabilities info) */
68 #define P2P_SEID_DEV_ID			3	/* P2P Device ID */
69 #define P2P_SEID_INTENT			4	/* Group Owner Intent */
70 #define P2P_SEID_CFG_TIMEOUT		5	/* Configuration Timeout */
71 #define P2P_SEID_CHANNEL		6	/* Listen channel */
72 #define P2P_SEID_GRP_BSSID		7	/* P2P Group BSSID */
73 #define P2P_SEID_XT_TIMING		8	/* Extended Listen Timing */
74 #define P2P_SEID_INTINTADDR		9	/* Intended P2P Interface Address */
75 #define P2P_SEID_P2P_MGBTY		10	/* P2P Manageability */
76 #define P2P_SEID_CHAN_LIST		11	/* Channel List */
77 #define P2P_SEID_ABSENCE		12	/* Notice of Absence */
78 #define P2P_SEID_DEV_INFO		13	/* Device Info */
79 #define P2P_SEID_GROUP_INFO		14	/* Group Info */
80 #define P2P_SEID_GROUP_ID		15	/* Group ID */
81 #define P2P_SEID_P2P_IF			16	/* P2P Interface */
82 #define P2P_SEID_OP_CHANNEL		17	/* Operating Channel */
83 #define P2P_SEID_INVITE_FLAGS		18	/* Invitation Flags */
84 #define P2P_SEID_SERVICE_HASH		21	/* Service hash */
85 #define P2P_SEID_SESSION		22	/* Session information */
86 #define P2P_SEID_CONNECT_CAP		23	/* Connection capability */
87 #define P2P_SEID_ADVERTISE_ID		24	/* Advertisement ID */
88 #define P2P_SEID_ADVERTISE_SERVICE	25	/* Advertised service */
89 #define P2P_SEID_SESSION_ID		26	/* Session ID */
90 #define P2P_SEID_FEATURE_CAP		27	/* Feature capability */
91 #define	P2P_SEID_PERSISTENT_GROUP	28	/* Persistent group */
92 #define P2P_SEID_SESSION_INFO_RESP	29	/* Session Information Response */
93 #define P2P_SEID_VNDR			221	/* Vendor-specific subelement */
94 
95 #define P2P_SE_VS_ID_SERVICES	0x1b /* BRCM proprietary subel: L2 Services */
96 
97 /* WiFi P2P IE subelement: P2P Capability (capabilities info) */
98 BWL_PRE_PACKED_STRUCT struct wifi_p2p_info_se_s {
99 	uint8	eltId;		/* SE ID: P2P_SEID_P2P_INFO */
100 	uint8	len[2];		/* SE length not including eltId, len fields */
101 	uint8	dev;		/* Device Capability Bitmap */
102 	uint8	group;		/* Group Capability Bitmap */
103 } BWL_POST_PACKED_STRUCT;
104 typedef struct wifi_p2p_info_se_s wifi_p2p_info_se_t;
105 
106 /* P2P Capability subelement's Device Capability Bitmap bit values */
107 #define P2P_CAPSE_DEV_SERVICE_DIS	0x1 /* Service Discovery */
108 #define P2P_CAPSE_DEV_CLIENT_DIS	0x2 /* Client Discoverability */
109 #define P2P_CAPSE_DEV_CONCURRENT	0x4 /* Concurrent Operation */
110 #define P2P_CAPSE_DEV_INFRA_MAN		0x8 /* P2P Infrastructure Managed */
111 #define P2P_CAPSE_DEV_LIMIT			0x10 /* P2P Device Limit */
112 #define P2P_CAPSE_INVITE_PROC		0x20 /* P2P Invitation Procedure */
113 
114 /* P2P Capability subelement's Group Capability Bitmap bit values */
115 #define P2P_CAPSE_GRP_OWNER			0x1 /* P2P Group Owner */
116 #define P2P_CAPSE_PERSIST_GRP		0x2 /* Persistent P2P Group */
117 #define P2P_CAPSE_GRP_LIMIT			0x4 /* P2P Group Limit */
118 #define P2P_CAPSE_GRP_INTRA_BSS		0x8 /* Intra-BSS Distribution */
119 #define P2P_CAPSE_GRP_X_CONNECT		0x10 /* Cross Connection */
120 #define P2P_CAPSE_GRP_PERSISTENT	0x20 /* Persistent Reconnect */
121 #define P2P_CAPSE_GRP_FORMATION		0x40 /* Group Formation */
122 
123 /* WiFi P2P IE subelement: Group Owner Intent */
124 BWL_PRE_PACKED_STRUCT struct wifi_p2p_intent_se_s {
125 	uint8	eltId;		/* SE ID: P2P_SEID_INTENT */
126 	uint8	len[2];		/* SE length not including eltId, len fields */
127 	uint8	intent;		/* Intent Value 0...15 (0=legacy 15=master only) */
128 } BWL_POST_PACKED_STRUCT;
129 typedef struct wifi_p2p_intent_se_s wifi_p2p_intent_se_t;
130 
131 /* WiFi P2P IE subelement: Configuration Timeout */
132 BWL_PRE_PACKED_STRUCT struct wifi_p2p_cfg_tmo_se_s {
133 	uint8	eltId;		/* SE ID: P2P_SEID_CFG_TIMEOUT */
134 	uint8	len[2];		/* SE length not including eltId, len fields */
135 	uint8	go_tmo;		/* GO config timeout in units of 10 ms */
136 	uint8	client_tmo;	/* Client config timeout in units of 10 ms */
137 } BWL_POST_PACKED_STRUCT;
138 typedef struct wifi_p2p_cfg_tmo_se_s wifi_p2p_cfg_tmo_se_t;
139 
140 /* WiFi P2P IE subelement: Listen Channel */
141 BWL_PRE_PACKED_STRUCT struct wifi_p2p_listen_channel_se_s {
142 	uint8	eltId;		/* SE ID: P2P_SEID_CHANNEL */
143 	uint8	len[2];		/* SE length not including eltId, len fields */
144 	uint8	country[3];	/* Country String */
145 	uint8	op_class;	/* Operating Class */
146 	uint8	channel;	/* Channel */
147 } BWL_POST_PACKED_STRUCT;
148 typedef struct wifi_p2p_listen_channel_se_s wifi_p2p_listen_channel_se_t;
149 
150 /* WiFi P2P IE subelement: P2P Group BSSID */
151 BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_bssid_se_s {
152 	uint8	eltId;		/* SE ID: P2P_SEID_GRP_BSSID */
153 	uint8	len[2];		/* SE length not including eltId, len fields */
154 	uint8	mac[6];		/* P2P group bssid */
155 } BWL_POST_PACKED_STRUCT;
156 typedef struct wifi_p2p_grp_bssid_se_s wifi_p2p_grp_bssid_se_t;
157 
158 /* WiFi P2P IE subelement: P2P Group ID */
159 BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_id_se_s {
160 	uint8	eltId;		/* SE ID: P2P_SEID_GROUP_ID */
161 	uint8	len[2];		/* SE length not including eltId, len fields */
162 	uint8	mac[6];		/* P2P device address */
163 	uint8	ssid[1];	/* ssid. device id. variable length */
164 } BWL_POST_PACKED_STRUCT;
165 typedef struct wifi_p2p_grp_id_se_s wifi_p2p_grp_id_se_t;
166 
167 /* WiFi P2P IE subelement: P2P Interface */
168 BWL_PRE_PACKED_STRUCT struct wifi_p2p_intf_se_s {
169 	uint8	eltId;		/* SE ID: P2P_SEID_P2P_IF */
170 	uint8	len[2];		/* SE length not including eltId, len fields */
171 	uint8	mac[6];		/* P2P device address */
172 	uint8	ifaddrs;	/* P2P Interface Address count */
173 	uint8	ifaddr[1][6];	/* P2P Interface Address list */
174 } BWL_POST_PACKED_STRUCT;
175 typedef struct wifi_p2p_intf_se_s wifi_p2p_intf_se_t;
176 
177 /* WiFi P2P IE subelement: Status */
178 BWL_PRE_PACKED_STRUCT struct wifi_p2p_status_se_s {
179 	uint8	eltId;		/* SE ID: P2P_SEID_STATUS */
180 	uint8	len[2];		/* SE length not including eltId, len fields */
181 	uint8	status;		/* Status Code: P2P_STATSE_* */
182 } BWL_POST_PACKED_STRUCT;
183 typedef struct wifi_p2p_status_se_s wifi_p2p_status_se_t;
184 
185 /* Status subelement Status Code definitions */
186 #define P2P_STATSE_SUCCESS			0
187 				/* Success */
188 #define P2P_STATSE_FAIL_INFO_CURR_UNAVAIL	1
189 				/* Failed, information currently unavailable */
190 #define P2P_STATSE_PASSED_UP			P2P_STATSE_FAIL_INFO_CURR_UNAVAIL
191 				/* Old name for above in P2P spec 1.08 and older */
192 #define P2P_STATSE_FAIL_INCOMPAT_PARAMS		2
193 				/* Failed, incompatible parameters */
194 #define P2P_STATSE_FAIL_LIMIT_REACHED		3
195 				/* Failed, limit reached */
196 #define P2P_STATSE_FAIL_INVALID_PARAMS		4
197 				/* Failed, invalid parameters */
198 #define P2P_STATSE_FAIL_UNABLE_TO_ACCOM		5
199 				/* Failed, unable to accomodate request */
200 #define P2P_STATSE_FAIL_PROTO_ERROR		6
201 				/* Failed, previous protocol error or disruptive behaviour */
202 #define P2P_STATSE_FAIL_NO_COMMON_CHAN		7
203 				/* Failed, no common channels */
204 #define P2P_STATSE_FAIL_UNKNOWN_GROUP		8
205 				/* Failed, unknown P2P Group */
206 #define P2P_STATSE_FAIL_INTENT			9
207 				/* Failed, both peers indicated Intent 15 in GO Negotiation */
208 #define P2P_STATSE_FAIL_INCOMPAT_PROVIS		10
209 				/* Failed, incompatible provisioning method */
210 #define P2P_STATSE_FAIL_USER_REJECT		11
211 				/* Failed, rejected by user */
212 #define P2P_STATSE_SUCCESS_USER_ACCEPT		12
213 				/* Success, accepted by user */
214 
215 /* WiFi P2P IE attribute: Extended Listen Timing */
216 BWL_PRE_PACKED_STRUCT struct wifi_p2p_ext_se_s {
217 	uint8	eltId;		/* ID: P2P_SEID_EXT_TIMING */
218 	uint8	len[2];		/* length not including eltId, len fields */
219 	uint8	avail[2];	/* availibility period */
220 	uint8	interval[2];	/* availibility interval */
221 } BWL_POST_PACKED_STRUCT;
222 typedef struct wifi_p2p_ext_se_s wifi_p2p_ext_se_t;
223 
224 #define P2P_EXT_MIN	10	/* minimum 10ms */
225 
226 /* WiFi P2P IE subelement: Intended P2P Interface Address */
227 BWL_PRE_PACKED_STRUCT struct wifi_p2p_intintad_se_s {
228 	uint8	eltId;		/* SE ID: P2P_SEID_INTINTADDR */
229 	uint8	len[2];		/* SE length not including eltId, len fields */
230 	uint8	mac[6];		/* intended P2P interface MAC address */
231 } BWL_POST_PACKED_STRUCT;
232 typedef struct wifi_p2p_intintad_se_s wifi_p2p_intintad_se_t;
233 
234 /* WiFi P2P IE subelement: Channel */
235 BWL_PRE_PACKED_STRUCT struct wifi_p2p_channel_se_s {
236 	uint8	eltId;		/* SE ID: P2P_SEID_STATUS */
237 	uint8	len[2];		/* SE length not including eltId, len fields */
238 	uint8	band;		/* Regulatory Class (band) */
239 	uint8	channel;	/* Channel */
240 } BWL_POST_PACKED_STRUCT;
241 typedef struct wifi_p2p_channel_se_s wifi_p2p_channel_se_t;
242 
243 /* Channel Entry structure within the Channel List SE */
244 BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_entry_s {
245 	uint8	band;						/* Regulatory Class (band) */
246 	uint8	num_channels;				/* # of channels in the channel list */
247 	uint8	channels[WL_NUMCHANNELS];	/* Channel List */
248 } BWL_POST_PACKED_STRUCT;
249 typedef struct wifi_p2p_chanlist_entry_s wifi_p2p_chanlist_entry_t;
250 #define WIFI_P2P_CHANLIST_SE_MAX_ENTRIES 2
251 
252 /* WiFi P2P IE subelement: Channel List */
253 BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_se_s {
254 	uint8	eltId;		/* SE ID: P2P_SEID_CHAN_LIST */
255 	uint8	len[2];		/* SE length not including eltId, len fields */
256 	uint8	country[3];	/* Country String */
257 	uint8	num_entries;	/* # of channel entries */
258 	wifi_p2p_chanlist_entry_t	entries[WIFI_P2P_CHANLIST_SE_MAX_ENTRIES];
259 						/* Channel Entry List */
260 } BWL_POST_PACKED_STRUCT;
261 typedef struct wifi_p2p_chanlist_se_s wifi_p2p_chanlist_se_t;
262 
263 /* WiFi Primary Device Type structure */
264 BWL_PRE_PACKED_STRUCT struct wifi_p2p_pri_devtype_s {
265 	uint16	cat_id;		/* Category ID */
266 	uint8	OUI[3];		/* WFA OUI: 0x0050F2 */
267 	uint8	oui_type;	/* WPS_OUI_TYPE */
268 	uint16	sub_cat_id;	/* Sub Category ID */
269 } BWL_POST_PACKED_STRUCT;
270 typedef struct wifi_p2p_pri_devtype_s wifi_p2p_pri_devtype_t;
271 
272 /* WiFi P2P Device Info Sub Element Primary Device Type Sub Category
273  * maximum values for each category
274  */
275 #define P2P_DISE_SUBCATEGORY_MINVAL		1
276 #define P2P_DISE_CATEGORY_COMPUTER		1
277 #define P2P_DISE_SUBCATEGORY_COMPUTER_MAXVAL		8
278 #define P2P_DISE_CATEGORY_INPUT_DEVICE		2
279 #define P2P_DISE_SUBCATEGORY_INPUT_DEVICE_MAXVAL	9
280 #define P2P_DISE_CATEGORY_PRINTER		3
281 #define P2P_DISE_SUBCATEGORY_PRINTER_MAXVAL		5
282 #define P2P_DISE_CATEGORY_CAMERA		4
283 #define P2P_DISE_SUBCATEGORY_CAMERA_MAXVAL		4
284 #define P2P_DISE_CATEGORY_STORAGE		5
285 #define P2P_DISE_SUBCATEGORY_STORAGE_MAXVAL		1
286 #define P2P_DISE_CATEGORY_NETWORK_INFRA		6
287 #define P2P_DISE_SUBCATEGORY_NETWORK_INFRA_MAXVAL	4
288 #define P2P_DISE_CATEGORY_DISPLAY		7
289 #define P2P_DISE_SUBCATEGORY_DISPLAY_MAXVAL		4
290 #define P2P_DISE_CATEGORY_MULTIMEDIA		8
291 #define P2P_DISE_SUBCATEGORY_MULTIMEDIA_MAXVAL		6
292 #define P2P_DISE_CATEGORY_GAMING		9
293 #define P2P_DISE_SUBCATEGORY_GAMING_MAXVAL		5
294 #define P2P_DISE_CATEGORY_TELEPHONE		10
295 #define P2P_DISE_SUBCATEGORY_TELEPHONE_MAXVAL		5
296 #define P2P_DISE_CATEGORY_AUDIO			11
297 #define P2P_DISE_SUBCATEGORY_AUDIO_MAXVAL		6
298 
299 /* WiFi P2P IE's Device Info subelement */
300 BWL_PRE_PACKED_STRUCT struct wifi_p2p_devinfo_se_s {
301 	uint8	eltId;			/* SE ID: P2P_SEID_DEVINFO */
302 	uint8	len[2];			/* SE length not including eltId, len fields */
303 	uint8	mac[6];			/* P2P Device MAC address */
304 	uint16	wps_cfg_meths;		/* Config Methods: reg_prototlv.h WPS_CONFMET_* */
305 	uint8	pri_devtype[8];		/* Primary Device Type */
306 } BWL_POST_PACKED_STRUCT;
307 typedef struct wifi_p2p_devinfo_se_s wifi_p2p_devinfo_se_t;
308 
309 #define P2P_DEV_TYPE_LEN	8
310 
311 /* WiFi P2P IE's Group Info subelement Client Info Descriptor */
312 BWL_PRE_PACKED_STRUCT struct wifi_p2p_cid_fixed_s {
313 	uint8	len;
314 	uint8	devaddr[ETHER_ADDR_LEN];	/* P2P Device Address */
315 	uint8	ifaddr[ETHER_ADDR_LEN];		/* P2P Interface Address */
316 	uint8	devcap;				/* Device Capability */
317 	uint8	cfg_meths[2];			/* Config Methods: reg_prototlv.h WPS_CONFMET_* */
318 	uint8	pridt[P2P_DEV_TYPE_LEN];	/* Primary Device Type */
319 	uint8	secdts;				/* Number of Secondary Device Types */
320 } BWL_POST_PACKED_STRUCT;
321 typedef struct wifi_p2p_cid_fixed_s wifi_p2p_cid_fixed_t;
322 
323 /* WiFi P2P IE's Device ID subelement */
324 BWL_PRE_PACKED_STRUCT struct wifi_p2p_devid_se_s {
325 	uint8	eltId;
326 	uint8	len[2];
327 	struct ether_addr	addr;			/* P2P Device MAC address */
328 } BWL_POST_PACKED_STRUCT;
329 typedef struct wifi_p2p_devid_se_s wifi_p2p_devid_se_t;
330 
331 /* WiFi P2P IE subelement: P2P Manageability */
332 BWL_PRE_PACKED_STRUCT struct wifi_p2p_mgbt_se_s {
333 	uint8	eltId;		/* SE ID: P2P_SEID_P2P_MGBTY */
334 	uint8	len[2];		/* SE length not including eltId, len fields */
335 	uint8	mg_bitmap;	/* manageability bitmap */
336 } BWL_POST_PACKED_STRUCT;
337 typedef struct wifi_p2p_mgbt_se_s wifi_p2p_mgbt_se_t;
338 /* mg_bitmap field bit values */
339 #define P2P_MGBTSE_P2PDEVMGMT_FLAG   0x1 /* AP supports Managed P2P Device */
340 
341 /* WiFi P2P IE subelement: Group Info */
342 BWL_PRE_PACKED_STRUCT struct wifi_p2p_grpinfo_se_s {
343 	uint8	eltId;			/* SE ID: P2P_SEID_GROUP_INFO */
344 	uint8	len[2];			/* SE length not including eltId, len fields */
345 } BWL_POST_PACKED_STRUCT;
346 typedef struct wifi_p2p_grpinfo_se_s wifi_p2p_grpinfo_se_t;
347 
348 /* WiFi IE subelement: Operating Channel */
349 BWL_PRE_PACKED_STRUCT struct wifi_p2p_op_channel_se_s {
350 	uint8	eltId;		/* SE ID: P2P_SEID_OP_CHANNEL */
351 	uint8	len[2];		/* SE length not including eltId, len fields */
352 	uint8	country[3];	/* Country String */
353 	uint8	op_class;	/* Operating Class */
354 	uint8	channel;	/* Channel */
355 } BWL_POST_PACKED_STRUCT;
356 typedef struct wifi_p2p_op_channel_se_s wifi_p2p_op_channel_se_t;
357 
358 /* WiFi IE subelement: INVITATION FLAGS */
359 BWL_PRE_PACKED_STRUCT struct wifi_p2p_invite_flags_se_s {
360 	uint8	eltId;		/* SE ID: P2P_SEID_INVITE_FLAGS */
361 	uint8	len[2];		/* SE length not including eltId, len fields */
362 	uint8	flags;		/* Flags */
363 } BWL_POST_PACKED_STRUCT;
364 typedef struct wifi_p2p_invite_flags_se_s wifi_p2p_invite_flags_se_t;
365 
366 /* WiFi P2P IE subelement: Service Hash */
367 BWL_PRE_PACKED_STRUCT struct wifi_p2p_serv_hash_se_s {
368 	uint8	eltId;			/* SE ID: P2P_SEID_SERVICE_HASH */
369 	uint8	len[2];			/* SE length not including eltId, len fields
370 					 * in multiple of 6 Bytes
371 					*/
372 	uint8	hash[1];		/* Variable length - SHA256 hash of
373 					 * service names (can be more than one hashes)
374 					*/
375 } BWL_POST_PACKED_STRUCT;
376 typedef struct wifi_p2p_serv_hash_se_s wifi_p2p_serv_hash_se_t;
377 
378 /* WiFi P2P IE subelement: Service Instance Data */
379 BWL_PRE_PACKED_STRUCT struct wifi_p2p_serv_inst_data_se_s {
380 	uint8	eltId;			/* SE ID: P2P_SEID_SESSION */
381 	uint8	len[2];			/* SE length not including eltId, len */
382 	uint8	ssn_info[1];		/* Variable length - Session information as specified by
383 					 * the service layer, type matches serv. name
384 					*/
385 } BWL_POST_PACKED_STRUCT;
386 typedef struct wifi_p2p_serv_inst_data_se_s wifi_p2p_serv_inst_data_se_t;
387 
388 /* WiFi P2P IE subelement: Connection capability */
389 BWL_PRE_PACKED_STRUCT struct wifi_p2p_conn_cap_data_se_s {
390 	uint8	eltId;			/* SE ID: P2P_SEID_CONNECT_CAP */
391 	uint8	len[2];			/* SE length not including eltId, len */
392 	uint8	conn_cap;		/* 1byte capability as specified by the
393 					 * service layer, valid bitmask/values
394 					*/
395 } BWL_POST_PACKED_STRUCT;
396 typedef struct wifi_p2p_conn_cap_data_se_s wifi_p2p_conn_cap_data_se_t;
397 
398 /* WiFi P2P IE subelement: Advertisement ID */
399 BWL_PRE_PACKED_STRUCT struct wifi_p2p_advt_id_se_s {
400 	uint8	eltId;			/* SE ID: P2P_SEID_ADVERTISE_ID */
401 	uint8	len[2];			/* SE length not including eltId, len fixed 4 Bytes */
402 	uint8	advt_id[4];		/* 4byte Advertisement ID of the peer device sent in
403 					 * PROV Disc in Network byte order
404 					*/
405 	uint8	advt_mac[6];			/* P2P device address of the service advertiser */
406 } BWL_POST_PACKED_STRUCT;
407 typedef struct wifi_p2p_advt_id_se_s wifi_p2p_advt_id_se_t;
408 
409 /* WiFi P2P IE subelement: Advertise Service Hash */
410 BWL_PRE_PACKED_STRUCT struct wifi_p2p_adv_serv_info_s {
411 	uint8	advt_id[4];		/* SE Advertise ID for the service */
412 	uint16	nw_cfg_method;	/* SE Network Config method for the service */
413 	uint8	serv_name_len;	/* SE length of the service name */
414 	uint8	serv_name[1];	/* Variable length service name field */
415 } BWL_POST_PACKED_STRUCT;
416 typedef struct wifi_p2p_adv_serv_info_s wifi_p2p_adv_serv_info_t;
417 
418 /* WiFi P2P IE subelement: Advertise Service Hash */
419 BWL_PRE_PACKED_STRUCT struct wifi_p2p_advt_serv_se_s {
420 	uint8	eltId;			/* SE ID: P2P_SEID_ADVERTISE_SERVICE */
421 	uint8	len[2];			/* SE length not including eltId, len fields mutiple len of
422 					 * wifi_p2p_adv_serv_info_t entries
423 					*/
424 	wifi_p2p_adv_serv_info_t	p_advt_serv_info[1]; /* Variable length
425 								of multiple instances
426 								of the advertise service info
427 								*/
428 } BWL_POST_PACKED_STRUCT;
429 typedef struct wifi_p2p_advt_serv_se_s wifi_p2p_advt_serv_se_t;
430 
431 /* WiFi P2P IE subelement: Session ID */
432 BWL_PRE_PACKED_STRUCT struct wifi_p2p_ssn_id_se_s {
433 	uint8	eltId;			/* SE ID: P2P_SEID_SESSION_ID */
434 	uint8	len[2];			/* SE length not including eltId, len fixed 4 Bytes */
435 	uint8	ssn_id[4];		/* 4byte Session ID of the peer device sent in
436 							 * PROV Disc in Network byte order
437 							 */
438 	uint8	ssn_mac[6];		/* P2P device address of the seeker - session mac */
439 } BWL_POST_PACKED_STRUCT;
440 typedef struct wifi_p2p_ssn_id_se_s wifi_p2p_ssn_id_se_t;
441 
442 #define P2P_ADVT_SERV_SE_FIXED_LEN	3	/* Includes only the element ID and len */
443 #define P2P_ADVT_SERV_INFO_FIXED_LEN	7	/* Per ADV Service Instance advt_id +
444 						 * nw_config_method + serv_name_len
445 						 */
446 
447 /* WiFi P2P Action Frame */
448 BWL_PRE_PACKED_STRUCT struct wifi_p2p_action_frame {
449 	uint8	category;	/* P2P_AF_CATEGORY */
450 	uint8	OUI[3];		/* OUI - P2P_OUI */
451 	uint8	type;		/* OUI Type - P2P_VER */
452 	uint8	subtype;	/* OUI Subtype - P2P_AF_* */
453 	uint8	dialog_token;	/* nonzero, identifies req/resp tranaction */
454 	uint8	elts[1];	/* Variable length information elements.  Max size =
455 				 * ACTION_FRAME_SIZE - sizeof(this structure) - 1
456 				 */
457 } BWL_POST_PACKED_STRUCT;
458 typedef struct wifi_p2p_action_frame wifi_p2p_action_frame_t;
459 #define P2P_AF_CATEGORY		0x7f
460 
461 #define P2P_AF_FIXED_LEN	7
462 
463 /* WiFi P2P Action Frame OUI Subtypes */
464 #define P2P_AF_NOTICE_OF_ABSENCE	0	/* Notice of Absence */
465 #define P2P_AF_PRESENCE_REQ		1	/* P2P Presence Request */
466 #define P2P_AF_PRESENCE_RSP		2	/* P2P Presence Response */
467 #define P2P_AF_GO_DISC_REQ		3	/* GO Discoverability Request */
468 
469 /* WiFi P2P Public Action Frame */
470 BWL_PRE_PACKED_STRUCT struct wifi_p2p_pub_act_frame {
471 	uint8	category;	/* P2P_PUB_AF_CATEGORY */
472 	uint8	action;		/* P2P_PUB_AF_ACTION */
473 	uint8	oui[3];		/* P2P_OUI */
474 	uint8	oui_type;	/* OUI type - P2P_VER */
475 	uint8	subtype;	/* OUI subtype - P2P_TYPE_* */
476 	uint8	dialog_token;	/* nonzero, identifies req/rsp transaction */
477 	uint8	elts[1];	/* Variable length information elements.  Max size =
478 				 * ACTION_FRAME_SIZE - sizeof(this structure) - 1
479 				 */
480 } BWL_POST_PACKED_STRUCT;
481 typedef struct wifi_p2p_pub_act_frame wifi_p2p_pub_act_frame_t;
482 #define P2P_PUB_AF_FIXED_LEN	8
483 #define P2P_PUB_AF_CATEGORY	0x04
484 #define P2P_PUB_AF_ACTION	0x09
485 
486 /* WiFi P2P Public Action Frame OUI Subtypes */
487 #define P2P_PAF_GON_REQ		0	/* Group Owner Negotiation Req */
488 #define P2P_PAF_GON_RSP		1	/* Group Owner Negotiation Rsp */
489 #define P2P_PAF_GON_CONF	2	/* Group Owner Negotiation Confirm */
490 #define P2P_PAF_INVITE_REQ	3	/* P2P Invitation Request */
491 #define P2P_PAF_INVITE_RSP	4	/* P2P Invitation Response */
492 #define P2P_PAF_DEVDIS_REQ	5	/* Device Discoverability Request */
493 #define P2P_PAF_DEVDIS_RSP	6	/* Device Discoverability Response */
494 #define P2P_PAF_PROVDIS_REQ	7	/* Provision Discovery Request */
495 #define P2P_PAF_PROVDIS_RSP	8	/* Provision Discovery Response */
496 #define P2P_PAF_SUBTYPE_INVALID	255	/* Invalid Subtype */
497 
498 /* TODO: Stop using these obsolete aliases for P2P_PAF_GON_* */
499 #define P2P_TYPE_MNREQ		P2P_PAF_GON_REQ
500 #define P2P_TYPE_MNRSP		P2P_PAF_GON_RSP
501 #define P2P_TYPE_MNCONF		P2P_PAF_GON_CONF
502 
503 /* WiFi P2P IE subelement: Notice of Absence */
504 BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_desc {
505 	uint8	cnt_type;	/* Count/Type */
506 	uint32	duration;	/* Duration */
507 	uint32	interval;	/* Interval */
508 	uint32	start;		/* Start Time */
509 } BWL_POST_PACKED_STRUCT;
510 typedef struct wifi_p2p_noa_desc wifi_p2p_noa_desc_t;
511 
512 BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_se {
513 	uint8	eltId;		/* Subelement ID */
514 	uint8	len[2];		/* Length */
515 	uint8	index;		/* Index */
516 	uint8	ops_ctw_parms;	/* CTWindow and OppPS Parameters */
517 	wifi_p2p_noa_desc_t	desc[1];	/* Notice of Absence Descriptor(s) */
518 } BWL_POST_PACKED_STRUCT;
519 typedef struct wifi_p2p_noa_se wifi_p2p_noa_se_t;
520 
521 #define P2P_NOA_SE_FIXED_LEN	5
522 
523 #define P2P_NOA_SE_MAX_DESC	2	/* max NoA descriptors in presence request */
524 
525 /* cnt_type field values */
526 #define P2P_NOA_DESC_CNT_RESERVED	0	/* reserved and should not be used */
527 #define P2P_NOA_DESC_CNT_REPEAT		255	/* continuous schedule */
528 #define P2P_NOA_DESC_TYPE_PREFERRED	1	/* preferred values */
529 #define P2P_NOA_DESC_TYPE_ACCEPTABLE	2	/* acceptable limits */
530 
531 /* ctw_ops_parms field values */
532 #define P2P_NOA_CTW_MASK	0x7f
533 #define P2P_NOA_OPS_MASK	0x80
534 #define P2P_NOA_OPS_SHIFT	7
535 
536 #define P2P_CTW_MIN	10	/* minimum 10TU */
537 
538 /*
539  * P2P Service Discovery related
540  */
541 #define	P2PSD_ACTION_CATEGORY		0x04
542 				/* Public action frame */
543 #define	P2PSD_ACTION_ID_GAS_IREQ	0x0a
544 				/* Action value for GAS Initial Request AF */
545 #define	P2PSD_ACTION_ID_GAS_IRESP	0x0b
546 				/* Action value for GAS Initial Response AF */
547 #define	P2PSD_ACTION_ID_GAS_CREQ	0x0c
548 				/* Action value for GAS Comeback Request AF */
549 #define	P2PSD_ACTION_ID_GAS_CRESP	0x0d
550 				/* Action value for GAS Comeback Response AF */
551 #define P2PSD_AD_EID				0x6c
552 				/* Advertisement Protocol IE ID */
553 #define P2PSD_ADP_TUPLE_QLMT_PAMEBI	0x00
554 				/* Query Response Length Limit 7 bits plus PAME-BI 1 bit */
555 #define P2PSD_ADP_PROTO_ID			0x00
556 				/* Advertisement Protocol ID. Always 0 for P2P SD */
557 #define P2PSD_GAS_OUI				P2P_OUI
558 				/* WFA OUI */
559 #define P2PSD_GAS_OUI_SUBTYPE		P2P_VER
560 				/* OUI Subtype for GAS IE */
561 #define P2PSD_GAS_NQP_INFOID		0xDDDD
562 				/* NQP Query Info ID: 56797 */
563 #define P2PSD_GAS_COMEBACKDEALY		0x00
564 				/* Not used in the Native GAS protocol */
565 
566 /* Service Protocol Type */
567 typedef enum p2psd_svc_protype {
568 	SVC_RPOTYPE_ALL = 0,
569 	SVC_RPOTYPE_BONJOUR = 1,
570 	SVC_RPOTYPE_UPNP = 2,
571 	SVC_RPOTYPE_WSD = 3,
572 	SVC_RPOTYPE_WFDS = 11,
573 	SVC_RPOTYPE_VENDOR = 255
574 } p2psd_svc_protype_t;
575 
576 /* Service Discovery response status code */
577 typedef enum {
578 	P2PSD_RESP_STATUS_SUCCESS = 0,
579 	P2PSD_RESP_STATUS_PROTYPE_NA = 1,
580 	P2PSD_RESP_STATUS_DATA_NA = 2,
581 	P2PSD_RESP_STATUS_BAD_REQUEST = 3
582 } p2psd_resp_status_t;
583 
584 /* Advertisement Protocol IE tuple field */
585 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_tpl {
586 	uint8	llm_pamebi;	/* Query Response Length Limit bit 0-6, set to 0 plus
587 				* Pre-Associated Message Exchange BSSID Independent bit 7, set to 0
588 				*/
589 	uint8	adp_id;		/* Advertisement Protocol ID: 0 for NQP Native Query Protocol */
590 } BWL_POST_PACKED_STRUCT;
591 typedef struct wifi_p2psd_adp_tpl wifi_p2psd_adp_tpl_t;
592 
593 /* Advertisement Protocol IE */
594 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_ie {
595 	uint8	id;		/* IE ID: 0x6c - 108 */
596 	uint8	len;	/* IE length */
597 	wifi_p2psd_adp_tpl_t adp_tpl;  /* Advertisement Protocol Tuple field. Only one
598 				* tuple is defined for P2P Service Discovery
599 				*/
600 } BWL_POST_PACKED_STRUCT;
601 typedef struct wifi_p2psd_adp_ie wifi_p2psd_adp_ie_t;
602 
603 /* NQP Vendor-specific Content */
604 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_nqp_query_vsc {
605 	uint8	oui_subtype;	/* OUI Subtype: 0x09 */
606 	uint16	svc_updi;		/* Service Update Indicator */
607 	uint8	svc_tlvs[1];	/* wifi_p2psd_qreq_tlv_t type for service request,
608 				* wifi_p2psd_qresp_tlv_t type for service response
609 				*/
610 } BWL_POST_PACKED_STRUCT;
611 typedef struct wifi_p2psd_nqp_query_vsc wifi_p2psd_nqp_query_vsc_t;
612 
613 /* Service Request TLV */
614 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_tlv {
615 	uint16	len;			/* Length: 5 plus size of Query Data */
616 	uint8	svc_prot;		/* Service Protocol Type */
617 	uint8	svc_tscid;		/* Service Transaction ID */
618 	uint8	query_data[1];	/* Query Data, passed in from above Layer 2 */
619 } BWL_POST_PACKED_STRUCT;
620 typedef struct wifi_p2psd_qreq_tlv wifi_p2psd_qreq_tlv_t;
621 
622 /* Query Request Frame, defined in generic format, instead of NQP specific */
623 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_frame {
624 	uint16	info_id;	/* Info ID: 0xDDDD */
625 	uint16	len;		/* Length of service request TLV, 5 plus the size of request data */
626 	uint8	oui[3];		/* WFA OUI: 0x0050F2 */
627 	uint8	qreq_vsc[1]; /* Vendor-specific Content: wifi_p2psd_nqp_query_vsc_t type for NQP */
628 
629 } BWL_POST_PACKED_STRUCT;
630 typedef struct wifi_p2psd_qreq_frame wifi_p2psd_qreq_frame_t;
631 
632 /* GAS Initial Request AF body, "elts" in wifi_p2p_pub_act_frame */
633 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_ireq_frame {
634 	wifi_p2psd_adp_ie_t		adp_ie;		/* Advertisement Protocol IE */
635 	uint16					qreq_len;	/* Query Request Length */
636 	uint8	qreq_frm[1];	/* Query Request Frame wifi_p2psd_qreq_frame_t */
637 } BWL_POST_PACKED_STRUCT;
638 typedef struct wifi_p2psd_gas_ireq_frame wifi_p2psd_gas_ireq_frame_t;
639 
640 /* Service Response TLV */
641 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_tlv {
642 	uint16	len;				/* Length: 5 plus size of Query Data */
643 	uint8	svc_prot;			/* Service Protocol Type */
644 	uint8	svc_tscid;			/* Service Transaction ID */
645 	uint8	status;				/* Value defined in Table 57 of P2P spec. */
646 	uint8	query_data[1];		/* Response Data, passed in from above Layer 2 */
647 } BWL_POST_PACKED_STRUCT;
648 typedef struct wifi_p2psd_qresp_tlv wifi_p2psd_qresp_tlv_t;
649 
650 /* Query Response Frame, defined in generic format, instead of NQP specific */
651 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_frame {
652 	uint16	info_id;	/* Info ID: 0xDDDD */
653 	uint16	len;		/* Lenth of service response TLV, 6 plus the size of resp data */
654 	uint8	oui[3];		/* WFA OUI: 0x0050F2 */
655 	uint8	qresp_vsc[1]; /* Vendor-specific Content: wifi_p2psd_qresp_tlv_t type for NQP */
656 
657 } BWL_POST_PACKED_STRUCT;
658 typedef struct wifi_p2psd_qresp_frame wifi_p2psd_qresp_frame_t;
659 
660 /* GAS Initial Response AF body, "elts" in wifi_p2p_pub_act_frame */
661 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_iresp_frame {
662 	uint16	status;			/* Value defined in Table 7-23 of IEEE P802.11u */
663 	uint16	cb_delay;		/* GAS Comeback Delay */
664 	wifi_p2psd_adp_ie_t	adp_ie;		/* Advertisement Protocol IE */
665 	uint16		qresp_len;	/* Query Response Length */
666 	uint8	qresp_frm[1];	/* Query Response Frame wifi_p2psd_qresp_frame_t */
667 } BWL_POST_PACKED_STRUCT;
668 typedef struct wifi_p2psd_gas_iresp_frame wifi_p2psd_gas_iresp_frame_t;
669 
670 /* GAS Comeback Response AF body, "elts" in wifi_p2p_pub_act_frame */
671 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_cresp_frame {
672 	uint16	status;			/* Value defined in Table 7-23 of IEEE P802.11u */
673 	uint8	fragment_id;	/* Fragmentation ID */
674 	uint16	cb_delay;		/* GAS Comeback Delay */
675 	wifi_p2psd_adp_ie_t	adp_ie;		/* Advertisement Protocol IE */
676 	uint16	qresp_len;		/* Query Response Length */
677 	uint8	qresp_frm[1];	/* Query Response Frame wifi_p2psd_qresp_frame_t */
678 } BWL_POST_PACKED_STRUCT;
679 typedef struct wifi_p2psd_gas_cresp_frame wifi_p2psd_gas_cresp_frame_t;
680 
681 /* Wi-Fi GAS Public Action Frame */
682 BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_pub_act_frame {
683 	uint8	category;		/* 0x04 Public Action Frame */
684 	uint8	action;			/* 0x6c Advertisement Protocol */
685 	uint8	dialog_token;	/* nonzero, identifies req/rsp transaction */
686 	uint8	query_data[1];	/* Query Data. wifi_p2psd_gas_ireq_frame_t
687 					 * or wifi_p2psd_gas_iresp_frame_t format
688 					 */
689 } BWL_POST_PACKED_STRUCT;
690 typedef struct wifi_p2psd_gas_pub_act_frame wifi_p2psd_gas_pub_act_frame_t;
691 
692 /* This marks the end of a packed structure section. */
693 #include <packed_section_end.h>
694 
695 #endif /* _P2P_H_ */
696