xref: /wlan-driver/qca-wifi-host-cmn/target_if/init_deinit/inc/mlo_global_h_shmem_arena.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-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: mlo_global_h_shmem_arena.h
20  *  This file contains APIs and data structures that are used to parse the MLO
21  *  global shared memory arena.
22  */
23 
24 #ifndef _MLO_GLOBAL_H_SHMEM_ARENA_H_
25 #define _MLO_GLOBAL_H_SHMEM_ARENA_H_
26 
27 #include <qdf_types.h>
28 #include <target_if.h>
29 #include "wmi.h"
30 #include <osdep.h>
31 
32 #define MGMT_RX_REO_INVALID_SNAPSHOT_VERSION      (-1)
33 
34 /**
35  * struct wlan_host_mlo_glb_h_shmem_params - MLO global shared memory parameters
36  * @major_version: Major version
37  * @minor_version: Minor version
38  */
39 struct wlan_host_mlo_glb_h_shmem_params {
40 	uint16_t major_version;
41 	uint16_t minor_version;
42 };
43 
44 /**
45  * struct wlan_host_mlo_glb_rx_reo_per_link_info - MGMT Rx REO
46  * information of a link in MLO global shared memory
47  * @link_id: Hardware link ID
48  * @fw_consumed: Address of FW consumed snapshot
49  * @fw_forwarded: Address of FW forwarded snapshot
50  * @hw_forwarded: Address of HW forwarded snapshot
51  */
52 struct wlan_host_mlo_glb_rx_reo_per_link_info {
53 	uint8_t link_id;
54 	void *fw_consumed;
55 	void *fw_forwarded;
56 	void *hw_forwarded;
57 };
58 
59 /**
60  * struct wlan_host_mlo_glb_rx_reo_snapshot_info - MGMT Rx REO
61  * information in MLO global shared memory
62  * @num_links: Number of valid links
63  * @valid_link_bmap: Valid link bitmap
64  * @link_info: pointer to an array of Rx REO per-link information
65  * @hw_forwarded_snapshot_ver: HW forwarded snapshot version
66  * @fw_forwarded_snapshot_ver: FW forwarded snapshot version
67  * @fw_consumed_snapshot_ver: FW consumed snapshot version
68  */
69 struct wlan_host_mlo_glb_rx_reo_snapshot_info {
70 	uint8_t num_links;
71 	uint16_t valid_link_bmap;
72 	struct wlan_host_mlo_glb_rx_reo_per_link_info *link_info;
73 	uint8_t hw_forwarded_snapshot_ver;
74 	uint8_t fw_forwarded_snapshot_ver;
75 	uint8_t fw_consumed_snapshot_ver;
76 };
77 
78 /**
79  * struct wlan_host_mlo_glb_per_chip_crash_info - per chip crash
80  * information in MLO global shared memory
81  * @chip_id: MLO Chip ID
82  * @crash_reason: Address of the crash_reason corresponding to chip_id
83  * @recovery_mode: Address of the recovery mode corresponding to chip_id
84  */
85 struct wlan_host_mlo_glb_per_chip_crash_info {
86 	uint8_t chip_id;
87 	void *crash_reason;
88 	void *recovery_mode;
89 };
90 
91 /**
92  * struct wlan_host_mlo_glb_chip_crash_info - chip crash information in MLO
93  *                                            global shared memory
94  * @no_of_chips: No of partner chip to which crash information is shared
95  * @valid_chip_bmap: Bitmap to indicate the chip to which the crash information
96  * is shared
97  * @per_chip_crash_info: pointer to an array of crash information associated
98  * with each chip
99  */
100 struct wlan_host_mlo_glb_chip_crash_info {
101 	uint8_t no_of_chips;
102 	qdf_bitmap(valid_chip_bmap, QDF_CHAR_BIT);
103 	struct wlan_host_mlo_glb_per_chip_crash_info *per_chip_crash_info;
104 };
105 
106 /**
107  * struct wlan_host_mlo_glb_h_shmem_arena_ctx - MLO Global shared
108  *                                              memory arena context
109  * @shmem_params: shared memory parameters
110  * @rx_reo_snapshot_info: MGMT Rx REO snapshot information
111  * @chip_crash_info: chip crash information
112  * @init_count: Number of init calls
113  */
114 struct wlan_host_mlo_glb_h_shmem_arena_ctx {
115 	struct wlan_host_mlo_glb_h_shmem_params shmem_params;
116 	struct wlan_host_mlo_glb_rx_reo_snapshot_info rx_reo_snapshot_info;
117 	struct wlan_host_mlo_glb_chip_crash_info chip_crash_info;
118 	qdf_atomic_t init_count;
119 };
120 
121 #ifdef WLAN_MLO_GLOBAL_SHMEM_SUPPORT
122 /**
123  * mlo_glb_h_shmem_arena_ctx_init() - Initialize MLO Global shared memory arena
124  * context on Host
125  * @arena_vaddr: Virtual address of the MLO Global shared memory arena
126  * @arena_len: Length (in bytes) of the MLO Global shared memory arena
127  * @grp_id: Id of the required MLO Group
128  *
129  * Return: QDF_STATUS of operation
130  */
131 QDF_STATUS mlo_glb_h_shmem_arena_ctx_init(void *arena_vaddr,
132 					  size_t arena_len,
133 					  uint8_t grp_id);
134 
135 /**
136  * mlo_glb_h_shmem_arena_ctx_deinit() - De-initialize MLO Global shared memory
137  * arena context on Host
138  * @grp_id: Id of the required MLO Group
139  *
140  * Return: QDF_STATUS of operation
141  */
142 QDF_STATUS mlo_glb_h_shmem_arena_ctx_deinit(uint8_t grp_id);
143 #endif
144 
145 #ifdef WLAN_MLO_GLOBAL_SHMEM_SUPPORT
146 /**
147  * mlo_glb_h_shmem_arena_get_crash_reason_address(): get the address of crash
148  * reason associated with chip_id
149  * @grp_id: Id of the required MLO Group
150  * @chip_id: Id of the MLO chip
151  *
152  * Return: Address of crash_reason field from global shmem arena in case of
153  * success, else returns NULL
154  */
155 void *mlo_glb_h_shmem_arena_get_crash_reason_address(uint8_t grp_id,
156 						     uint8_t chip_id);
157 
158 /**
159  * mlo_glb_h_shmem_arena_get_recovery_mode_address() - get the address of
160  * recovery mode associated with chip_id
161  * @grp_id: Id of the required MLO Group
162  * @chip_id: MLO Chip Id
163  *
164  * Return: Address of recovery mode field from global shmem arena in case of
165  * success, else returns NULL
166  */
167 void *mlo_glb_h_shmem_arena_get_recovery_mode_address(uint8_t grp_id,
168 						      uint8_t chip_id);
169 
170 /**
171  * mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info() - Get number of chips
172  * from crash info
173  * @grp_id: Id of the required MLO Group
174  *
175  * Return: number of chips participating in MLO from crash info shared by target
176  * in case of sccess, else returns 0
177  */
178 uint8_t mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info(uint8_t grp_id);
179 #endif
180 
181 #ifdef WLAN_MGMT_RX_REO_SUPPORT
182 /**
183  * mgmt_rx_reo_get_valid_link_bitmap() - Get valid link bitmap
184  * @grp_id: Id of the required MLO Group
185  *
186  * Return: valid link bitmap
187  */
188 uint16_t mgmt_rx_reo_get_valid_link_bitmap(uint8_t grp_id);
189 
190 /**
191  * mgmt_rx_reo_get_num_links() - Get number of links to be used by MGMT Rx REO
192  * @grp_id: Id of the required MLO Group
193  *
194  * Return: number of links in case of success, else -1
195  */
196 int mgmt_rx_reo_get_num_links(uint8_t grp_id);
197 
198 /**
199  * mgmt_rx_reo_get_snapshot_address() - Get the address of MGMT Rx REO snapshot
200  * @grp_id: Id of the required MLO Group
201  * @link_id: Link ID of the radio to which this snapshot belongs
202  * @snapshot_id: ID of the snapshot
203  *
204  * Return: virtual address of the snapshot on success, else NULL
205  */
206 void *mgmt_rx_reo_get_snapshot_address(
207 		uint8_t grp_id,
208 		uint8_t link_id,
209 		enum mgmt_rx_reo_shared_snapshot_id snapshot_id);
210 
211 /**
212  * mgmt_rx_reo_get_snapshot_version() - Get the version of MGMT Rx REO snapshot
213  * @grp_id: Id of the required MLO Group
214  * @snapshot_id: ID of the snapshot
215  *
216  * Return: Snapshot version
217  */
218 int8_t mgmt_rx_reo_get_snapshot_version
219 			(uint8_t grp_id,
220 			 enum mgmt_rx_reo_shared_snapshot_id snapshot_id);
221 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
222 #endif
223