xref: /linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h (revision e1c122d55f9ec5608ca98a9a846fd39cdf3ed7d7)
105491d2cSKalle Valo /*
205491d2cSKalle Valo  * Copyright (c) 2012 Broadcom Corporation
305491d2cSKalle Valo  *
405491d2cSKalle Valo  * Permission to use, copy, modify, and/or distribute this software for any
505491d2cSKalle Valo  * purpose with or without fee is hereby granted, provided that the above
605491d2cSKalle Valo  * copyright notice and this permission notice appear in all copies.
705491d2cSKalle Valo  *
805491d2cSKalle Valo  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
905491d2cSKalle Valo  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1005491d2cSKalle Valo  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
1105491d2cSKalle Valo  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1205491d2cSKalle Valo  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
1305491d2cSKalle Valo  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
1405491d2cSKalle Valo  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1505491d2cSKalle Valo  */
1605491d2cSKalle Valo 
1705491d2cSKalle Valo 
1805491d2cSKalle Valo #ifndef FWEH_H_
1905491d2cSKalle Valo #define FWEH_H_
2005491d2cSKalle Valo 
2105491d2cSKalle Valo #include <asm/unaligned.h>
2205491d2cSKalle Valo #include <linux/skbuff.h>
2305491d2cSKalle Valo #include <linux/if_ether.h>
2405491d2cSKalle Valo #include <linux/if.h>
2505491d2cSKalle Valo 
2605491d2cSKalle Valo /* formward declarations */
2705491d2cSKalle Valo struct brcmf_pub;
2805491d2cSKalle Valo struct brcmf_if;
2905491d2cSKalle Valo struct brcmf_cfg80211_info;
3005491d2cSKalle Valo 
3105491d2cSKalle Valo /* list of firmware events */
3205491d2cSKalle Valo #define BRCMF_FWEH_EVENT_ENUM_DEFLIST \
3305491d2cSKalle Valo 	BRCMF_ENUM_DEF(SET_SSID, 0) \
3405491d2cSKalle Valo 	BRCMF_ENUM_DEF(JOIN, 1) \
3505491d2cSKalle Valo 	BRCMF_ENUM_DEF(START, 2) \
3605491d2cSKalle Valo 	BRCMF_ENUM_DEF(AUTH, 3) \
3705491d2cSKalle Valo 	BRCMF_ENUM_DEF(AUTH_IND, 4) \
3805491d2cSKalle Valo 	BRCMF_ENUM_DEF(DEAUTH, 5) \
3905491d2cSKalle Valo 	BRCMF_ENUM_DEF(DEAUTH_IND, 6) \
4005491d2cSKalle Valo 	BRCMF_ENUM_DEF(ASSOC, 7) \
4105491d2cSKalle Valo 	BRCMF_ENUM_DEF(ASSOC_IND, 8) \
4205491d2cSKalle Valo 	BRCMF_ENUM_DEF(REASSOC, 9) \
4305491d2cSKalle Valo 	BRCMF_ENUM_DEF(REASSOC_IND, 10) \
4405491d2cSKalle Valo 	BRCMF_ENUM_DEF(DISASSOC, 11) \
4505491d2cSKalle Valo 	BRCMF_ENUM_DEF(DISASSOC_IND, 12) \
4605491d2cSKalle Valo 	BRCMF_ENUM_DEF(QUIET_START, 13) \
4705491d2cSKalle Valo 	BRCMF_ENUM_DEF(QUIET_END, 14) \
4805491d2cSKalle Valo 	BRCMF_ENUM_DEF(BEACON_RX, 15) \
4905491d2cSKalle Valo 	BRCMF_ENUM_DEF(LINK, 16) \
5005491d2cSKalle Valo 	BRCMF_ENUM_DEF(MIC_ERROR, 17) \
5105491d2cSKalle Valo 	BRCMF_ENUM_DEF(NDIS_LINK, 18) \
5205491d2cSKalle Valo 	BRCMF_ENUM_DEF(ROAM, 19) \
5305491d2cSKalle Valo 	BRCMF_ENUM_DEF(TXFAIL, 20) \
5405491d2cSKalle Valo 	BRCMF_ENUM_DEF(PMKID_CACHE, 21) \
5505491d2cSKalle Valo 	BRCMF_ENUM_DEF(RETROGRADE_TSF, 22) \
5605491d2cSKalle Valo 	BRCMF_ENUM_DEF(PRUNE, 23) \
5705491d2cSKalle Valo 	BRCMF_ENUM_DEF(AUTOAUTH, 24) \
5805491d2cSKalle Valo 	BRCMF_ENUM_DEF(EAPOL_MSG, 25) \
5905491d2cSKalle Valo 	BRCMF_ENUM_DEF(SCAN_COMPLETE, 26) \
6005491d2cSKalle Valo 	BRCMF_ENUM_DEF(ADDTS_IND, 27) \
6105491d2cSKalle Valo 	BRCMF_ENUM_DEF(DELTS_IND, 28) \
6205491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCNSENT_IND, 29) \
6305491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCNRX_MSG, 30) \
6405491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCNLOST_MSG, 31) \
6505491d2cSKalle Valo 	BRCMF_ENUM_DEF(ROAM_PREP, 32) \
6605491d2cSKalle Valo 	BRCMF_ENUM_DEF(PFN_NET_FOUND, 33) \
6705491d2cSKalle Valo 	BRCMF_ENUM_DEF(PFN_NET_LOST, 34) \
6805491d2cSKalle Valo 	BRCMF_ENUM_DEF(RESET_COMPLETE, 35) \
6905491d2cSKalle Valo 	BRCMF_ENUM_DEF(JOIN_START, 36) \
7005491d2cSKalle Valo 	BRCMF_ENUM_DEF(ROAM_START, 37) \
7105491d2cSKalle Valo 	BRCMF_ENUM_DEF(ASSOC_START, 38) \
7205491d2cSKalle Valo 	BRCMF_ENUM_DEF(IBSS_ASSOC, 39) \
7305491d2cSKalle Valo 	BRCMF_ENUM_DEF(RADIO, 40) \
7405491d2cSKalle Valo 	BRCMF_ENUM_DEF(PSM_WATCHDOG, 41) \
7505491d2cSKalle Valo 	BRCMF_ENUM_DEF(PROBREQ_MSG, 44) \
7605491d2cSKalle Valo 	BRCMF_ENUM_DEF(SCAN_CONFIRM_IND, 45) \
7705491d2cSKalle Valo 	BRCMF_ENUM_DEF(PSK_SUP, 46) \
7805491d2cSKalle Valo 	BRCMF_ENUM_DEF(COUNTRY_CODE_CHANGED, 47) \
7905491d2cSKalle Valo 	BRCMF_ENUM_DEF(EXCEEDED_MEDIUM_TIME, 48) \
8005491d2cSKalle Valo 	BRCMF_ENUM_DEF(ICV_ERROR, 49) \
8105491d2cSKalle Valo 	BRCMF_ENUM_DEF(UNICAST_DECODE_ERROR, 50) \
8205491d2cSKalle Valo 	BRCMF_ENUM_DEF(MULTICAST_DECODE_ERROR, 51) \
8305491d2cSKalle Valo 	BRCMF_ENUM_DEF(TRACE, 52) \
8405491d2cSKalle Valo 	BRCMF_ENUM_DEF(IF, 54) \
8505491d2cSKalle Valo 	BRCMF_ENUM_DEF(P2P_DISC_LISTEN_COMPLETE, 55) \
8605491d2cSKalle Valo 	BRCMF_ENUM_DEF(RSSI, 56) \
8705491d2cSKalle Valo 	BRCMF_ENUM_DEF(EXTLOG_MSG, 58) \
8805491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME, 59) \
8905491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME_COMPLETE, 60) \
9005491d2cSKalle Valo 	BRCMF_ENUM_DEF(PRE_ASSOC_IND, 61) \
9105491d2cSKalle Valo 	BRCMF_ENUM_DEF(PRE_REASSOC_IND, 62) \
9205491d2cSKalle Valo 	BRCMF_ENUM_DEF(CHANNEL_ADOPTED, 63) \
9305491d2cSKalle Valo 	BRCMF_ENUM_DEF(AP_STARTED, 64) \
9405491d2cSKalle Valo 	BRCMF_ENUM_DEF(DFS_AP_STOP, 65) \
9505491d2cSKalle Valo 	BRCMF_ENUM_DEF(DFS_AP_RESUME, 66) \
9605491d2cSKalle Valo 	BRCMF_ENUM_DEF(ESCAN_RESULT, 69) \
9705491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME_OFF_CHAN_COMPLETE, 70) \
9805491d2cSKalle Valo 	BRCMF_ENUM_DEF(PROBERESP_MSG, 71) \
9905491d2cSKalle Valo 	BRCMF_ENUM_DEF(P2P_PROBEREQ_MSG, 72) \
10005491d2cSKalle Valo 	BRCMF_ENUM_DEF(DCS_REQUEST, 73) \
10105491d2cSKalle Valo 	BRCMF_ENUM_DEF(FIFO_CREDIT_MAP, 74) \
10205491d2cSKalle Valo 	BRCMF_ENUM_DEF(ACTION_FRAME_RX, 75) \
10305491d2cSKalle Valo 	BRCMF_ENUM_DEF(TDLS_PEER_EVENT, 92) \
10405491d2cSKalle Valo 	BRCMF_ENUM_DEF(BCMC_CREDIT_SUPPORT, 127)
10505491d2cSKalle Valo 
10605491d2cSKalle Valo #define BRCMF_ENUM_DEF(id, val) \
10705491d2cSKalle Valo 	BRCMF_E_##id = (val),
10805491d2cSKalle Valo 
10905491d2cSKalle Valo /* firmware event codes sent by the dongle */
11005491d2cSKalle Valo enum brcmf_fweh_event_code {
11105491d2cSKalle Valo 	BRCMF_FWEH_EVENT_ENUM_DEFLIST
11205491d2cSKalle Valo 	/* this determines event mask length which must match
11305491d2cSKalle Valo 	 * minimum length check in device firmware so it is
11405491d2cSKalle Valo 	 * hard-coded here.
11505491d2cSKalle Valo 	 */
11605491d2cSKalle Valo 	BRCMF_E_LAST = 139
11705491d2cSKalle Valo };
11805491d2cSKalle Valo #undef BRCMF_ENUM_DEF
11905491d2cSKalle Valo 
12005491d2cSKalle Valo #define BRCMF_EVENTING_MASK_LEN		DIV_ROUND_UP(BRCMF_E_LAST, 8)
12105491d2cSKalle Valo 
12205491d2cSKalle Valo /* flags field values in struct brcmf_event_msg */
12305491d2cSKalle Valo #define BRCMF_EVENT_MSG_LINK		0x01
12405491d2cSKalle Valo #define BRCMF_EVENT_MSG_FLUSHTXQ	0x02
12505491d2cSKalle Valo #define BRCMF_EVENT_MSG_GROUP		0x04
12605491d2cSKalle Valo 
12705491d2cSKalle Valo /* status field values in struct brcmf_event_msg */
12805491d2cSKalle Valo #define BRCMF_E_STATUS_SUCCESS			0
12905491d2cSKalle Valo #define BRCMF_E_STATUS_FAIL			1
13005491d2cSKalle Valo #define BRCMF_E_STATUS_TIMEOUT			2
13105491d2cSKalle Valo #define BRCMF_E_STATUS_NO_NETWORKS		3
13205491d2cSKalle Valo #define BRCMF_E_STATUS_ABORT			4
13305491d2cSKalle Valo #define BRCMF_E_STATUS_NO_ACK			5
13405491d2cSKalle Valo #define BRCMF_E_STATUS_UNSOLICITED		6
13505491d2cSKalle Valo #define BRCMF_E_STATUS_ATTEMPT			7
13605491d2cSKalle Valo #define BRCMF_E_STATUS_PARTIAL			8
13705491d2cSKalle Valo #define BRCMF_E_STATUS_NEWSCAN			9
13805491d2cSKalle Valo #define BRCMF_E_STATUS_NEWASSOC			10
13905491d2cSKalle Valo #define BRCMF_E_STATUS_11HQUIET			11
14005491d2cSKalle Valo #define BRCMF_E_STATUS_SUPPRESS			12
14105491d2cSKalle Valo #define BRCMF_E_STATUS_NOCHANS			13
14205491d2cSKalle Valo #define BRCMF_E_STATUS_CS_ABORT			15
14305491d2cSKalle Valo #define BRCMF_E_STATUS_ERROR			16
14405491d2cSKalle Valo 
14505491d2cSKalle Valo /* reason field values in struct brcmf_event_msg */
14605491d2cSKalle Valo #define BRCMF_E_REASON_INITIAL_ASSOC		0
14705491d2cSKalle Valo #define BRCMF_E_REASON_LOW_RSSI			1
14805491d2cSKalle Valo #define BRCMF_E_REASON_DEAUTH			2
14905491d2cSKalle Valo #define BRCMF_E_REASON_DISASSOC			3
15005491d2cSKalle Valo #define BRCMF_E_REASON_BCNS_LOST		4
15105491d2cSKalle Valo #define BRCMF_E_REASON_MINTXRATE		9
15205491d2cSKalle Valo #define BRCMF_E_REASON_TXFAIL			10
15305491d2cSKalle Valo 
15405491d2cSKalle Valo #define BRCMF_E_REASON_LINK_BSSCFG_DIS		4
15505491d2cSKalle Valo #define BRCMF_E_REASON_FAST_ROAM_FAILED		5
15605491d2cSKalle Valo #define BRCMF_E_REASON_DIRECTED_ROAM		6
15705491d2cSKalle Valo #define BRCMF_E_REASON_TSPEC_REJECTED		7
15805491d2cSKalle Valo #define BRCMF_E_REASON_BETTER_AP		8
15905491d2cSKalle Valo 
16005491d2cSKalle Valo #define BRCMF_E_REASON_TDLS_PEER_DISCOVERED	0
16105491d2cSKalle Valo #define BRCMF_E_REASON_TDLS_PEER_CONNECTED	1
16205491d2cSKalle Valo #define BRCMF_E_REASON_TDLS_PEER_DISCONNECTED	2
16305491d2cSKalle Valo 
16405491d2cSKalle Valo /* action field values for brcmf_ifevent */
16505491d2cSKalle Valo #define BRCMF_E_IF_ADD				1
16605491d2cSKalle Valo #define BRCMF_E_IF_DEL				2
16705491d2cSKalle Valo #define BRCMF_E_IF_CHANGE			3
16805491d2cSKalle Valo 
16905491d2cSKalle Valo /* flag field values for brcmf_ifevent */
17005491d2cSKalle Valo #define BRCMF_E_IF_FLAG_NOIF			1
17105491d2cSKalle Valo 
17205491d2cSKalle Valo /* role field values for brcmf_ifevent */
17305491d2cSKalle Valo #define BRCMF_E_IF_ROLE_STA			0
17405491d2cSKalle Valo #define BRCMF_E_IF_ROLE_AP			1
17505491d2cSKalle Valo #define BRCMF_E_IF_ROLE_WDS			2
17605491d2cSKalle Valo #define BRCMF_E_IF_ROLE_P2P_GO			3
17705491d2cSKalle Valo #define BRCMF_E_IF_ROLE_P2P_CLIENT		4
17805491d2cSKalle Valo 
17905491d2cSKalle Valo /**
18005491d2cSKalle Valo  * definitions for event packet validation.
18105491d2cSKalle Valo  */
18205491d2cSKalle Valo #define BRCM_OUI				"\x00\x10\x18"
18305491d2cSKalle Valo #define BCMILCP_BCM_SUBTYPE_EVENT		1
18405491d2cSKalle Valo 
18505491d2cSKalle Valo 
18605491d2cSKalle Valo /**
1870aedbcafSHante Meuleman  * struct brcm_ethhdr - broadcom specific ether header.
1880aedbcafSHante Meuleman  *
1890aedbcafSHante Meuleman  * @subtype: subtype for this packet.
1900aedbcafSHante Meuleman  * @length: TODO: length of appended data.
1910aedbcafSHante Meuleman  * @version: version indication.
1920aedbcafSHante Meuleman  * @oui: OUI of this packet.
1930aedbcafSHante Meuleman  * @usr_subtype: subtype for this OUI.
1940aedbcafSHante Meuleman  */
1950aedbcafSHante Meuleman struct brcm_ethhdr {
1960aedbcafSHante Meuleman 	__be16 subtype;
1970aedbcafSHante Meuleman 	__be16 length;
1980aedbcafSHante Meuleman 	u8 version;
1990aedbcafSHante Meuleman 	u8 oui[3];
2000aedbcafSHante Meuleman 	__be16 usr_subtype;
2010aedbcafSHante Meuleman } __packed;
2020aedbcafSHante Meuleman 
2030aedbcafSHante Meuleman struct brcmf_event_msg_be {
2040aedbcafSHante Meuleman 	__be16 version;
2050aedbcafSHante Meuleman 	__be16 flags;
2060aedbcafSHante Meuleman 	__be32 event_type;
2070aedbcafSHante Meuleman 	__be32 status;
2080aedbcafSHante Meuleman 	__be32 reason;
2090aedbcafSHante Meuleman 	__be32 auth_type;
2100aedbcafSHante Meuleman 	__be32 datalen;
2110aedbcafSHante Meuleman 	u8 addr[ETH_ALEN];
2120aedbcafSHante Meuleman 	char ifname[IFNAMSIZ];
2130aedbcafSHante Meuleman 	u8 ifidx;
2140aedbcafSHante Meuleman 	u8 bsscfgidx;
2150aedbcafSHante Meuleman } __packed;
2160aedbcafSHante Meuleman 
2170aedbcafSHante Meuleman /**
2180aedbcafSHante Meuleman  * struct brcmf_event - contents of broadcom event packet.
2190aedbcafSHante Meuleman  *
2200aedbcafSHante Meuleman  * @eth: standard ether header.
2210aedbcafSHante Meuleman  * @hdr: broadcom specific ether header.
2220aedbcafSHante Meuleman  * @msg: common part of the actual event message.
2230aedbcafSHante Meuleman  */
2240aedbcafSHante Meuleman struct brcmf_event {
2250aedbcafSHante Meuleman 	struct ethhdr eth;
2260aedbcafSHante Meuleman 	struct brcm_ethhdr hdr;
2270aedbcafSHante Meuleman 	struct brcmf_event_msg_be msg;
2280aedbcafSHante Meuleman } __packed;
2290aedbcafSHante Meuleman 
2300aedbcafSHante Meuleman /**
23105491d2cSKalle Valo  * struct brcmf_event_msg - firmware event message.
23205491d2cSKalle Valo  *
23305491d2cSKalle Valo  * @version: version information.
23405491d2cSKalle Valo  * @flags: event flags.
23505491d2cSKalle Valo  * @event_code: firmware event code.
23605491d2cSKalle Valo  * @status: status information.
23705491d2cSKalle Valo  * @reason: reason code.
23805491d2cSKalle Valo  * @auth_type: authentication type.
23905491d2cSKalle Valo  * @datalen: lenght of event data buffer.
24005491d2cSKalle Valo  * @addr: ether address.
24105491d2cSKalle Valo  * @ifname: interface name.
24205491d2cSKalle Valo  * @ifidx: interface index.
24305491d2cSKalle Valo  * @bsscfgidx: bsscfg index.
24405491d2cSKalle Valo  */
24505491d2cSKalle Valo struct brcmf_event_msg {
24605491d2cSKalle Valo 	u16 version;
24705491d2cSKalle Valo 	u16 flags;
24805491d2cSKalle Valo 	u32 event_code;
24905491d2cSKalle Valo 	u32 status;
25005491d2cSKalle Valo 	u32 reason;
25105491d2cSKalle Valo 	s32 auth_type;
25205491d2cSKalle Valo 	u32 datalen;
25305491d2cSKalle Valo 	u8 addr[ETH_ALEN];
25405491d2cSKalle Valo 	char ifname[IFNAMSIZ];
25505491d2cSKalle Valo 	u8 ifidx;
25605491d2cSKalle Valo 	u8 bsscfgidx;
25705491d2cSKalle Valo };
25805491d2cSKalle Valo 
25905491d2cSKalle Valo struct brcmf_if_event {
26005491d2cSKalle Valo 	u8 ifidx;
26105491d2cSKalle Valo 	u8 action;
26205491d2cSKalle Valo 	u8 flags;
26337a869ecSHante Meuleman 	u8 bsscfgidx;
26405491d2cSKalle Valo 	u8 role;
26505491d2cSKalle Valo };
26605491d2cSKalle Valo 
26705491d2cSKalle Valo typedef int (*brcmf_fweh_handler_t)(struct brcmf_if *ifp,
26805491d2cSKalle Valo 				    const struct brcmf_event_msg *evtmsg,
26905491d2cSKalle Valo 				    void *data);
27005491d2cSKalle Valo 
27105491d2cSKalle Valo /**
27205491d2cSKalle Valo  * struct brcmf_fweh_info - firmware event handling information.
27305491d2cSKalle Valo  *
27405491d2cSKalle Valo  * @p2pdev_setup_ongoing: P2P device creation in progress.
27505491d2cSKalle Valo  * @event_work: event worker.
27605491d2cSKalle Valo  * @evt_q_lock: lock for event queue protection.
27705491d2cSKalle Valo  * @event_q: event queue.
27805491d2cSKalle Valo  * @evt_handler: registered event handlers.
27905491d2cSKalle Valo  */
28005491d2cSKalle Valo struct brcmf_fweh_info {
28105491d2cSKalle Valo 	bool p2pdev_setup_ongoing;
28205491d2cSKalle Valo 	struct work_struct event_work;
28305491d2cSKalle Valo 	spinlock_t evt_q_lock;
28405491d2cSKalle Valo 	struct list_head event_q;
28505491d2cSKalle Valo 	int (*evt_handler[BRCMF_E_LAST])(struct brcmf_if *ifp,
28605491d2cSKalle Valo 					 const struct brcmf_event_msg *evtmsg,
28705491d2cSKalle Valo 					 void *data);
28805491d2cSKalle Valo };
28905491d2cSKalle Valo 
290*e1c122d5SRafał Miłecki const char *brcmf_fweh_event_name(enum brcmf_fweh_event_code code);
291*e1c122d5SRafał Miłecki 
29205491d2cSKalle Valo void brcmf_fweh_attach(struct brcmf_pub *drvr);
29305491d2cSKalle Valo void brcmf_fweh_detach(struct brcmf_pub *drvr);
29405491d2cSKalle Valo int brcmf_fweh_register(struct brcmf_pub *drvr, enum brcmf_fweh_event_code code,
29505491d2cSKalle Valo 			int (*handler)(struct brcmf_if *ifp,
29605491d2cSKalle Valo 				       const struct brcmf_event_msg *evtmsg,
29705491d2cSKalle Valo 				       void *data));
29805491d2cSKalle Valo void brcmf_fweh_unregister(struct brcmf_pub *drvr,
29905491d2cSKalle Valo 			   enum brcmf_fweh_event_code code);
30005491d2cSKalle Valo int brcmf_fweh_activate_events(struct brcmf_if *ifp);
30105491d2cSKalle Valo void brcmf_fweh_process_event(struct brcmf_pub *drvr,
3020aedbcafSHante Meuleman 			      struct brcmf_event *event_packet,
3030aedbcafSHante Meuleman 			      u32 packet_len);
30405491d2cSKalle Valo void brcmf_fweh_p2pdev_setup(struct brcmf_if *ifp, bool ongoing);
30505491d2cSKalle Valo 
30605491d2cSKalle Valo static inline void brcmf_fweh_process_skb(struct brcmf_pub *drvr,
30705491d2cSKalle Valo 					  struct sk_buff *skb)
30805491d2cSKalle Valo {
30905491d2cSKalle Valo 	struct brcmf_event *event_packet;
31005491d2cSKalle Valo 	u16 usr_stype;
31105491d2cSKalle Valo 
31205491d2cSKalle Valo 	/* only process events when protocol matches */
31305491d2cSKalle Valo 	if (skb->protocol != cpu_to_be16(ETH_P_LINK_CTL))
31405491d2cSKalle Valo 		return;
31505491d2cSKalle Valo 
3160aedbcafSHante Meuleman 	if ((skb->len + ETH_HLEN) < sizeof(*event_packet))
3170aedbcafSHante Meuleman 		return;
3180aedbcafSHante Meuleman 
31905491d2cSKalle Valo 	/* check for BRCM oui match */
32005491d2cSKalle Valo 	event_packet = (struct brcmf_event *)skb_mac_header(skb);
3210aedbcafSHante Meuleman 	if (memcmp(BRCM_OUI, &event_packet->hdr.oui[0],
3220aedbcafSHante Meuleman 		   sizeof(event_packet->hdr.oui)))
32305491d2cSKalle Valo 		return;
32405491d2cSKalle Valo 
32505491d2cSKalle Valo 	/* final match on usr_subtype */
3260aedbcafSHante Meuleman 	usr_stype = get_unaligned_be16(&event_packet->hdr.usr_subtype);
32705491d2cSKalle Valo 	if (usr_stype != BCMILCP_BCM_SUBTYPE_EVENT)
32805491d2cSKalle Valo 		return;
32905491d2cSKalle Valo 
3300aedbcafSHante Meuleman 	brcmf_fweh_process_event(drvr, event_packet, skb->len + ETH_HLEN);
33105491d2cSKalle Valo }
33205491d2cSKalle Valo 
33305491d2cSKalle Valo #endif /* FWEH_H_ */
334