xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/include/bcmwifi_monitor.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Monitor Mode routines.
3  * This header file housing the define and function use by DHD
4  *
5  * Broadcom Proprietary and Confidential. Copyright (C) 2020,
6  * All Rights Reserved.
7  *
8  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom;
9  * the contents of this file may not be disclosed to third parties,
10  * copied or duplicated in any form, in whole or in part, without
11  * the prior written permission of Broadcom.
12  *
13  *
14  * <<Broadcom-WL-IPTag/Proprietary:>>
15  */
16 #ifndef _BCMWIFI_MONITOR_H_
17 #define _BCMWIFI_MONITOR_H_
18 
19 #include <monitor.h>
20 
21 typedef struct monitor_info monitor_info_t;
22 
23 typedef struct monitor_pkt_ts {
24 	union {
25 		uint32	ts_low; /* time stamp low 32 bits */
26 		uint32	reserved; /* If timestamp not used */
27 	};
28 	union {
29 		uint32  ts_high; /* time stamp high 28 bits */
30 		union {
31 			uint32  ts_high_ext :28; /* time stamp high 28 bits */
32 			uint32  clk_id_ext :3; /* clock ID source  */
33 			uint32  phase :1; /* Phase bit */
34 			uint32	marker_ext;
35 		};
36 	};
37 } monitor_pkt_ts_t;
38 
39 typedef struct monitor_pkt_info {
40 	uint32	marker;
41 	/* timestamp */
42 	monitor_pkt_ts_t ts;
43 } monitor_pkt_info_t;
44 
45 typedef struct monitor_pkt_rssi {
46 	int8 dBm;  /* number of full dBms */
47 	/* sub-dbm resolution */
48 	int8  decidBm; /* sub dBms : value after the decimal point */
49 } monitor_pkt_rssi_t;
50 
51 /* structure to add specific information to rxsts structure
52  * otherwise non available to all modules like core RSSI and qdbm resolution
53 */
54 
55 typedef struct monitor_pkt_rxsts {
56 	wl_rxsts_t *rxsts;
57 	uint8   corenum; /* number of cores/antennas */
58 	monitor_pkt_rssi_t rxpwr[4];
59 } monitor_pkt_rxsts_t;
60 
61 #define HE_EXTRACT_FROM_PLCP(plcp, ppdu_type, field)						\
62 		(getbits(plcp, D11_PHY_HDR_LEN,							\
63 			HE_ ## ppdu_type ## _PPDU_ ## field ## _IDX,				\
64 			HE_ ## ppdu_type ## _PPDU_ ## field ## _FSZ))
65 
66 #define HE_PACK_RTAP_FROM_PLCP(plcp, ppdu_type, field)						\
67 		(HE_EXTRACT_FROM_PLCP(plcp, ppdu_type, field) <<				\
68 			HE_RADIOTAP_ ## field ## _SHIFT)
69 
70 #define HE_PACK_RTAP_GI_LTF_FROM_PLCP(plcp, ppdu_type, field, member)				\
71 		((he_plcp2ltf_gi[HE_EXTRACT_FROM_PLCP(plcp, ppdu_type, field)].member) <<	\
72 			HE_RADIOTAP_ ## field ## _SHIFT)
73 
74 #define HE_PACK_RTAP_FROM_VAL(val, field)							\
75 		((val) << HE_RADIOTAP_ ## field ## _SHIFT)
76 
77 #define HE_PACK_RTAP_FROM_PRXS(rxh, corerev, corerev_minor, field)				\
78 		(HE_PACK_RTAP_FROM_VAL(D11PPDU_ ## field(rxh, corerev, corerev_minor), field))
79 
80 /* channel bandwidth */
81 #define WLC_20_MHZ	20	/**< 20Mhz channel bandwidth */
82 #define WLC_40_MHZ	40	/**< 40Mhz channel bandwidth */
83 #define WLC_80_MHZ	80	/**< 80Mhz channel bandwidth */
84 #define WLC_160_MHZ	160	/**< 160Mhz channel bandwidth */
85 #define WLC_240_MHZ	240	/**< 240Mhz channel bandwidth */
86 #define WLC_320_MHZ	320	/**< 320Mhz channel bandwidth */
87 
88 extern uint16 bcmwifi_monitor_create(monitor_info_t**);
89 extern void bcmwifi_set_corerev_major(monitor_info_t* info, int8 corerev);
90 extern void bcmwifi_set_corerev_minor(monitor_info_t* info, int8 corerev);
91 extern void bcmwifi_monitor_delete(monitor_info_t* info);
92 extern uint16 bcmwifi_monitor(monitor_info_t* info,
93 	monitor_pkt_info_t* pkt_info, void *pdata, uint16 len, void* pout,
94 	uint16* offset, uint16 pad_req, void *wrxh_in, void *wrxh_last);
95 extern uint16 wl_rxsts_to_rtap(monitor_pkt_rxsts_t* pkt_rxsts, void *pdata,
96                                uint16 len, void* pout, uint16 pad_req);
97 
98 #endif /* _BCMWIFI_MONITOR_H_ */
99