1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /**
19  *  DOC: wlan_mgmt_txrx_rx_reo_public_structs.h
20  *  Contains MGMT Rx REO structure definitions
21  */
22 
23 #ifndef _WLAN_MGMT_TXRX_RX_REO_PUBLIC_STRUCTS_H
24 #define _WLAN_MGMT_TXRX_RX_REO_PUBLIC_STRUCTS_H
25 #ifdef WLAN_MGMT_RX_REO_SUPPORT
26 /*
27  * enum mgmt_rx_reo_shared_snapshot_id - Represents the management
28  * rx-reorder snapshots shared between host and target in the host DDR.
29  * These snapshots are written by FW/HW and read by Host.
30  * @MGMT_RX_REO_SHARED_SNAPSHOT_FW_CONSUMED: FW consumed snapshot
31  * @MGMT_RX_REO_SHARED_SNAPSHOT_FW_FORWARDED: FW forwarded snapshot
32  * @MGMT_RX_REO_SHARED_SNAPSHOT_MAC_HW: MAC HW snapshot
33  * @MGMT_RX_REO_SHARED_SNAPSHOT_MAX: Max number of snapshots
34  * @MGMT_RX_REO_SHARED_SNAPSHOT_INVALID: Invalid snapshot
35  */
36 enum mgmt_rx_reo_shared_snapshot_id {
37 	MGMT_RX_REO_SHARED_SNAPSHOT_FW_CONSUMED = 0,
38 	MGMT_RX_REO_SHARED_SNAPSHOT_FW_FORWARDED = 1,
39 	MGMT_RX_REO_SHARED_SNAPSHOT_MAC_HW = 2,
40 	MGMT_RX_REO_SHARED_SNAPSHOT_MAX = 3,
41 	MGMT_RX_REO_SHARED_SNAPSHOT_INVALID,
42 };
43 
44 /*
45  * struct mgmt_rx_reo_shared_snapshot - Represents the management rx-reorder
46  * shared snapshots
47  * @mgmt_rx_reo_snapshot_low: Lower 32 bits of the reo snapshot
48  * @mgmt_rx_reo_snapshot_high: Higher 32 bits of the reo snapshot
49  */
50 struct mgmt_rx_reo_shared_snapshot {
51 	union {
52 		uint32_t mgmt_rx_reo_snapshot_low;
53 		uint32_t mgmt_pkt_ctr_ver_a:16,
54 			 global_timestamp_redundant_ver_a:15,
55 			 valid_ver_a:1;
56 		uint32_t global_timestamp_low_ver_b:15,
57 			 mgmt_pkt_ctr_ver_b:16,
58 			 valid_ver_b:1;
59 	};
60 
61 	union {
62 		uint32_t mgmt_rx_reo_snapshot_high;
63 		uint32_t global_timestamp_ver_a;
64 		uint32_t mgmt_pkt_ctr_redundant_ver_b:15,
65 			 global_timestamp_high_ver_b:17;
66 	};
67 };
68 
69 #define MGMT_RX_REO_SNAPSHOT_B2B_READ_SWAR_RETRY_LIMIT     (11)
70 #define MGMT_RX_REO_SNAPSHOT_READ_RETRY_LIMIT              (25)
71 
72 /*
73  * struct mgmt_rx_reo_snapshot_params - Represents the simplified version of
74  * Management Rx Frame snapshot for Host use. Note that this is different from
75  * the structure shared between the Host and FW/HW
76  * @valid: Whether this snapshot is valid
77  * @retry_count: snapshot read retry count
78  * @mgmt_pkt_ctr: MGMT packet counter. This will be local to a particular
79  * HW link
80  * @global_timestamp: Global timestamp.This is taken from a clock which is
81  * common across all the HW links
82  */
83 struct mgmt_rx_reo_snapshot_params {
84 	bool valid;
85 	uint8_t retry_count;
86 	uint16_t mgmt_pkt_ctr;
87 	uint32_t global_timestamp;
88 };
89 
90 /*
91  * struct mgmt_rx_reo_snapshot_info - Information related to management Rx
92  * reorder snapshot
93  * @address: Snapshot address
94  * @version: Snapshot version
95  */
96 struct mgmt_rx_reo_snapshot_info {
97 	struct mgmt_rx_reo_shared_snapshot *address;
98 	uint8_t version;
99 };
100 
101 /*
102  * struct mgmt_rx_reo_params - MGMT Rx REO parameters
103  * @valid: Whether these params are valid
104  * @pdev_id: pdev ID for which FW consumed event is received
105  * @link_id: link ID for which FW consumed event is received
106  * @mgmt_pkt_ctr: MGMT packet counter of the frame that is consumed
107  * @global_timestamp: Global timestamp of the frame that is consumed
108  * @duration_us: duration in us
109  * @start_timestamp: start time stamp
110  * @end_timestamp: end time stamp
111  */
112 struct mgmt_rx_reo_params {
113 	bool valid;
114 	uint8_t pdev_id;
115 	uint8_t link_id;
116 	uint16_t mgmt_pkt_ctr;
117 	uint32_t global_timestamp;
118 	uint16_t duration_us;
119 	uint32_t start_timestamp;
120 	uint32_t end_timestamp;
121 };
122 
123 /*
124  * struct mgmt_rx_reo_filter - MGMT Rx REO filter
125  * @filter_low: Least significant 32-bits of the filter
126  * @filter_high: Most significant 32-bits of the filter
127  */
128 struct mgmt_rx_reo_filter {
129 	uint32_t low;
130 	uint32_t high;
131 };
132 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
133 #endif /* _WLAN_MGMT_TXRX_RX_REO_PUBLIC_STRUCTS_H */
134