xref: /wlan-dirver/qca-wifi-host-cmn/target_if/init_deinit/src/mlo_global_h_shmem_arena_api.c (revision 2f4b444fb7e689b83a4ab0e7b3b38f0bf4def8e0)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 /**
18  *  DOC: mlo_global_h_shmem_arena_api.c
19  *  This file contains definition of functions that MLO global
20  *  shared memory arena exposes.
21  */
22 #include <mlo_global_h_shmem_arena.h>
23 
24 /**
25  * mgmt_rx_reo_snapshot_is_valid() - Check if an MGMT Rx REO snapshot is valid
26  * @snapshot_low: lower 32-bits of the snapshot
27  *
28  * Return: true if snapshot is valid, else false
29  */
30 static bool mgmt_rx_reo_snapshot_is_valid(uint32_t snapshot_low)
31 {
32 	return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_PARAM_VALID_GET(snapshot_low);
33 }
34 
35 /**
36  * mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr() - Get the management packet counter
37  * from an MGMT Rx REO snapshot
38  * @snapshot_low: lower 32-bits of the snapshot
39  *
40  * Return: Management packet counter of the snapshot
41  */
42 static uint16_t mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr(uint32_t snapshot_low)
43 {
44 	return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_PARAM_MGMT_PKT_CTR_GET(
45 			snapshot_low);
46 }
47 
48 /**
49  * mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr() - Get the redundant management packet
50  * counter from MGMT Rx REO snapshot
51  * @snapshot_high: higher 32-bits of the snapshot
52  *
53  * Return: Redundant management packet counter of the snapshot
54  */
55 static uint16_t mgmt_rx_reo_snapshot_get_redundant_mgmt_pkt_ctr(
56 	uint32_t snapshot_high)
57 {
58 	return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_PARAM_MGMT_PKT_CTR_REDUNDANT_GET(
59 			snapshot_high);
60 }
61 
62 /**
63  * mgmt_rx_reo_snapshot_is_consistent() - Check if an MGMT Rx REO snapshot is
64  * consistent
65  * @mgmt_pkt_ctr: Management packet counter of the snapshot
66  * @redundant_mgmt_pkt_ctr: Redundant management packet counter of the snapshot
67  *
68  * Return: true if the snapshot is consistent, else false
69  */
70 static bool mgmt_rx_reo_snapshot_is_consistent(uint16_t mgmt_pkt_ctr,
71 					       uint16_t redundant_mgmt_pkt_ctr)
72 {
73 	return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_IS_CONSISTENT(
74 			mgmt_pkt_ctr, redundant_mgmt_pkt_ctr);
75 }
76 
77 /**
78  * mgmt_rx_reo_snapshot_get_global_timestamp() - Get the global timestamp from
79  * MGMT Rx REO snapshot
80  * @snapshot_low: lower 32-bits of the snapshot
81  * @snapshot_high: higher 32-bits of the snapshot
82  *
83  * Return: Global timestamp of the snapshot
84  */
85 static uint32_t mgmt_rx_reo_snapshot_get_global_timestamp(
86 	uint32_t snapshot_low, uint32_t snapshot_high)
87 {
88 	return MLO_SHMEM_MGMT_RX_REO_SNAPSHOT_PARAM_GLOBAL_TIMESTAMP_GET_FROM_DWORDS(
89 		snapshot_low, snapshot_high);
90 }
91 
92 QDF_STATUS mgmt_rx_reo_register_wifi3_0_ops(
93 	struct wlan_lmac_if_mgmt_rx_reo_low_level_ops *reo_low_level_ops)
94 {
95 	if (!reo_low_level_ops) {
96 		target_if_err("Low level ops of MGMT Rx REO is null");
97 		return QDF_STATUS_E_NULL_VALUE;
98 	}
99 
100 	reo_low_level_ops->init_shmem_arena_ctx =
101 		mlo_glb_h_shmem_arena_ctx_init;
102 	reo_low_level_ops->deinit_shmem_arena_ctx =
103 		mlo_glb_h_shmem_arena_ctx_deinit;
104 	reo_low_level_ops->get_num_links = mgmt_rx_reo_get_num_links;
105 	reo_low_level_ops->get_snapshot_address =
106 		mgmt_rx_reo_get_snapshot_address;
107 	reo_low_level_ops->snapshot_is_valid =
108 		mgmt_rx_reo_snapshot_is_valid;
109 	reo_low_level_ops->snapshot_get_mgmt_pkt_ctr =
110 		mgmt_rx_reo_snapshot_get_mgmt_pkt_ctr;
111 	reo_low_level_ops->snapshot_get_redundant_mgmt_pkt_ctr =
112 		mgmt_rx_reo_snapshot_get_redundant_mgmt_pkt_ctr;
113 	reo_low_level_ops->snapshot_is_consistent =
114 		mgmt_rx_reo_snapshot_is_consistent;
115 	reo_low_level_ops->snapshot_get_global_timestamp =
116 		mgmt_rx_reo_snapshot_get_global_timestamp;
117 
118 	reo_low_level_ops->implemented = true;
119 
120 	return QDF_STATUS_SUCCESS;
121 }
122