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_api.c 20 * This file contains definition of functions that MLO global 21 * shared memory arena exposes. 22 */ 23 #include <mlo_global_h_shmem_arena.h> 24 25 #ifdef WLAN_MGMT_RX_REO_SUPPORT 26 /** 27 * mgmt_rx_reo_snapshot_is_valid() - Check if an MGMT Rx REO snapshot is valid 28 * @snapshot_low: lower 32-bits of the snapshot 29 * @snapshot_version: snapshot version 30 * 31 * Return: true if snapshot is valid, else false 32 */ 33 static bool mgmt_rx_reo_snapshot_is_valid(uint32_t snapshot_low, 34 uint8_t snapshot_version) 35 { 36 return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_VALID_GET(snapshot_low, 37 snapshot_version); 38 } 39 40 /** 41 * mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr() - Get the management packet counter 42 * from an MGMT Rx REO snapshot 43 * @snapshot_low: lower 32-bits of the snapshot 44 * @snapshot_version: snapshot version 45 * 46 * Return: Management packet counter of the snapshot 47 */ 48 static uint16_t mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr(uint32_t snapshot_low, 49 uint8_t snapshot_version) 50 { 51 return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_MGMT_PKT_CTR_GET 52 (snapshot_low, snapshot_version); 53 } 54 55 /** 56 * mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr() - Get the redundant management packet 57 * counter from MGMT Rx REO snapshot 58 * @snapshot_high: higher 32-bits of the snapshot 59 * 60 * Return: Redundant management packet counter of the snapshot 61 */ 62 static uint16_t mgmt_rx_reo_snapshot_get_redundant_mgmt_pkt_ctr 63 (uint32_t snapshot_high) 64 { 65 return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_MGMT_PKT_CTR_REDUNDANT_GET 66 (snapshot_high); 67 } 68 69 /** 70 * mgmt_rx_reo_snapshot_is_consistent() - Check if an MGMT Rx REO snapshot is 71 * consistent 72 * @snapshot_low: lower 32-bits of the snapshot 73 * @snapshot_high: higher 32-bits of the snapshot 74 * @snapshot_version: snapshot version 75 * 76 * Return: true if the snapshot is consistent, else false 77 */ 78 static bool mgmt_rx_reo_snapshot_is_consistent(uint32_t snapshot_low, 79 uint32_t snapshot_high, 80 uint8_t snapshot_version) 81 { 82 return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_CHECK_CONSISTENCY(snapshot_low, 83 snapshot_high, snapshot_version); 84 } 85 86 /** 87 * mgmt_rx_reo_snapshot_get_global_timestamp() - Get the global timestamp from 88 * MGMT Rx REO snapshot 89 * @snapshot_low: lower 32-bits of the snapshot 90 * @snapshot_high: higher 32-bits of the snapshot 91 * 92 * Return: Global timestamp of the snapshot 93 */ 94 static uint32_t mgmt_rx_reo_snapshot_get_global_timestamp( 95 uint32_t snapshot_low, uint32_t snapshot_high, uint8_t snapshot_version) 96 { 97 return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_GLOBAL_TIMESTAMP_GET 98 (snapshot_low, snapshot_high, snapshot_version); 99 } 100 101 QDF_STATUS mgmt_rx_reo_register_wifi3_0_ops( 102 struct wlan_lmac_if_mgmt_rx_reo_low_level_ops *reo_low_level_ops) 103 { 104 if (!reo_low_level_ops) { 105 target_if_err("Low level ops of MGMT Rx REO is null"); 106 return QDF_STATUS_E_NULL_VALUE; 107 } 108 109 reo_low_level_ops->get_valid_link_bitmap = 110 mgmt_rx_reo_get_valid_link_bitmap; 111 reo_low_level_ops->get_num_links = mgmt_rx_reo_get_num_links; 112 reo_low_level_ops->get_snapshot_address = 113 mgmt_rx_reo_get_snapshot_address; 114 reo_low_level_ops->get_snapshot_version = 115 mgmt_rx_reo_get_snapshot_version; 116 reo_low_level_ops->snapshot_is_valid = 117 mgmt_rx_reo_snapshot_is_valid; 118 reo_low_level_ops->snapshot_get_mgmt_pkt_ctr = 119 mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr; 120 reo_low_level_ops->snapshot_get_redundant_mgmt_pkt_ctr = 121 mgmt_rx_reo_snapshot_get_redundant_mgmt_pkt_ctr; 122 reo_low_level_ops->snapshot_is_consistent = 123 mgmt_rx_reo_snapshot_is_consistent; 124 reo_low_level_ops->snapshot_get_global_timestamp = 125 mgmt_rx_reo_snapshot_get_global_timestamp; 126 127 reo_low_level_ops->implemented = true; 128 129 return QDF_STATUS_SUCCESS; 130 } 131 #endif 132 133 #ifdef WLAN_MLO_GLOBAL_SHMEM_SUPPORT 134 static inline 135 void global_shmem_register_target_recovery_ops( 136 struct wlan_lmac_if_global_shmem_local_ops *shmem_local_ops) 137 { 138 if (!shmem_local_ops) { 139 target_if_err("Low level ops of global shmem is NULL"); 140 return; 141 } 142 143 shmem_local_ops->get_crash_reason_address = 144 mlo_glb_h_shmem_arena_get_crash_reason_address; 145 shmem_local_ops->get_no_of_chips_from_crash_info = 146 mlo_glb_h_shmem_arena_get_no_of_chips_from_crash_info; 147 } 148 #else 149 static inline 150 void global_shmem_register_target_recovery_ops( 151 struct wlan_lmac_if_global_shmem_local_ops *shmem_local_ops) 152 { 153 if (!shmem_local_ops) { 154 target_if_err("Low level ops of global shmem is NULL"); 155 return; 156 } 157 158 shmem_local_ops->get_crash_reason_address = NULL; 159 shmem_local_ops->get_no_of_chips_from_crash_info = NULL; 160 } 161 #endif 162 163 QDF_STATUS global_shmem_register_wifi3_0_ops( 164 struct wlan_lmac_if_global_shmem_local_ops *shmem_local_ops) 165 { 166 if (!shmem_local_ops) { 167 target_if_err("Low level ops of global shmem is NULL"); 168 return QDF_STATUS_E_NULL_VALUE; 169 } 170 171 shmem_local_ops->init_shmem_arena_ctx = 172 mlo_glb_h_shmem_arena_ctx_init; 173 shmem_local_ops->deinit_shmem_arena_ctx = 174 mlo_glb_h_shmem_arena_ctx_deinit; 175 176 global_shmem_register_target_recovery_ops(shmem_local_ops); 177 178 shmem_local_ops->implemented = true; 179 180 return QDF_STATUS_SUCCESS; 181 } 182