1/*
2 * Copyright (C) 1999-2012, Broadcom Corporation
3 *
4 *      Unless you and Broadcom execute a separate written software license
5 * agreement governing use of this software, this software is licensed to you
6 * under the terms of the GNU General Public License version 2 (the "GPL"),
7 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
8 * following added to such license:
9 *
10 *      As a special exception, the copyright holders of this software give you
11 * permission to link this software with independent modules, and to copy and
12 * distribute the resulting executable under terms of your choice, provided that
13 * you also meet, for each linked independent module, the terms and conditions of
14 * the license of that module.  An independent module is a module which is not
15 * derived from this software.  The special exception does not apply to any
16 * modifications of the software.
17 *
18 *      Notwithstanding the above, under no circumstances may you combine this
19 * software in any way with any other Broadcom software provided under a license
20 * other than the GPL, without Broadcom's express prior written consent.
21 *
22 * Fundamental types and constants relating to WFA P2P (aka WiFi Direct)
23 *
24 * $Id: p2p.h 326276 2012-04-06 23:16:42Z $
25 */
26
27#ifndef _P2P_H_
28#define _P2P_H_
29
30#ifndef _TYPEDEFS_H_
31#include <typedefs.h>
32#endif
33#include <wlioctl.h>
34#include <proto/802.11.h>
35
36
37#include <packed_section_start.h>
38
39
40
41#define P2P_OUI			WFA_OUI
42#define P2P_VER			WFA_OUI_TYPE_P2P
43
44#define P2P_IE_ID		0xdd
45
46
47BWL_PRE_PACKED_STRUCT struct wifi_p2p_ie {
48	uint8	id;
49	uint8	len;
50	uint8	OUI[3];
51	uint8	oui_type;
52	uint8	subelts[1];
53} BWL_POST_PACKED_STRUCT;
54typedef struct wifi_p2p_ie wifi_p2p_ie_t;
55
56#define P2P_IE_FIXED_LEN	6
57
58#define P2P_ATTR_ID_OFF		0
59#define P2P_ATTR_LEN_OFF	1
60#define P2P_ATTR_DATA_OFF	3
61
62#define P2P_ATTR_ID_LEN		1
63#define P2P_ATTR_LEN_LEN	2
64#define P2P_ATTR_HDR_LEN	3
65
66
67#define P2P_SEID_STATUS			0
68#define P2P_SEID_MINOR_RC		1
69#define P2P_SEID_P2P_INFO		2
70#define P2P_SEID_DEV_ID			3
71#define P2P_SEID_INTENT			4
72#define P2P_SEID_CFG_TIMEOUT		5
73#define P2P_SEID_CHANNEL		6
74#define P2P_SEID_GRP_BSSID		7
75#define P2P_SEID_XT_TIMING		8
76#define P2P_SEID_INTINTADDR		9
77#define P2P_SEID_P2P_MGBTY		10
78#define P2P_SEID_CHAN_LIST		11
79#define P2P_SEID_ABSENCE		12
80#define P2P_SEID_DEV_INFO		13
81#define P2P_SEID_GROUP_INFO		14
82#define P2P_SEID_GROUP_ID		15
83#define P2P_SEID_P2P_IF			16
84#define P2P_SEID_OP_CHANNEL		17
85#define P2P_SEID_INVITE_FLAGS		18
86#define P2P_SEID_VNDR			221
87
88#define P2P_SE_VS_ID_SERVICES	0x1b
89
90
91
92BWL_PRE_PACKED_STRUCT struct wifi_p2p_info_se_s {
93	uint8	eltId;
94	uint8	len[2];
95	uint8	dev;
96	uint8	group;
97} BWL_POST_PACKED_STRUCT;
98typedef struct wifi_p2p_info_se_s wifi_p2p_info_se_t;
99
100
101#define P2P_CAPSE_DEV_SERVICE_DIS	0x1
102#define P2P_CAPSE_DEV_CLIENT_DIS	0x2
103#define P2P_CAPSE_DEV_CONCURRENT	0x4
104#define P2P_CAPSE_DEV_INFRA_MAN		0x8
105#define P2P_CAPSE_DEV_LIMIT			0x10
106#define P2P_CAPSE_INVITE_PROC		0x20
107
108
109#define P2P_CAPSE_GRP_OWNER			0x1
110#define P2P_CAPSE_PERSIST_GRP		0x2
111#define P2P_CAPSE_GRP_LIMIT			0x4
112#define P2P_CAPSE_GRP_INTRA_BSS		0x8
113#define P2P_CAPSE_GRP_X_CONNECT		0x10
114#define P2P_CAPSE_GRP_PERSISTENT	0x20
115#define P2P_CAPSE_GRP_FORMATION		0x40
116
117
118
119BWL_PRE_PACKED_STRUCT struct wifi_p2p_intent_se_s {
120	uint8	eltId;
121	uint8	len[2];
122	uint8	intent;
123} BWL_POST_PACKED_STRUCT;
124typedef struct wifi_p2p_intent_se_s wifi_p2p_intent_se_t;
125
126
127BWL_PRE_PACKED_STRUCT struct wifi_p2p_cfg_tmo_se_s {
128	uint8	eltId;
129	uint8	len[2];
130	uint8	go_tmo;
131	uint8	client_tmo;
132} BWL_POST_PACKED_STRUCT;
133typedef struct wifi_p2p_cfg_tmo_se_s wifi_p2p_cfg_tmo_se_t;
134
135
136BWL_PRE_PACKED_STRUCT struct wifi_p2p_listen_channel_se_s {
137	uint8	eltId;
138	uint8	len[2];
139	uint8	country[3];
140	uint8	op_class;
141	uint8	channel;
142} BWL_POST_PACKED_STRUCT;
143typedef struct wifi_p2p_listen_channel_se_s wifi_p2p_listen_channel_se_t;
144
145
146BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_bssid_se_s {
147	uint8	eltId;
148	uint8	len[2];
149	uint8	mac[6];
150} BWL_POST_PACKED_STRUCT;
151typedef struct wifi_p2p_grp_bssid_se_s wifi_p2p_grp_bssid_se_t;
152
153
154BWL_PRE_PACKED_STRUCT struct wifi_p2p_grp_id_se_s {
155	uint8	eltId;
156	uint8	len[2];
157	uint8	mac[6];
158	uint8	ssid[1];
159} BWL_POST_PACKED_STRUCT;
160typedef struct wifi_p2p_grp_id_se_s wifi_p2p_grp_id_se_t;
161
162
163BWL_PRE_PACKED_STRUCT struct wifi_p2p_intf_se_s {
164	uint8	eltId;
165	uint8	len[2];
166	uint8	mac[6];
167	uint8	ifaddrs;
168	uint8	ifaddr[1][6];
169} BWL_POST_PACKED_STRUCT;
170typedef struct wifi_p2p_intf_se_s wifi_p2p_intf_se_t;
171
172
173BWL_PRE_PACKED_STRUCT struct wifi_p2p_status_se_s {
174	uint8	eltId;
175	uint8	len[2];
176	uint8	status;
177} BWL_POST_PACKED_STRUCT;
178typedef struct wifi_p2p_status_se_s wifi_p2p_status_se_t;
179
180
181#define P2P_STATSE_SUCCESS			0
182
183#define P2P_STATSE_FAIL_INFO_CURR_UNAVAIL	1
184
185#define P2P_STATSE_PASSED_UP			P2P_STATSE_FAIL_INFO_CURR_UNAVAIL
186
187#define P2P_STATSE_FAIL_INCOMPAT_PARAMS		2
188
189#define P2P_STATSE_FAIL_LIMIT_REACHED		3
190
191#define P2P_STATSE_FAIL_INVALID_PARAMS		4
192
193#define P2P_STATSE_FAIL_UNABLE_TO_ACCOM		5
194
195#define P2P_STATSE_FAIL_PROTO_ERROR		6
196
197#define P2P_STATSE_FAIL_NO_COMMON_CHAN		7
198
199#define P2P_STATSE_FAIL_UNKNOWN_GROUP		8
200
201#define P2P_STATSE_FAIL_INTENT			9
202
203#define P2P_STATSE_FAIL_INCOMPAT_PROVIS		10
204
205#define P2P_STATSE_FAIL_USER_REJECT		11
206
207
208
209BWL_PRE_PACKED_STRUCT struct wifi_p2p_ext_se_s {
210	uint8	eltId;
211	uint8	len[2];
212	uint8	avail[2];
213	uint8	interval[2];
214} BWL_POST_PACKED_STRUCT;
215typedef struct wifi_p2p_ext_se_s wifi_p2p_ext_se_t;
216
217#define P2P_EXT_MIN	10
218
219
220BWL_PRE_PACKED_STRUCT struct wifi_p2p_intintad_se_s {
221	uint8	eltId;
222	uint8	len[2];
223	uint8	mac[6];
224} BWL_POST_PACKED_STRUCT;
225typedef struct wifi_p2p_intintad_se_s wifi_p2p_intintad_se_t;
226
227
228BWL_PRE_PACKED_STRUCT struct wifi_p2p_channel_se_s {
229	uint8	eltId;
230	uint8	len[2];
231	uint8	band;
232	uint8	channel;
233} BWL_POST_PACKED_STRUCT;
234typedef struct wifi_p2p_channel_se_s wifi_p2p_channel_se_t;
235
236
237
238BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_entry_s {
239	uint8	band;
240	uint8	num_channels;
241	uint8	channels[WL_NUMCHANNELS];
242} BWL_POST_PACKED_STRUCT;
243typedef struct wifi_p2p_chanlist_entry_s wifi_p2p_chanlist_entry_t;
244#define WIFI_P2P_CHANLIST_SE_MAX_ENTRIES 2
245
246
247BWL_PRE_PACKED_STRUCT struct wifi_p2p_chanlist_se_s {
248	uint8	eltId;
249	uint8	len[2];
250	uint8	country[3];
251	uint8	num_entries;
252	wifi_p2p_chanlist_entry_t	entries[WIFI_P2P_CHANLIST_SE_MAX_ENTRIES];
253
254} BWL_POST_PACKED_STRUCT;
255typedef struct wifi_p2p_chanlist_se_s wifi_p2p_chanlist_se_t;
256
257
258BWL_PRE_PACKED_STRUCT struct wifi_p2p_pri_devtype_s {
259	uint16	cat_id;
260	uint8	OUI[3];
261	uint8	oui_type;
262	uint16	sub_cat_id;
263} BWL_POST_PACKED_STRUCT;
264typedef struct wifi_p2p_pri_devtype_s wifi_p2p_pri_devtype_t;
265
266
267BWL_PRE_PACKED_STRUCT struct wifi_p2p_devinfo_se_s {
268	uint8	eltId;
269	uint8	len[2];
270	uint8	mac[6];
271	uint16	wps_cfg_meths;
272	uint8	pri_devtype[8];
273} BWL_POST_PACKED_STRUCT;
274typedef struct wifi_p2p_devinfo_se_s wifi_p2p_devinfo_se_t;
275
276#define P2P_DEV_TYPE_LEN	8
277
278
279BWL_PRE_PACKED_STRUCT struct wifi_p2p_cid_fixed_s {
280	uint8	len;
281	uint8	devaddr[ETHER_ADDR_LEN];
282	uint8	ifaddr[ETHER_ADDR_LEN];
283	uint8	devcap;
284	uint8	cfg_meths[2];
285	uint8	pridt[P2P_DEV_TYPE_LEN];
286	uint8	secdts;
287} BWL_POST_PACKED_STRUCT;
288typedef struct wifi_p2p_cid_fixed_s wifi_p2p_cid_fixed_t;
289
290
291BWL_PRE_PACKED_STRUCT struct wifi_p2p_devid_se_s {
292	uint8	eltId;
293	uint8	len[2];
294	struct ether_addr	addr;
295} BWL_POST_PACKED_STRUCT;
296typedef struct wifi_p2p_devid_se_s wifi_p2p_devid_se_t;
297
298
299BWL_PRE_PACKED_STRUCT struct wifi_p2p_mgbt_se_s {
300	uint8	eltId;
301	uint8	len[2];
302	uint8	mg_bitmap;
303} BWL_POST_PACKED_STRUCT;
304typedef struct wifi_p2p_mgbt_se_s wifi_p2p_mgbt_se_t;
305
306#define P2P_MGBTSE_P2PDEVMGMT_FLAG   0x1
307
308
309BWL_PRE_PACKED_STRUCT struct wifi_p2p_grpinfo_se_s {
310	uint8	eltId;
311	uint8	len[2];
312} BWL_POST_PACKED_STRUCT;
313typedef struct wifi_p2p_grpinfo_se_s wifi_p2p_grpinfo_se_t;
314
315
316BWL_PRE_PACKED_STRUCT struct wifi_p2p_op_channel_se_s {
317	uint8	eltId;
318	uint8	len[2];
319	uint8	country[3];
320	uint8	op_class;
321	uint8	channel;
322} BWL_POST_PACKED_STRUCT;
323typedef struct wifi_p2p_op_channel_se_s wifi_p2p_op_channel_se_t;
324
325
326BWL_PRE_PACKED_STRUCT struct wifi_p2p_invite_flags_se_s {
327	uint8	eltId;
328	uint8	len[2];
329	uint8	flags;
330} BWL_POST_PACKED_STRUCT;
331typedef struct wifi_p2p_invite_flags_se_s wifi_p2p_invite_flags_se_t;
332
333
334BWL_PRE_PACKED_STRUCT struct wifi_p2p_action_frame {
335	uint8	category;
336	uint8	OUI[3];
337	uint8	type;
338	uint8	subtype;
339	uint8	dialog_token;
340	uint8	elts[1];
341} BWL_POST_PACKED_STRUCT;
342typedef struct wifi_p2p_action_frame wifi_p2p_action_frame_t;
343#define P2P_AF_CATEGORY		0x7f
344
345#define P2P_AF_FIXED_LEN	7
346
347
348#define P2P_AF_NOTICE_OF_ABSENCE	0
349#define P2P_AF_PRESENCE_REQ		1
350#define P2P_AF_PRESENCE_RSP		2
351#define P2P_AF_GO_DISC_REQ		3
352
353
354
355BWL_PRE_PACKED_STRUCT struct wifi_p2p_pub_act_frame {
356	uint8	category;
357	uint8	action;
358	uint8	oui[3];
359	uint8	oui_type;
360	uint8	subtype;
361	uint8	dialog_token;
362	uint8	elts[1];
363} BWL_POST_PACKED_STRUCT;
364typedef struct wifi_p2p_pub_act_frame wifi_p2p_pub_act_frame_t;
365#define P2P_PUB_AF_FIXED_LEN	8
366#define P2P_PUB_AF_CATEGORY	0x04
367#define P2P_PUB_AF_ACTION	0x09
368
369
370#define P2P_PAF_GON_REQ		0
371#define P2P_PAF_GON_RSP		1
372#define P2P_PAF_GON_CONF	2
373#define P2P_PAF_INVITE_REQ	3
374#define P2P_PAF_INVITE_RSP	4
375#define P2P_PAF_DEVDIS_REQ	5
376#define P2P_PAF_DEVDIS_RSP	6
377#define P2P_PAF_PROVDIS_REQ	7
378#define P2P_PAF_PROVDIS_RSP	8
379#define P2P_PAF_SUBTYPE_INVALID	255	/* Invalid Subtype */
380
381#define P2P_TYPE_MNREQ		P2P_PAF_GON_REQ
382#define P2P_TYPE_MNRSP		P2P_PAF_GON_RSP
383#define P2P_TYPE_MNCONF		P2P_PAF_GON_CONF
384
385
386BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_desc {
387	uint8	cnt_type;
388	uint32	duration;
389	uint32	interval;
390	uint32	start;
391} BWL_POST_PACKED_STRUCT;
392typedef struct wifi_p2p_noa_desc wifi_p2p_noa_desc_t;
393
394BWL_PRE_PACKED_STRUCT struct wifi_p2p_noa_se {
395	uint8	eltId;
396	uint8	len[2];
397	uint8	index;
398	uint8	ops_ctw_parms;
399	wifi_p2p_noa_desc_t	desc[1];
400} BWL_POST_PACKED_STRUCT;
401typedef struct wifi_p2p_noa_se wifi_p2p_noa_se_t;
402
403#define P2P_NOA_SE_FIXED_LEN	5
404
405
406#define P2P_NOA_DESC_CNT_RESERVED	0
407#define P2P_NOA_DESC_CNT_REPEAT		255
408#define P2P_NOA_DESC_TYPE_PREFERRED	1
409#define P2P_NOA_DESC_TYPE_ACCEPTABLE	2
410
411
412#define P2P_NOA_CTW_MASK	0x7f
413#define P2P_NOA_OPS_MASK	0x80
414#define P2P_NOA_OPS_SHIFT	7
415
416#define P2P_CTW_MIN	10
417
418
419#define	P2PSD_ACTION_CATEGORY		0x04
420
421#define	P2PSD_ACTION_ID_GAS_IREQ	0x0a
422
423#define	P2PSD_ACTION_ID_GAS_IRESP	0x0b
424
425#define	P2PSD_ACTION_ID_GAS_CREQ	0x0c
426
427#define	P2PSD_ACTION_ID_GAS_CRESP	0x0d
428
429#define P2PSD_AD_EID				0x6c
430
431#define P2PSD_ADP_TUPLE_QLMT_PAMEBI	0x00
432
433#define P2PSD_ADP_PROTO_ID			0x00
434
435#define P2PSD_GAS_OUI				P2P_OUI
436
437#define P2PSD_GAS_OUI_SUBTYPE		P2P_VER
438
439#define P2PSD_GAS_NQP_INFOID		0xDDDD
440
441#define P2PSD_GAS_COMEBACKDEALY		0x00
442
443
444
445typedef enum p2psd_svc_protype {
446	SVC_RPOTYPE_ALL = 0,
447	SVC_RPOTYPE_BONJOUR = 1,
448	SVC_RPOTYPE_UPNP = 2,
449	SVC_RPOTYPE_WSD = 3,
450	SVC_RPOTYPE_VENDOR = 255
451} p2psd_svc_protype_t;
452
453
454typedef enum {
455	P2PSD_RESP_STATUS_SUCCESS = 0,
456	P2PSD_RESP_STATUS_PROTYPE_NA = 1,
457	P2PSD_RESP_STATUS_DATA_NA = 2,
458	P2PSD_RESP_STATUS_BAD_REQUEST = 3
459} p2psd_resp_status_t;
460
461
462BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_tpl {
463	uint8	llm_pamebi;
464	uint8	adp_id;
465} BWL_POST_PACKED_STRUCT;
466typedef struct wifi_p2psd_adp_tpl wifi_p2psd_adp_tpl_t;
467
468
469BWL_PRE_PACKED_STRUCT struct wifi_p2psd_adp_ie {
470	uint8	id;
471	uint8	len;
472	wifi_p2psd_adp_tpl_t adp_tpl;
473} BWL_POST_PACKED_STRUCT;
474typedef struct wifi_p2psd_adp_ie wifi_p2psd_adp_ie_t;
475
476
477BWL_PRE_PACKED_STRUCT struct wifi_p2psd_nqp_query_vsc {
478	uint8	oui_subtype;
479	uint16	svc_updi;
480	uint8	svc_tlvs[1];
481} BWL_POST_PACKED_STRUCT;
482typedef struct wifi_p2psd_nqp_query_vsc wifi_p2psd_nqp_query_vsc_t;
483
484
485BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_tlv {
486	uint16	len;
487	uint8	svc_prot;
488	uint8	svc_tscid;
489	uint8	query_data[1];
490} BWL_POST_PACKED_STRUCT;
491typedef struct wifi_p2psd_qreq_tlv wifi_p2psd_qreq_tlv_t;
492
493
494BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qreq_frame {
495	uint16	info_id;
496	uint16	len;
497	uint8	oui[3];
498	uint8	qreq_vsc[1];
499
500} BWL_POST_PACKED_STRUCT;
501typedef struct wifi_p2psd_qreq_frame wifi_p2psd_qreq_frame_t;
502
503
504BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_ireq_frame {
505	wifi_p2psd_adp_ie_t		adp_ie;
506	uint16					qreq_len;
507	uint8	qreq_frm[1];
508} BWL_POST_PACKED_STRUCT;
509typedef struct wifi_p2psd_gas_ireq_frame wifi_p2psd_gas_ireq_frame_t;
510
511
512BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_tlv {
513	uint16	len;
514	uint8	svc_prot;
515	uint8	svc_tscid;
516	uint8	status;
517	uint8	query_data[1];
518} BWL_POST_PACKED_STRUCT;
519typedef struct wifi_p2psd_qresp_tlv wifi_p2psd_qresp_tlv_t;
520
521
522BWL_PRE_PACKED_STRUCT struct wifi_p2psd_qresp_frame {
523	uint16	info_id;
524	uint16	len;
525	uint8	oui[3];
526	uint8	qresp_vsc[1];
527
528} BWL_POST_PACKED_STRUCT;
529typedef struct wifi_p2psd_qresp_frame wifi_p2psd_qresp_frame_t;
530
531
532BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_iresp_frame {
533	uint16	status;
534	uint16	cb_delay;
535	wifi_p2psd_adp_ie_t	adp_ie;
536	uint16		qresp_len;
537	uint8	qresp_frm[1];
538} BWL_POST_PACKED_STRUCT;
539typedef struct wifi_p2psd_gas_iresp_frame wifi_p2psd_gas_iresp_frame_t;
540
541
542BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_cresp_frame {
543	uint16	status;
544	uint8	fragment_id;
545	uint16	cb_delay;
546	wifi_p2psd_adp_ie_t	adp_ie;
547	uint16	qresp_len;
548	uint8	qresp_frm[1];
549} BWL_POST_PACKED_STRUCT;
550typedef struct wifi_p2psd_gas_cresp_frame wifi_p2psd_gas_cresp_frame_t;
551
552
553BWL_PRE_PACKED_STRUCT struct wifi_p2psd_gas_pub_act_frame {
554	uint8	category;
555	uint8	action;
556	uint8	dialog_token;
557	uint8	query_data[1];
558} BWL_POST_PACKED_STRUCT;
559typedef struct wifi_p2psd_gas_pub_act_frame wifi_p2psd_gas_pub_act_frame_t;
560
561
562#include <packed_section_end.h>
563
564#endif
565