xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/inc/mlo_global_h_shmem_arena.h (revision 87ce989ee0b2172d08cfc0e040cdb9ca3fcce1e8)
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_forwaded_snapshot_ver: HW forwaded snapshot version
66  * @fw_forwaded_snapshot_ver: FW forwaded 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_forwaded_snapshot_ver;
74 	uint8_t fw_forwaded_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  *
124  * Return: QDF_STATUS of operation
125  */
126 QDF_STATUS mlo_glb_h_shmem_arena_ctx_init(void *arena_vaddr,
127 					  size_t arena_len);
128 
129 /**
130  * mlo_glb_h_shmem_arena_ctx_deinit() - De-initialize MLO Global shared memory
131  * arena context on Host
132  *
133  * Return: QDF_STATUS of operation
134  */
135 QDF_STATUS mlo_glb_h_shmem_arena_ctx_deinit(void);
136 #endif
137 
138 #ifdef WLAN_MLO_GLOBAL_SHMEM_SUPPORT
139 /**
140  * mlo_glb_h_shmem_arena_get_crash_reason_address(): get the address of crash
141  * reason associated with chip_id
142  *
143  * Return: Address of crash_reason field fron global shmem arena in case of
144  * success, else returns NULL
145  */
146 void *mlo_glb_h_shmem_arena_get_crash_reason_address(uint8_t chip_id);
147 
148 /**
149  * mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info() - Get number of chips
150  * from crash info
151  *
152  * Return: number of chips participating in MLO from crash info shared by target
153  * in case of sccess, else returns 0
154  */
155 uint8_t mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info(void);
156 #endif
157 
158 #ifdef WLAN_MGMT_RX_REO_SUPPORT
159 /**
160  * mgmt_rx_reo_get_valid_link_bitmap() - Get valid link bitmap
161  *
162  * Return: valid link bitmap
163  */
164 uint16_t mgmt_rx_reo_get_valid_link_bitmap(void);
165 
166 /**
167  * mgmt_rx_reo_get_num_links() - Get number of links to be used by MGMT Rx REO
168  *
169  * Return: number of links in case of success, else -1
170  */
171 int mgmt_rx_reo_get_num_links(void);
172 
173 /**
174  * mgmt_rx_reo_get_snapshot_address() - Get the address of MGMT Rx REO snapshot
175  * @link_id: Link ID of the radio to which this snapshot belongs
176  * @snapshot_id: ID of the snapshot
177  *
178  * Return: virtual address of the snapshot on success, else NULL
179  */
180 void *mgmt_rx_reo_get_snapshot_address(
181 	uint8_t link_id, enum mgmt_rx_reo_shared_snapshot_id snapshot_id);
182 
183 /**
184  * mgmt_rx_reo_get_snapshot_version() - Get the version of MGMT Rx REO snapshot
185  * @snapshot_id: ID of the snapshot
186  *
187  * Return: Snapshot version
188  */
189 int8_t mgmt_rx_reo_get_snapshot_version
190 			(enum mgmt_rx_reo_shared_snapshot_id snapshot_id);
191 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
192 #endif
193