xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include/monitor.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Monitor Mode definitions.
3  * This header file housing the define and function prototype use by
4  * both the wl firmware and drivers.
5  *
6  * Broadcom Proprietary and Confidential. Copyright (C) 2020,
7  * All Rights Reserved.
8  *
9  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom;
10  * the contents of this file may not be disclosed to third parties,
11  * copied or duplicated in any form, in whole or in part, without
12  * the prior written permission of Broadcom.
13  *
14  *
15  * <<Broadcom-WL-IPTag/Proprietary:>>
16  */
17 #ifndef _MONITOR_H_
18 #define _MONITOR_H_
19 
20 #include <bcmwifi_channels.h>
21 
22 #include <packed_section_start.h>
23 /* wl_monitor rx status per packet */
24 typedef struct BWL_PRE_PACKED_STRUCT wl_rxsts {
25 	uint       pkterror;      /* error flags per pkt */
26 	uint       phytype;       /* 802.11 A/B/G /N  */
27 	chanspec_t chanspec;      /* channel spec */
28 	uint16     datarate;      /* rate in 500kbps */
29 	uint8      mcs;           /* MCS for HT frame */
30 	uint8      htflags;       /* HT modulation flags */
31 	uint       antenna;       /* antenna pkts received on */
32 	uint       pktlength;     /* pkt length minus bcm phy hdr */
33 	uint32     mactime;       /* time stamp from mac, count per 1us */
34 	uint       sq;            /* signal quality */
35 	int32      signal;        /* in dBm */
36 	int32      noise;         /* in dBm */
37 	uint       preamble;      /* Unknown, short, long */
38 	uint       encoding;      /* Unknown, CCK, PBCC, OFDM, HT, VHT */
39 	uint       nfrmtype;      /* special 802.11n frames(AMPDU, AMSDU) */
40 	uint8      nss;           /* Number of spatial streams for VHT frame */
41 	uint8      coding;
42 	uint16     aid;           /* Partial AID for VHT frame */
43 	uint8      gid;           /* Group ID for VHT frame */
44 	uint8      bw;            /* Bandwidth for VHT frame */
45 	uint16     vhtflags;      /* VHT modulation flags */
46 	uint16     bw_nonht;      /* non-HT bw advertised in rts/cts */
47 	uint32     ampdu_counter; /* AMPDU counter for sniffer */
48 	uint32     sig_a1;        /* TODO: this unused field needs to be removed */
49 	uint32     sig_a2;        /* TODO: this unused field needs to be removed */
50 	uint16     data1;
51 	uint16     data2;
52 	uint16     data3;
53 	uint16     data4;
54 	uint16     data5;
55 	uint16     data6;
56 	uint8      ru_channel1[4];
57 	uint8      ru_channel2[4];
58 	uint16     flag1;
59 	uint16     flag2;
60 } BWL_POST_PACKED_STRUCT wl_rxsts_t, wl_mon_rxsts_t;
61 #include <packed_section_end.h>
62 
63 #define WLMONRXSTS_SIZE	sizeof(wl_rxsts_t)
64 
65 /* phy type */
66 #define WL_RXS_PHY_N			0x00000004 /* N phy type */
67 
68 /* encoding */
69 #define WL_RXS_ENCODING_UNKNOWN		0x00000000
70 #define WL_RXS_ENCODING_DSSS_CCK	0x00000001 /* DSSS/CCK encoding (1, 2, 5.5, 11) */
71 #define WL_RXS_ENCODING_OFDM		0x00000002 /* OFDM encoding */
72 #define WL_RXS_ENCODING_HT		0x00000003 /* HT encoding */
73 #define WL_RXS_ENCODING_VHT		0x00000004 /* VHT encoding */
74 #define WL_RXS_ENCODING_HE		0x00000005 /* HE encoding */
75 #define WL_RXS_ENCODING_EHT		0x00000006 /* EHT encoding */
76 
77 /* status per error RX pkt */
78 #define WL_RXS_CRC_ERROR		0x00000001 /* CRC Error in packet */
79 #define WL_RXS_RUNT_ERROR		0x00000002 /* Runt packet */
80 #define WL_RXS_ALIGN_ERROR		0x00000004 /* Misaligned packet */
81 #define WL_RXS_OVERSIZE_ERROR		0x00000008 /* packet bigger than RX_LENGTH (usually 1518) */
82 #define WL_RXS_WEP_ICV_ERROR		0x00000010 /* Integrity Check Value error */
83 #define WL_RXS_WEP_ENCRYPTED		0x00000020 /* Encrypted with WEP */
84 #define WL_RXS_PLCP_SHORT		0x00000040 /* Short PLCP error */
85 #define WL_RXS_DECRYPT_ERR		0x00000080 /* Decryption error */
86 #define WL_RXS_OTHER_ERR		0x80000000 /* Other errors */
87 
88 /* preamble */
89 #define WL_RXS_UNUSED_STUB		0x0		/**< stub to match with wlc_ethereal.h */
90 #define WL_RXS_PREAMBLE_SHORT		0x00000001	/**< Short preamble */
91 #define WL_RXS_PREAMBLE_LONG		0x00000002	/**< Long preamble */
92 #define WL_RXS_PREAMBLE_HT_MM		0x00000003	/**< HT mixed mode preamble */
93 #define WL_RXS_PREAMBLE_HT_GF		0x00000004	/**< HT green field preamble */
94 
95 /* htflags */
96 #define WL_RXS_HTF_BW_MASK		0x07
97 #define WL_RXS_HTF_40			0x01
98 #define WL_RXS_HTF_20L			0x02
99 #define WL_RXS_HTF_20U			0x04
100 #define WL_RXS_HTF_SGI			0x08
101 #define WL_RXS_HTF_STBC_MASK		0x30
102 #define WL_RXS_HTF_STBC_SHIFT		4
103 #define WL_RXS_HTF_LDPC			0x40
104 
105 #ifdef WLTXMONITOR
106 /* reuse bw-bits in ht for vht */
107 #define WL_RXS_VHTF_BW_MASK		0x87
108 #define WL_RXS_VHTF_40			0x01
109 #define WL_RXS_VHTF_20L			WL_RXS_VHTF_20LL
110 #define WL_RXS_VHTF_20U			WL_RXS_VHTF_20LU
111 #define WL_RXS_VHTF_80			0x02
112 #define WL_RXS_VHTF_20LL		0x03
113 #define WL_RXS_VHTF_20LU		0x04
114 #define WL_RXS_VHTF_20UL		0x05
115 #define WL_RXS_VHTF_20UU		0x06
116 #define WL_RXS_VHTF_40L			0x07
117 #define WL_RXS_VHTF_40U			0x80
118 #endif /* WLTXMONITOR */
119 
120 /* vhtflags */
121 #define WL_RXS_VHTF_STBC		0x01
122 #define WL_RXS_VHTF_TXOP_PS		0x02
123 #define WL_RXS_VHTF_SGI			0x04
124 #define WL_RXS_VHTF_SGI_NSYM_DA		0x08
125 #define WL_RXS_VHTF_LDPC_EXTRA		0x10
126 #define WL_RXS_VHTF_BF			0x20
127 #define WL_RXS_VHTF_DYN_BW_NONHT	0x40
128 #define WL_RXS_VHTF_CODING_LDCP		0x01
129 
130 #define WL_RXS_VHT_BW_20		0
131 #define WL_RXS_VHT_BW_40		1
132 #define WL_RXS_VHT_BW_20L		2
133 #define WL_RXS_VHT_BW_20U		3
134 #define WL_RXS_VHT_BW_80		4
135 #define WL_RXS_VHT_BW_40L		5
136 #define WL_RXS_VHT_BW_40U		6
137 #define WL_RXS_VHT_BW_20LL		7
138 #define WL_RXS_VHT_BW_20LU		8
139 #define WL_RXS_VHT_BW_20UL		9
140 #define WL_RXS_VHT_BW_20UU		10
141 #define WL_RXS_VHT_BW_160		11
142 #define WL_RXS_VHT_BW_80L		12
143 #define WL_RXS_VHT_BW_80U		13
144 #define WL_RXS_VHT_BW_40LL		14
145 #define WL_RXS_VHT_BW_40LU		15
146 #define WL_RXS_VHT_BW_40UL		16
147 #define WL_RXS_VHT_BW_40UU		17
148 #define WL_RXS_VHT_BW_20LLL		18
149 #define WL_RXS_VHT_BW_20LLU		19
150 #define WL_RXS_VHT_BW_20LUL		20
151 #define WL_RXS_VHT_BW_20LUU		21
152 #define WL_RXS_VHT_BW_20ULL		22
153 #define WL_RXS_VHT_BW_20ULU		23
154 #define WL_RXS_VHT_BW_20UUL		24
155 #define WL_RXS_VHT_BW_20UUU		25
156 
157 #define WL_RXS_NFRM_AMPDU_FIRST		0x00000001 /* first MPDU in A-MPDU */
158 #define WL_RXS_NFRM_AMPDU_SUB		0x00000002 /* subsequent MPDU(s) in A-MPDU */
159 #define WL_RXS_NFRM_AMSDU_FIRST		0x00000004 /* first MSDU in A-MSDU */
160 #define WL_RXS_NFRM_AMSDU_SUB		0x00000008 /* subsequent MSDU(s) in A-MSDU */
161 
162 /* HE flags */
163 #define WL_RXS_HEF_SIGA_PPDU_SU		0x0000
164 #define WL_RXS_HEF_SIGA_PPDU_EXT_SU	0x0001
165 #define WL_RXS_HEF_SIGA_PPDU_MU		0x0002
166 #define WL_RXS_HEF_SIGA_PPDU_TRIG	0x0003
167 #define WL_RXS_HEF_SIGA_BSS_COLOR	0x0004
168 #define WL_RXS_HEF_SIGA_BEAM_CHANGE	0x0008
169 #define WL_RXS_HEF_SIGA_DL_UL		0x0010
170 #define WL_RXS_HEF_SIGA_MCS		0x0020
171 #define WL_RXS_HEF_SIGA_DCM		0x0040
172 #define WL_RXS_HEF_SIGA_CODING		0x0080
173 #define WL_RXS_HEF_SIGA_LDPC		0x0100
174 #define WL_RXS_HEF_SIGA_STBC		0x0200
175 #define WL_RXS_HEF_SIGA_SPATIAL_REUSE	0x0400
176 #define WL_RXS_HEF_SIGA_STA_ID		0x0800
177 #define WL_RXS_HEF_SIGA_SPATIAL_REUSE2	0x0800
178 #define WL_RXS_HEF_SIGA_SPATIAL_REUSE3	0x1000
179 #define WL_RXS_HEF_SIGA_SPATIAL_REUSE4	0x2000
180 #define WL_RXS_HEF_SIGA_BW		0x4000
181 #define WL_RXS_HEF_SIGA_RU_ALLOC	0x4000
182 #define WL_RXS_HEF_SIGA_DOPPLER		0x8000
183 #define WL_RXS_HEF_SIGA_GI		0x0002
184 #define WL_RXS_HEF_SIGA_LTF_SIZE	0x0004 /* no explicit known field */
185 #define WL_RXS_HEF_SIGA_NUM_LTF		0x0004
186 #define WL_RXS_HEF_SIGA_PADDING		0x0008
187 #define WL_RXS_HEF_SIGA_TXBF		0x0010
188 #define WL_RXS_HEF_SIGA_PE		0x0020
189 #define WL_RXS_HEF_SIGA_TXOP		0x0040
190 #define WL_RXS_HEF_SIGA_MIDAMBLE	0x0080
191 
192 /* https://www.radiotap.org/fields/HE-MU.html */
193 #define WL_RXS_HEF_SIGB_MCS_KNOWN	0x0010
194 #define WL_RXS_HEF_SIGB_DCM_KNOWN	0x0040
195 #define WL_RXS_HEF_CH2_26TONE_RU_KNOWN	0x0080
196 #define WL_RXS_HEF_CH1_RU_KNOWN		0x0100
197 #define WL_RXS_HEF_CH2_RU_KNOWN		0x0200
198 #define WL_RXS_HEF_CH1_26TONE_RU_KNOWN	0x1000
199 #define WL_RXS_HEF_SIGB_COMP_KNOWN	0x4000
200 #define WL_RXS_HEF_NUM_SIGB_SYMB_KNOWN	0x8000
201 #define WL_RXS_HEF_BW_SIGA_KNOWN	0x0004
202 #define WL_RXS_HEF_PREPUNCR_SIGA_KNOWN	0x0400
203 #define WL_RXS_HEF_SIGB_SYMB_KNOWN      0x8000
204 #define WL_RXS_HEF_PREPUNCR_KNOWN       0x0400
205 
206 #include <packed_section_start.h>
207 typedef struct BWL_PRE_PACKED_STRUCT wl_txsts {
208 	uint       pkterror;  /**< error flags per pkt */
209 	uint       phytype;   /**< 802.11 A/B/G /N */
210 	chanspec_t chanspec;  /**< channel spec */
211 	uint16     datarate;  /**< rate in 500kbps */
212 	uint8      mcs;       /**< MCS for HT frame */
213 	uint8      htflags;   /**< HT modulation flags */
214 	uint       antenna;   /**< antenna pkt transmitted on */
215 	uint       pktlength; /**< pkt length minus bcm phy hdr */
216 	uint32     mactime;   /**< ? time stamp from mac, count per 1us */
217 	uint       preamble;  /**< Unknown, short, long */
218 	uint       encoding;  /**< Unknown, CCK, PBCC, OFDM, HT */
219 	uint       nfrmtype;  /**< special 802.11n frames(AMPDU, AMSDU) */
220 	uint       txflags;   /**< As defined in radiotap field 15 */
221 	uint       retries;   /**< Number of retries */
222 	struct wl_if *wlif;   /**< wl interface */
223 } BWL_POST_PACKED_STRUCT wl_txsts_t;
224 #include <packed_section_end.h>
225 
226 #define WL_TXS_TXF_FAIL		0x01	/**< TX failed due to excessive retries */
227 #define WL_TXS_TXF_CTS		0x02	/**< TX used CTS-to-self protection */
228 #define WL_TXS_TXF_RTSCTS	0x04	/**< TX used RTS/CTS */
229 
230 #endif /* _MONITOR_H_ */
231