1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 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 		struct {
54 			uint32_t mgmt_pkt_ctr_ver_a:16;
55 			uint32_t global_timestamp_redundant_ver_a:15;
56 			uint32_t valid_ver_a:1;
57 		};
58 		struct {
59 			uint32_t global_timestamp_low_ver_b:15;
60 			uint32_t mgmt_pkt_ctr_ver_b:16;
61 			uint32_t valid_ver_b:1;
62 		};
63 	};
64 
65 	union {
66 		uint32_t mgmt_rx_reo_snapshot_high;
67 		uint32_t global_timestamp_ver_a;
68 		struct {
69 			uint32_t mgmt_pkt_ctr_redundant_ver_b:15;
70 			uint32_t global_timestamp_high_ver_b:17;
71 		};
72 	};
73 };
74 
75 #define MGMT_RX_REO_SNAPSHOT_B2B_READ_SWAR_RETRY_LIMIT     (11)
76 #define MGMT_RX_REO_SNAPSHOT_READ_RETRY_LIMIT              (25)
77 
78 /*
79  * struct mgmt_rx_reo_snapshot_params - Represents the simplified version of
80  * Management Rx Frame snapshot for Host use. Note that this is different from
81  * the structure shared between the Host and FW/HW
82  * @valid: Whether this snapshot is valid
83  * @retry_count: snapshot read retry count
84  * @mgmt_pkt_ctr: MGMT packet counter. This will be local to a particular
85  * HW link
86  * @global_timestamp: Global timestamp.This is taken from a clock which is
87  * common across all the HW links
88  */
89 struct mgmt_rx_reo_snapshot_params {
90 	bool valid;
91 	uint8_t retry_count;
92 	uint16_t mgmt_pkt_ctr;
93 	uint32_t global_timestamp;
94 };
95 
96 /*
97  * struct mgmt_rx_reo_snapshot_info - Information related to management Rx
98  * reorder snapshot
99  * @address: Snapshot address
100  * @version: Snapshot version
101  */
102 struct mgmt_rx_reo_snapshot_info {
103 	struct mgmt_rx_reo_shared_snapshot *address;
104 	uint8_t version;
105 };
106 
107 /*
108  * struct mgmt_rx_reo_params - MGMT Rx REO parameters
109  * @valid: Whether these params are valid
110  * @pdev_id: pdev ID for which FW consumed event is received
111  * @link_id: link ID for which FW consumed event is received
112  * @mlo_grp_id: MLO group ID which it belongs to
113  * @mgmt_pkt_ctr: MGMT packet counter of the frame that is consumed
114  * @global_timestamp: Global timestamp of the frame that is consumed
115  * @duration_us: duration in us
116  * @start_timestamp: start time stamp
117  * @end_timestamp: end time stamp
118  */
119 struct mgmt_rx_reo_params {
120 	bool valid;
121 	uint8_t pdev_id;
122 	uint8_t link_id;
123 	uint8_t mlo_grp_id;
124 	uint16_t mgmt_pkt_ctr;
125 	uint32_t global_timestamp;
126 	uint16_t duration_us;
127 	uint32_t start_timestamp;
128 	uint32_t end_timestamp;
129 };
130 
131 /*
132  * struct mgmt_rx_reo_filter - MGMT Rx REO filter
133  * @filter_low: Least significant 32-bits of the filter
134  * @filter_high: Most significant 32-bits of the filter
135  */
136 struct mgmt_rx_reo_filter {
137 	uint32_t low;
138 	uint32_t high;
139 };
140 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
141 #endif /* _WLAN_MGMT_TXRX_RX_REO_PUBLIC_STRUCTS_H */
142