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