xref: /OK3568_Linux_fs/external/rkwifibt/drivers/bcmdhd/dhd_linux_pktdump.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Header file for the Packet dump helper functions
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/Open:>>
22  *
23  * $Id$
24  */
25 
26 #ifndef __DHD_LINUX_PKTDUMP_H_
27 #define __DHD_LINUX_PKTDUMP_H_
28 
29 #include <typedefs.h>
30 #include <dhd.h>
31 
32 typedef enum {
33 	EAPOL_OTHER = 0,
34 	EAPOL_4WAY_M1,
35 	EAPOL_4WAY_M2,
36 	EAPOL_4WAY_M3,
37 	EAPOL_4WAY_M4,
38 	EAPOL_GROUPKEY_M1,
39 	EAPOL_GROUPKEY_M2
40 } msg_eapol_t;
41 
42 typedef enum pkt_cnt_rsn {
43 	PKT_CNT_RSN_INVALID	= 0,
44 	PKT_CNT_RSN_ROAM	= 1,
45 	PKT_CNT_RSN_GRPKEY_UP	= 2,
46 	PKT_CNT_RSN_CONNECT	= 3,
47 	PKT_CNT_RSN_MAX		= 4
48 } pkt_cnt_rsn_t;
49 
50 enum pkt_type {
51 	PKT_TYPE_DATA = 0,
52 	PKT_TYPE_DHCP = 1,
53 	PKT_TYPE_ICMP = 2,
54 	PKT_TYPE_DNS = 3,
55 	PKT_TYPE_ARP = 4,
56 	PKT_TYPE_EAP = 5
57 };
58 
59 extern msg_eapol_t dhd_is_4way_msg(uint8 *pktdata);
60 extern void dhd_dump_pkt(dhd_pub_t *dhd, int ifidx, uint8 *pktdata,
61 	uint32 pktlen, bool tx, uint32 *pkthash, uint16 *pktfate);
62 #ifdef BCMPCIE
63 extern bool dhd_match_pkt_type(dhd_pub_t *dhd, uint8 *pktdata, uint32 pktlen);
64 #endif /* BCMPCIE */
65 #ifdef DHD_PKTDUMP_ROAM
66 extern void dhd_dump_mod_pkt_timer(dhd_pub_t *dhdp, uint16 rsn);
67 extern void dhd_dump_pkt_init(dhd_pub_t *dhdp);
68 extern void dhd_dump_pkt_deinit(dhd_pub_t *dhdp);
69 extern void dhd_dump_pkt_clear(dhd_pub_t *dhdp);
70 #else
dhd_dump_mod_pkt_timer(dhd_pub_t * dhdp,uint16 rsn)71 static INLINE void dhd_dump_mod_pkt_timer(dhd_pub_t *dhdp, uint16 rsn) { }
dhd_dump_pkt_init(dhd_pub_t * dhdp)72 static INLINE void dhd_dump_pkt_init(dhd_pub_t *dhdp) { }
dhd_dump_pkt_deinit(dhd_pub_t * dhdp)73 static INLINE void dhd_dump_pkt_deinit(dhd_pub_t *dhdp) { }
dhd_dump_pkt_clear(dhd_pub_t * dhdp)74 static INLINE void dhd_dump_pkt_clear(dhd_pub_t *dhdp) { }
75 #endif /* DHD_PKTDUMP_ROAM */
76 
77 /* Rx packet dump */
78 #ifdef DHD_TRX_DUMP
79 extern void dhd_trx_pkt_dump(dhd_pub_t *dhdp, int ifidx,
80 	uint8 *pktdata, uint32 pktlen, bool tx);
81 #else
dhd_trx_pkt_dump(dhd_pub_t * dhdp,int ifidx,uint8 * pktdata,uint32 pktlen,bool tx)82 static INLINE void dhd_trx_pkt_dump(dhd_pub_t *dhdp, int ifidx,
83 	uint8 *pktdata, uint32 pktlen, bool tx) { }
84 #endif /* DHD_TRX_DUMP */
85 
86 /* DHCP packet dump */
87 #ifdef DHD_DHCP_DUMP
88 extern void dhd_dhcp_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx,
89 	uint32 *pkthash, uint16 *pktfate);
90 #else
dhd_dhcp_dump(dhd_pub_t * dhdp,int ifidx,uint8 * pktdata,bool tx,uint32 * pkthash,uint16 * pktfate)91 static INLINE void dhd_dhcp_dump(dhd_pub_t *dhdp, int ifidx,
92 	uint8 *pktdata, bool tx, uint32 *pkthash, uint16 *pktfate) { }
93 #endif /* DHD_DHCP_DUMP */
94 
95 /* DNS packet dump */
96 #ifdef DHD_DNS_DUMP
97 extern void dhd_dns_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx,
98 	uint32 *pkthash, uint16 *pktfate);
99 #else
dhd_dns_dump(dhd_pub_t * dhdp,int ifidx,uint8 * pktdata,bool tx,uint32 * pkthash,uint16 * pktfate)100 static INLINE void dhd_dns_dump(dhd_pub_t *dhdp, int ifidx,
101 	uint8 *pktdata, bool tx, uint32 *pkthash, uint16 *pktfate) { }
102 #endif /* DHD_DNS_DUMP */
103 
104 /* ICMP packet dump */
105 #ifdef DHD_ICMP_DUMP
106 extern void dhd_icmp_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx,
107 	uint32 *pkthash, uint16 *pktfate);
108 #else
dhd_icmp_dump(dhd_pub_t * dhdp,int ifidx,uint8 * pktdata,bool tx,uint32 * pkthash,uint16 * pktfate)109 static INLINE void dhd_icmp_dump(dhd_pub_t *dhdp, int ifidx,
110 	uint8 *pktdata, bool tx, uint32 *pkthash, uint16 *pktfate) { }
111 #endif /* DHD_ICMP_DUMP */
112 
113 /* ARP packet dump */
114 #ifdef DHD_ARP_DUMP
115 extern void dhd_arp_dump(dhd_pub_t *dhdp, int ifidx, uint8 *pktdata, bool tx,
116 	uint32 *pkthash, uint16 *pktfate);
117 #else
dhd_arp_dump(dhd_pub_t * dhdp,int ifidx,uint8 * pktdata,bool tx,uint32 * pkthash,uint16 * pktfate)118 static INLINE void dhd_arp_dump(dhd_pub_t *dhdp, int ifidx,
119 	uint8 *pktdata, bool tx, uint32 *pkthash, uint16 *pktfate) { }
120 #endif /* DHD_ARP_DUMP */
121 
122 /* 802.1X packet dump */
123 #ifdef DHD_8021X_DUMP
124 extern void dhd_dump_eapol_message(dhd_pub_t *dhd, int ifidx,
125         uint8 *pktdata, uint32 pktlen, bool tx, uint32 *pkthash, uint16 *pktfate);
126 #else
dhd_dump_eapol_message(dhd_pub_t * dhd,int ifidx,uint8 * pktdata,uint32 pktlen,bool tx,uint32 * pkthash,uint16 * pktfate)127 static INLINE void dhd_dump_eapol_message(dhd_pub_t *dhd, int ifidx,
128         uint8 *pktdata, uint32 pktlen, bool tx, uint32 *pkthash, uint16 *pktfate) { }
129 #endif /* DHD_8021X_DUMP */
130 extern bool dhd_check_ip_prot(uint8 *pktdata, uint16 ether_type);
131 extern bool dhd_check_arp(uint8 *pktdata, uint16 ether_type);
132 extern bool dhd_check_dhcp(uint8 *pktdata);
133 extern bool dhd_check_icmp(uint8 *pktdata);
134 extern bool dhd_check_dns(uint8 *pktdata);
135 #endif /* __DHD_LINUX_PKTDUMP_H_ */
136