xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/inc/mlo_global_h_shmem_arena.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 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: 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  * 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  * wlan_host_mlo_glb_rx_reo_per_link_info - MGMT Rx REO information of a link in
46  * 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  * wlan_host_mlo_glb_rx_reo_snapshot_info - MGMT Rx REO information in MLO
61  * 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  * wlan_host_mlo_glb_per_chip_crash_info - per chip crash information in MLO
80  * global shared memory
81  * @chip_id: MLO Chip ID
82  * @crash_reason: Address of the crash_reason corresponding to chip_id
83  */
84 struct wlan_host_mlo_glb_per_chip_crash_info {
85 	uint8_t chip_id;
86 	void *crash_reason;
87 };
88 
89 /**
90  * wlan_host_mlo_glb_chip_crash_info - chip crash information in MLO
91  * global shared memory
92  * @no_of_chips: No of partner chip to which crash information is shared
93  * @valid_chip_bmap: Bitmap to indicate the chip to which the crash information
94  * is shared
95  * @per_chip_crash_info: pointer to an array of crash information associated
96  * with each chip
97  */
98 struct wlan_host_mlo_glb_chip_crash_info {
99 	uint8_t no_of_chips;
100 	qdf_bitmap(valid_chip_bmap, QDF_CHAR_BIT);
101 	struct wlan_host_mlo_glb_per_chip_crash_info *per_chip_crash_info;
102 };
103 
104 /**
105  * wlan_host_mlo_glb_h_shmem_arena_ctx - MLO Global shared memory arena context
106  * @shmem_params: shared memory parameters
107  * @rx_reo_snapshot_info: MGMT Rx REO snapshot information
108  * @init_count: Number of init calls
109  */
110 struct wlan_host_mlo_glb_h_shmem_arena_ctx {
111 	struct wlan_host_mlo_glb_h_shmem_params shmem_params;
112 	struct wlan_host_mlo_glb_rx_reo_snapshot_info rx_reo_snapshot_info;
113 	struct wlan_host_mlo_glb_chip_crash_info chip_crash_info;
114 	qdf_atomic_t init_count;
115 };
116 
117 #ifdef WLAN_MLO_GLOBAL_SHMEM_SUPPORT
118 /**
119  * mlo_glb_h_shmem_arena_ctx_init() - Initialize MLO Global shared memory arena
120  * context on Host
121  * @arena_vaddr: Virtual address of the MLO Global shared memory arena
122  * @arena_len: Length (in bytes) of the MLO Global shared memory arena
123  * @grp_id: Id of the required MLO Group
124  *
125  * Return: QDF_STATUS of operation
126  */
127 QDF_STATUS mlo_glb_h_shmem_arena_ctx_init(void *arena_vaddr,
128 					  size_t arena_len,
129 					  uint8_t grp_id);
130 
131 /**
132  * mlo_glb_h_shmem_arena_ctx_deinit() - De-initialize MLO Global shared memory
133  * arena context on Host
134  * @grp_id: Id of the required MLO Group
135  *
136  * Return: QDF_STATUS of operation
137  */
138 QDF_STATUS mlo_glb_h_shmem_arena_ctx_deinit(uint8_t grp_id);
139 #endif
140 
141 #ifdef WLAN_MLO_GLOBAL_SHMEM_SUPPORT
142 /**
143  * mlo_glb_h_shmem_arena_get_crash_reason_address(): get the address of crash
144  * reason associated with chip_id
145  * @grp_id: Id of the required MLO Group
146  * @chip_id: Id of the MLO chip
147  *
148  * Return: Address of crash_reason field from global shmem arena in case of
149  * success, else returns NULL
150  */
151 void *mlo_glb_h_shmem_arena_get_crash_reason_address(uint8_t grp_id,
152 						     uint8_t chip_id);
153 
154 /**
155  * mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info() - Get number of chips
156  * from crash info
157  * @grp_id: Id of the required MLO Group
158  *
159  * Return: number of chips participating in MLO from crash info shared by target
160  * in case of sccess, else returns 0
161  */
162 uint8_t mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info(uint8_t grp_id);
163 #endif
164 
165 #ifdef WLAN_MGMT_RX_REO_SUPPORT
166 /**
167  * mgmt_rx_reo_get_valid_link_bitmap() - Get valid link bitmap
168  * @grp_id: Id of the required MLO Group
169  *
170  * Return: valid link bitmap
171  */
172 uint16_t mgmt_rx_reo_get_valid_link_bitmap(uint8_t grp_id);
173 
174 /**
175  * mgmt_rx_reo_get_num_links() - Get number of links to be used by MGMT Rx REO
176  * @grp_id: Id of the required MLO Group
177  *
178  * Return: number of links in case of success, else -1
179  */
180 int mgmt_rx_reo_get_num_links(uint8_t grp_id);
181 
182 /**
183  * mgmt_rx_reo_get_snapshot_address() - Get the address of MGMT Rx REO snapshot
184  * @grp_id: Id of the required MLO Group
185  * @link_id: Link ID of the radio to which this snapshot belongs
186  * @snapshot_id: ID of the snapshot
187  *
188  * Return: virtual address of the snapshot on success, else NULL
189  */
190 void *mgmt_rx_reo_get_snapshot_address(
191 		uint8_t grp_id,
192 		uint8_t link_id,
193 		enum mgmt_rx_reo_shared_snapshot_id snapshot_id);
194 
195 /**
196  * mgmt_rx_reo_get_snapshot_version() - Get the version of MGMT Rx REO snapshot
197  * @grp_id: Id of the required MLO Group
198  * @snapshot_id: ID of the snapshot
199  *
200  * Return: Snapshot version
201  */
202 int8_t mgmt_rx_reo_get_snapshot_version
203 			(uint8_t grp_id,
204 			 enum mgmt_rx_reo_shared_snapshot_id snapshot_id);
205 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
206 #endif
207