xref: /linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h (revision daeccac2d5e7a6179ffff63e40b4a59bc3376a05)
1*daeccac2SArend van Spriel // SPDX-License-Identifier: ISC
205491d2cSKalle Valo /*
305491d2cSKalle Valo  * Copyright (c) 2012 Broadcom Corporation
405491d2cSKalle Valo  */
505491d2cSKalle Valo 
605491d2cSKalle Valo 
705491d2cSKalle Valo #ifndef FWEH_H_
805491d2cSKalle Valo #define FWEH_H_
905491d2cSKalle Valo 
1005491d2cSKalle Valo #include <asm/unaligned.h>
1105491d2cSKalle Valo #include <linux/skbuff.h>
1205491d2cSKalle Valo #include <linux/if_ether.h>
1305491d2cSKalle Valo #include <linux/if.h>
1405491d2cSKalle Valo 
1505491d2cSKalle Valo /* formward declarations */
1605491d2cSKalle Valo struct brcmf_pub;
1705491d2cSKalle Valo struct brcmf_if;
1805491d2cSKalle Valo struct brcmf_cfg80211_info;
1905491d2cSKalle Valo 
2005491d2cSKalle Valo /* list of firmware events */
2105491d2cSKalle Valo #define BRCMF_FWEH_EVENT_ENUM_DEFLIST \
2205491d2cSKalle Valo 	BRCMF_ENUM_DEF(SET_SSID, 0) \
2305491d2cSKalle Valo 	BRCMF_ENUM_DEF(JOIN, 1) \
2405491d2cSKalle Valo 	BRCMF_ENUM_DEF(START, 2) \
2505491d2cSKalle Valo 	BRCMF_ENUM_DEF(AUTH, 3) \
2605491d2cSKalle Valo 	BRCMF_ENUM_DEF(AUTH_IND, 4) \
2705491d2cSKalle Valo 	BRCMF_ENUM_DEF(DEAUTH, 5) \
2805491d2cSKalle Valo 	BRCMF_ENUM_DEF(DEAUTH_IND, 6) \
2905491d2cSKalle Valo 	BRCMF_ENUM_DEF(ASSOC, 7) \
3005491d2cSKalle Valo 	BRCMF_ENUM_DEF(ASSOC_IND, 8) \
3105491d2cSKalle Valo 	BRCMF_ENUM_DEF(REASSOC, 9) \
3205491d2cSKalle Valo 	BRCMF_ENUM_DEF(REASSOC_IND, 10) \
3305491d2cSKalle Valo 	BRCMF_ENUM_DEF(DISASSOC, 11) \
3405491d2cSKalle Valo 	BRCMF_ENUM_DEF(DISASSOC_IND, 12) \
3505491d2cSKalle Valo 	BRCMF_ENUM_DEF(QUIET_START, 13) \
3605491d2cSKalle Valo 	BRCMF_ENUM_DEF(QUIET_END, 14) \
3705491d2cSKalle Valo 	BRCMF_ENUM_DEF(BEACON_RX, 15) \
3805491d2cSKalle Valo 	BRCMF_ENUM_DEF(LINK, 16) \
3905491d2cSKalle Valo 	BRCMF_ENUM_DEF(MIC_ERROR, 17) \
4005491d2cSKalle Valo 	BRCMF_ENUM_DEF(NDIS_LINK, 18) \
4105491d2cSKalle Valo 	BRCMF_ENUM_DEF(ROAM, 19) \
4205491d2cSKalle Valo 	BRCMF_ENUM_DEF(TXFAIL, 20) \
4305491d2cSKalle Valo 	BRCMF_ENUM_DEF(PMKID_CACHE, 21) \
4405491d2cSKalle Valo 	BRCMF_ENUM_DEF(RETROGRADE_TSF, 22) \
4505491d2cSKalle Valo 	BRCMF_ENUM_DEF(PRUNE, 23) \
4605491d2cSKalle Valo 	BRCMF_ENUM_DEF(AUTOAUTH, 24) \
4705491d2cSKalle Valo 	BRCMF_ENUM_DEF(EAPOL_MSG, 25) \
4805491d2cSKalle Valo 	BRCMF_ENUM_DEF(SCAN_COMPLETE, 26) \
4905491d2cSKalle Valo 	BRCMF_ENUM_DEF(ADDTS_IND, 27) \
5005491d2cSKalle Valo 	BRCMF_ENUM_DEF(DELTS_IND, 28) \
5105491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCNSENT_IND, 29) \
5205491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCNRX_MSG, 30) \
5305491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCNLOST_MSG, 31) \
5405491d2cSKalle Valo 	BRCMF_ENUM_DEF(ROAM_PREP, 32) \
5505491d2cSKalle Valo 	BRCMF_ENUM_DEF(PFN_NET_FOUND, 33) \
5605491d2cSKalle Valo 	BRCMF_ENUM_DEF(PFN_NET_LOST, 34) \
5705491d2cSKalle Valo 	BRCMF_ENUM_DEF(RESET_COMPLETE, 35) \
5805491d2cSKalle Valo 	BRCMF_ENUM_DEF(JOIN_START, 36) \
5905491d2cSKalle Valo 	BRCMF_ENUM_DEF(ROAM_START, 37) \
6005491d2cSKalle Valo 	BRCMF_ENUM_DEF(ASSOC_START, 38) \
6105491d2cSKalle Valo 	BRCMF_ENUM_DEF(IBSS_ASSOC, 39) \
6205491d2cSKalle Valo 	BRCMF_ENUM_DEF(RADIO, 40) \
6305491d2cSKalle Valo 	BRCMF_ENUM_DEF(PSM_WATCHDOG, 41) \
6405491d2cSKalle Valo 	BRCMF_ENUM_DEF(PROBREQ_MSG, 44) \
6505491d2cSKalle Valo 	BRCMF_ENUM_DEF(SCAN_CONFIRM_IND, 45) \
6605491d2cSKalle Valo 	BRCMF_ENUM_DEF(PSK_SUP, 46) \
6705491d2cSKalle Valo 	BRCMF_ENUM_DEF(COUNTRY_CODE_CHANGED, 47) \
6805491d2cSKalle Valo 	BRCMF_ENUM_DEF(EXCEEDED_MEDIUM_TIME, 48) \
6905491d2cSKalle Valo 	BRCMF_ENUM_DEF(ICV_ERROR, 49) \
7005491d2cSKalle Valo 	BRCMF_ENUM_DEF(UNICAST_DECODE_ERROR, 50) \
7105491d2cSKalle Valo 	BRCMF_ENUM_DEF(MULTICAST_DECODE_ERROR, 51) \
7205491d2cSKalle Valo 	BRCMF_ENUM_DEF(TRACE, 52) \
7305491d2cSKalle Valo 	BRCMF_ENUM_DEF(IF, 54) \
7405491d2cSKalle Valo 	BRCMF_ENUM_DEF(P2P_DISC_LISTEN_COMPLETE, 55) \
7505491d2cSKalle Valo 	BRCMF_ENUM_DEF(RSSI, 56) \
7605491d2cSKalle Valo 	BRCMF_ENUM_DEF(EXTLOG_MSG, 58) \
7705491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME, 59) \
7805491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME_COMPLETE, 60) \
7905491d2cSKalle Valo 	BRCMF_ENUM_DEF(PRE_ASSOC_IND, 61) \
8005491d2cSKalle Valo 	BRCMF_ENUM_DEF(PRE_REASSOC_IND, 62) \
8105491d2cSKalle Valo 	BRCMF_ENUM_DEF(CHANNEL_ADOPTED, 63) \
8205491d2cSKalle Valo 	BRCMF_ENUM_DEF(AP_STARTED, 64) \
8305491d2cSKalle Valo 	BRCMF_ENUM_DEF(DFS_AP_STOP, 65) \
8405491d2cSKalle Valo 	BRCMF_ENUM_DEF(DFS_AP_RESUME, 66) \
8505491d2cSKalle Valo 	BRCMF_ENUM_DEF(ESCAN_RESULT, 69) \
8605491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME_OFF_CHAN_COMPLETE, 70) \
8705491d2cSKalle Valo 	BRCMF_ENUM_DEF(PROBERESP_MSG, 71) \
8805491d2cSKalle Valo 	BRCMF_ENUM_DEF(P2P_PROBEREQ_MSG, 72) \
8905491d2cSKalle Valo 	BRCMF_ENUM_DEF(DCS_REQUEST, 73) \
9005491d2cSKalle Valo 	BRCMF_ENUM_DEF(FIFO_CREDIT_MAP, 74) \
9105491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME_RX, 75) \
9205491d2cSKalle Valo 	BRCMF_ENUM_DEF(TDLS_PEER_EVENT, 92) \
9305491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCMC_CREDIT_SUPPORT, 127)
9405491d2cSKalle Valo 
9505491d2cSKalle Valo #define BRCMF_ENUM_DEF(id, val) \
9605491d2cSKalle Valo 	BRCMF_E_##id = (val),
9705491d2cSKalle Valo 
9805491d2cSKalle Valo /* firmware event codes sent by the dongle */
9905491d2cSKalle Valo enum brcmf_fweh_event_code {
10005491d2cSKalle Valo 	BRCMF_FWEH_EVENT_ENUM_DEFLIST
10105491d2cSKalle Valo 	/* this determines event mask length which must match
10205491d2cSKalle Valo 	 * minimum length check in device firmware so it is
10305491d2cSKalle Valo 	 * hard-coded here.
10405491d2cSKalle Valo 	 */
10505491d2cSKalle Valo 	BRCMF_E_LAST = 139
10605491d2cSKalle Valo };
10705491d2cSKalle Valo #undef BRCMF_ENUM_DEF
10805491d2cSKalle Valo 
10905491d2cSKalle Valo #define BRCMF_EVENTING_MASK_LEN		DIV_ROUND_UP(BRCMF_E_LAST, 8)
11005491d2cSKalle Valo 
11105491d2cSKalle Valo /* flags field values in struct brcmf_event_msg */
11205491d2cSKalle Valo #define BRCMF_EVENT_MSG_LINK		0x01
11305491d2cSKalle Valo #define BRCMF_EVENT_MSG_FLUSHTXQ	0x02
11405491d2cSKalle Valo #define BRCMF_EVENT_MSG_GROUP		0x04
11505491d2cSKalle Valo 
11605491d2cSKalle Valo /* status field values in struct brcmf_event_msg */
11705491d2cSKalle Valo #define BRCMF_E_STATUS_SUCCESS			0
11805491d2cSKalle Valo #define BRCMF_E_STATUS_FAIL			1
11905491d2cSKalle Valo #define BRCMF_E_STATUS_TIMEOUT			2
12005491d2cSKalle Valo #define BRCMF_E_STATUS_NO_NETWORKS		3
12105491d2cSKalle Valo #define BRCMF_E_STATUS_ABORT			4
12205491d2cSKalle Valo #define BRCMF_E_STATUS_NO_ACK			5
12305491d2cSKalle Valo #define BRCMF_E_STATUS_UNSOLICITED		6
12405491d2cSKalle Valo #define BRCMF_E_STATUS_ATTEMPT			7
12505491d2cSKalle Valo #define BRCMF_E_STATUS_PARTIAL			8
12605491d2cSKalle Valo #define BRCMF_E_STATUS_NEWSCAN			9
12705491d2cSKalle Valo #define BRCMF_E_STATUS_NEWASSOC			10
12805491d2cSKalle Valo #define BRCMF_E_STATUS_11HQUIET			11
12905491d2cSKalle Valo #define BRCMF_E_STATUS_SUPPRESS			12
13005491d2cSKalle Valo #define BRCMF_E_STATUS_NOCHANS			13
13105491d2cSKalle Valo #define BRCMF_E_STATUS_CS_ABORT			15
13205491d2cSKalle Valo #define BRCMF_E_STATUS_ERROR			16
13305491d2cSKalle Valo 
134b8a64f0eSArend van Spriel /* status field values for PSK_SUP event */
135b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_WAIT_M1		4
136b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_PREP_M2		5
137b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_COMPLETED		6
138b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_TIMEOUT		7
139b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_WAIT_M3		8
140b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_PREP_M4		9
141b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_WAIT_G1		10
142b8a64f0eSArend van Spriel #define BRCMF_E_STATUS_FWSUP_PREP_G2		11
143b8a64f0eSArend van Spriel 
14405491d2cSKalle Valo /* reason field values in struct brcmf_event_msg */
14505491d2cSKalle Valo #define BRCMF_E_REASON_INITIAL_ASSOC		0
14605491d2cSKalle Valo #define BRCMF_E_REASON_LOW_RSSI			1
14705491d2cSKalle Valo #define BRCMF_E_REASON_DEAUTH			2
14805491d2cSKalle Valo #define BRCMF_E_REASON_DISASSOC			3
14905491d2cSKalle Valo #define BRCMF_E_REASON_BCNS_LOST		4
15005491d2cSKalle Valo #define BRCMF_E_REASON_MINTXRATE		9
15105491d2cSKalle Valo #define BRCMF_E_REASON_TXFAIL			10
15205491d2cSKalle Valo 
15305491d2cSKalle Valo #define BRCMF_E_REASON_LINK_BSSCFG_DIS		4
15405491d2cSKalle Valo #define BRCMF_E_REASON_FAST_ROAM_FAILED		5
15505491d2cSKalle Valo #define BRCMF_E_REASON_DIRECTED_ROAM		6
15605491d2cSKalle Valo #define BRCMF_E_REASON_TSPEC_REJECTED		7
15705491d2cSKalle Valo #define BRCMF_E_REASON_BETTER_AP		8
15805491d2cSKalle Valo 
15905491d2cSKalle Valo #define BRCMF_E_REASON_TDLS_PEER_DISCOVERED	0
16005491d2cSKalle Valo #define BRCMF_E_REASON_TDLS_PEER_CONNECTED	1
16105491d2cSKalle Valo #define BRCMF_E_REASON_TDLS_PEER_DISCONNECTED	2
16205491d2cSKalle Valo 
163b8a64f0eSArend van Spriel /* reason field values for PSK_SUP event */
164b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_OTHER		0
165b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_DECRYPT_KEY_DATA	1
166b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_BAD_UCAST_WEP128	2
167b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_BAD_UCAST_WEP40	3
168b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_UNSUP_KEY_LEN	4
169b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_PW_KEY_CIPHER	5
170b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_MSG3_TOO_MANY_IE	6
171b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_MSG3_IE_MISMATCH	7
172b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_NO_INSTALL_FLAG	8
173b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_MSG3_NO_GTK	9
174b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_GRP_KEY_CIPHER	10
175b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_GRP_MSG1_NO_GTK	11
176b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_GTK_DECRYPT_FAIL	12
177b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_SEND_FAIL		13
178b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_DEAUTH		14
179b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_WPA_PSK_TMO	15
180b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_WPA_PSK_M1_TMO	16
181b8a64f0eSArend van Spriel #define BRCMF_E_REASON_FWSUP_WPA_PSK_M3_TMO	17
182b8a64f0eSArend van Spriel 
18305491d2cSKalle Valo /* action field values for brcmf_ifevent */
18405491d2cSKalle Valo #define BRCMF_E_IF_ADD				1
18505491d2cSKalle Valo #define BRCMF_E_IF_DEL				2
18605491d2cSKalle Valo #define BRCMF_E_IF_CHANGE			3
18705491d2cSKalle Valo 
18805491d2cSKalle Valo /* flag field values for brcmf_ifevent */
18905491d2cSKalle Valo #define BRCMF_E_IF_FLAG_NOIF			1
19005491d2cSKalle Valo 
19105491d2cSKalle Valo /* role field values for brcmf_ifevent */
19205491d2cSKalle Valo #define BRCMF_E_IF_ROLE_STA			0
19305491d2cSKalle Valo #define BRCMF_E_IF_ROLE_AP			1
19405491d2cSKalle Valo #define BRCMF_E_IF_ROLE_WDS			2
19505491d2cSKalle Valo #define BRCMF_E_IF_ROLE_P2P_GO			3
19605491d2cSKalle Valo #define BRCMF_E_IF_ROLE_P2P_CLIENT		4
19705491d2cSKalle Valo 
19805491d2cSKalle Valo /**
19905491d2cSKalle Valo  * definitions for event packet validation.
20005491d2cSKalle Valo  */
20105491d2cSKalle Valo #define BRCM_OUI				"\x00\x10\x18"
20205491d2cSKalle Valo #define BCMILCP_BCM_SUBTYPE_EVENT		1
203a4176ec3SArend van Spriel #define BCMILCP_SUBTYPE_VENDOR_LONG		32769
20405491d2cSKalle Valo 
20505491d2cSKalle Valo /**
2060aedbcafSHante Meuleman  * struct brcm_ethhdr - broadcom specific ether header.
2070aedbcafSHante Meuleman  *
2080aedbcafSHante Meuleman  * @subtype: subtype for this packet.
2090aedbcafSHante Meuleman  * @length: TODO: length of appended data.
2100aedbcafSHante Meuleman  * @version: version indication.
2110aedbcafSHante Meuleman  * @oui: OUI of this packet.
2120aedbcafSHante Meuleman  * @usr_subtype: subtype for this OUI.
2130aedbcafSHante Meuleman  */
2140aedbcafSHante Meuleman struct brcm_ethhdr {
2150aedbcafSHante Meuleman 	__be16 subtype;
2160aedbcafSHante Meuleman 	__be16 length;
2170aedbcafSHante Meuleman 	u8 version;
2180aedbcafSHante Meuleman 	u8 oui[3];
2190aedbcafSHante Meuleman 	__be16 usr_subtype;
2200aedbcafSHante Meuleman } __packed;
2210aedbcafSHante Meuleman 
2220aedbcafSHante Meuleman struct brcmf_event_msg_be {
2230aedbcafSHante Meuleman 	__be16 version;
2240aedbcafSHante Meuleman 	__be16 flags;
2250aedbcafSHante Meuleman 	__be32 event_type;
2260aedbcafSHante Meuleman 	__be32 status;
2270aedbcafSHante Meuleman 	__be32 reason;
2280aedbcafSHante Meuleman 	__be32 auth_type;
2290aedbcafSHante Meuleman 	__be32 datalen;
2300aedbcafSHante Meuleman 	u8 addr[ETH_ALEN];
2310aedbcafSHante Meuleman 	char ifname[IFNAMSIZ];
2320aedbcafSHante Meuleman 	u8 ifidx;
2330aedbcafSHante Meuleman 	u8 bsscfgidx;
2340aedbcafSHante Meuleman } __packed;
2350aedbcafSHante Meuleman 
2360aedbcafSHante Meuleman /**
2370aedbcafSHante Meuleman  * struct brcmf_event - contents of broadcom event packet.
2380aedbcafSHante Meuleman  *
2390aedbcafSHante Meuleman  * @eth: standard ether header.
2400aedbcafSHante Meuleman  * @hdr: broadcom specific ether header.
2410aedbcafSHante Meuleman  * @msg: common part of the actual event message.
2420aedbcafSHante Meuleman  */
2430aedbcafSHante Meuleman struct brcmf_event {
2440aedbcafSHante Meuleman 	struct ethhdr eth;
2450aedbcafSHante Meuleman 	struct brcm_ethhdr hdr;
2460aedbcafSHante Meuleman 	struct brcmf_event_msg_be msg;
2470aedbcafSHante Meuleman } __packed;
2480aedbcafSHante Meuleman 
2490aedbcafSHante Meuleman /**
25005491d2cSKalle Valo  * struct brcmf_event_msg - firmware event message.
25105491d2cSKalle Valo  *
25205491d2cSKalle Valo  * @version: version information.
25305491d2cSKalle Valo  * @flags: event flags.
25405491d2cSKalle Valo  * @event_code: firmware event code.
25505491d2cSKalle Valo  * @status: status information.
25605491d2cSKalle Valo  * @reason: reason code.
25705491d2cSKalle Valo  * @auth_type: authentication type.
2582359dd09SMatteo Croce  * @datalen: length of event data buffer.
25905491d2cSKalle Valo  * @addr: ether address.
26005491d2cSKalle Valo  * @ifname: interface name.
26105491d2cSKalle Valo  * @ifidx: interface index.
26205491d2cSKalle Valo  * @bsscfgidx: bsscfg index.
26305491d2cSKalle Valo  */
26405491d2cSKalle Valo struct brcmf_event_msg {
26505491d2cSKalle Valo 	u16 version;
26605491d2cSKalle Valo 	u16 flags;
26705491d2cSKalle Valo 	u32 event_code;
26805491d2cSKalle Valo 	u32 status;
26905491d2cSKalle Valo 	u32 reason;
27005491d2cSKalle Valo 	s32 auth_type;
27105491d2cSKalle Valo 	u32 datalen;
27205491d2cSKalle Valo 	u8 addr[ETH_ALEN];
27305491d2cSKalle Valo 	char ifname[IFNAMSIZ];
27405491d2cSKalle Valo 	u8 ifidx;
27505491d2cSKalle Valo 	u8 bsscfgidx;
27605491d2cSKalle Valo };
27705491d2cSKalle Valo 
27805491d2cSKalle Valo struct brcmf_if_event {
27905491d2cSKalle Valo 	u8 ifidx;
28005491d2cSKalle Valo 	u8 action;
28105491d2cSKalle Valo 	u8 flags;
28237a869ecSHante Meuleman 	u8 bsscfgidx;
28305491d2cSKalle Valo 	u8 role;
28405491d2cSKalle Valo };
28505491d2cSKalle Valo 
28605491d2cSKalle Valo typedef int (*brcmf_fweh_handler_t)(struct brcmf_if *ifp,
28705491d2cSKalle Valo 				    const struct brcmf_event_msg *evtmsg,
28805491d2cSKalle Valo 				    void *data);
28905491d2cSKalle Valo 
29005491d2cSKalle Valo /**
29105491d2cSKalle Valo  * struct brcmf_fweh_info - firmware event handling information.
29205491d2cSKalle Valo  *
29305491d2cSKalle Valo  * @p2pdev_setup_ongoing: P2P device creation in progress.
29405491d2cSKalle Valo  * @event_work: event worker.
29505491d2cSKalle Valo  * @evt_q_lock: lock for event queue protection.
29605491d2cSKalle Valo  * @event_q: event queue.
29705491d2cSKalle Valo  * @evt_handler: registered event handlers.
29805491d2cSKalle Valo  */
29905491d2cSKalle Valo struct brcmf_fweh_info {
30005491d2cSKalle Valo 	bool p2pdev_setup_ongoing;
30105491d2cSKalle Valo 	struct work_struct event_work;
30205491d2cSKalle Valo 	spinlock_t evt_q_lock;
30305491d2cSKalle Valo 	struct list_head event_q;
30405491d2cSKalle Valo 	int (*evt_handler[BRCMF_E_LAST])(struct brcmf_if *ifp,
30505491d2cSKalle Valo 					 const struct brcmf_event_msg *evtmsg,
30605491d2cSKalle Valo 					 void *data);
30705491d2cSKalle Valo };
30805491d2cSKalle Valo 
309e1c122d5SRafał Miłecki const char *brcmf_fweh_event_name(enum brcmf_fweh_event_code code);
310e1c122d5SRafał Miłecki 
31105491d2cSKalle Valo void brcmf_fweh_attach(struct brcmf_pub *drvr);
31205491d2cSKalle Valo void brcmf_fweh_detach(struct brcmf_pub *drvr);
31305491d2cSKalle Valo int brcmf_fweh_register(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code,
31405491d2cSKalle Valo 			int (*handler)(struct brcmf_if *ifp,
31505491d2cSKalle Valo 				       const struct brcmf_event_msg *evtmsg,
31605491d2cSKalle Valo 				       void *data));
31705491d2cSKalle Valo void brcmf_fweh_unregister(struct brcmf_pub *drvr,
31805491d2cSKalle Valo 			   enum brcmf_fweh_event_code code);
31905491d2cSKalle Valo int brcmf_fweh_activate_events(struct brcmf_if *ifp);
32005491d2cSKalle Valo void brcmf_fweh_process_event(struct brcmf_pub *drvr,
3210aedbcafSHante Meuleman 			      struct brcmf_event *event_packet,
3220aedbcafSHante Meuleman 			      u32 packet_len);
32305491d2cSKalle Valo void brcmf_fweh_p2pdev_setup(struct brcmf_if *ifp, bool ongoing);
32405491d2cSKalle Valo 
32505491d2cSKalle Valo static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
326a4176ec3SArend van Spriel 					  struct sk_buff *skb, u16 stype)
32705491d2cSKalle Valo {
32805491d2cSKalle Valo 	struct brcmf_event *event_packet;
329a4176ec3SArend van Spriel 	u16 subtype, usr_stype;
33005491d2cSKalle Valo 
33105491d2cSKalle Valo 	/* only process events when protocol matches */
33205491d2cSKalle Valo 	if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL))
33305491d2cSKalle Valo 		return;
33405491d2cSKalle Valo 
3350aedbcafSHante Meuleman 	if ((skb->len + ETH_HLEN) < sizeof(*event_packet))
3360aedbcafSHante Meuleman 		return;
3370aedbcafSHante Meuleman 
33805491d2cSKalle Valo 	event_packet = (struct brcmf_event *)skb_mac_header(skb);
339a4176ec3SArend van Spriel 
340a4176ec3SArend van Spriel 	/* check subtype if needed */
341a4176ec3SArend van Spriel 	if (unlikely(stype)) {
342a4176ec3SArend van Spriel 		subtype = get_unaligned_be16(&event_packet->hdr.subtype);
343a4176ec3SArend van Spriel 		if (subtype != stype)
344a4176ec3SArend van Spriel 			return;
345a4176ec3SArend van Spriel 	}
346a4176ec3SArend van Spriel 
347a4176ec3SArend van Spriel 	/* check for BRCM oui match */
3480aedbcafSHante Meuleman 	if (memcmp(BRCM_OUI, &event_packet->hdr.oui[0],
3490aedbcafSHante Meuleman 		   sizeof(event_packet->hdr.oui)))
35005491d2cSKalle Valo 		return;
35105491d2cSKalle Valo 
35205491d2cSKalle Valo 	/* final match on usr_subtype */
3530aedbcafSHante Meuleman 	usr_stype = get_unaligned_be16(&event_packet->hdr.usr_subtype);
35405491d2cSKalle Valo 	if (usr_stype != BCMILCP_BCM_SUBTYPE_EVENT)
35505491d2cSKalle Valo 		return;
35605491d2cSKalle Valo 
3570aedbcafSHante Meuleman 	brcmf_fweh_process_event(drvr, event_packet, skb->len + ETH_HLEN);
35805491d2cSKalle Valo }
35905491d2cSKalle Valo 
36005491d2cSKalle Valo #endif /* FWEH_H_ */
361