1 /*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 * Description: Header file of hmac&dmac message id defined.
15 * Create: 2021-07-14
16 */
17
18 #ifndef WLAN_FEATURE_H
19 #define WLAN_FEATURE_H
20
21 #include "mac_vap_ext.h"
22 #include "mac_device_ext.h"
23 #include "mac_user_ext.h"
24
25 #ifdef __cplusplus
26 #if __cplusplus
27 extern "C" {
28 #endif
29 #endif
30
31 typedef enum {
32 WLAN_FEATURE_INDEX_FTM,
33 WLAN_FEATURE_INDEX_DFS,
34 WLAN_FEATURE_INDEX_M2S,
35 WLAN_FEATURE_INDEX_BTCOEX,
36 WLAN_FEATURE_INDEX_BUTT
37 } wlan_feature_index_enum;
38
39 /*****************************************************************************
40 函 数 名 : hmac_device_get_feature_ptr
41 功能描述 : 通过特性索引获取hmac_device下的特性指针
42 *****************************************************************************/
hmac_device_get_feature_ptr(hmac_device_stru * hmac_device,wlan_feature_index_enum feature_index)43 static INLINE__ osal_void *hmac_device_get_feature_ptr(hmac_device_stru *hmac_device,
44 wlan_feature_index_enum feature_index)
45 {
46 return (osal_void *)hmac_device->hmac_device_feature_arr[feature_index];
47 }
48
49 /*****************************************************************************
50 函 数 名 : hmac_device_feature_registered
51 功能描述 : 在hmac_device结构体下注册特性指针
52 *****************************************************************************/
hmac_device_feature_registered(hmac_device_stru * hmac_device,wlan_feature_index_enum feature_index,osal_void * feature_ptr)53 static INLINE__ osal_u32 hmac_device_feature_registered(hmac_device_stru *hmac_device,
54 wlan_feature_index_enum feature_index, osal_void *feature_ptr)
55 {
56 if (hmac_device->hmac_device_feature_arr[feature_index] != OAL_PTR_NULL) {
57 return OAL_FAIL;
58 }
59 hmac_device->hmac_device_feature_arr[feature_index] = feature_ptr;
60
61 return OAL_SUCC;
62 }
63
64 /*****************************************************************************
65 函 数 名 : hmac_device_feature_cancellation
66 功能描述 : 在hmac_device结构体下去注册特性指针
67 *****************************************************************************/
hmac_device_feature_unregister(hmac_device_stru * hmac_device,wlan_feature_index_enum feature_index)68 static INLINE__ osal_void hmac_device_feature_unregister(hmac_device_stru *hmac_device,
69 wlan_feature_index_enum feature_index)
70 {
71 hmac_device->hmac_device_feature_arr[feature_index] = OAL_PTR_NULL;
72 }
73
74 /*****************************************************************************
75 函 数 名 : hmac_device_feature_init
76 功能描述 : 在hmac_device结构体下特性指针数组内存申请
77 *****************************************************************************/
hmac_device_feature_init(hmac_device_stru * hmac_device)78 static INLINE__ osal_u32 hmac_device_feature_init(hmac_device_stru *hmac_device)
79 {
80 if (hmac_device->hmac_device_feature_arr == OAL_PTR_NULL) {
81 hmac_device->hmac_device_feature_arr = (osal_void **) oal_mem_alloc(OAL_MEM_POOL_ID_LOCAL,
82 sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT, OAL_TRUE);
83 if (hmac_device->hmac_device_feature_arr == OAL_PTR_NULL) {
84 return OAL_FAIL;
85 }
86 }
87 (osal_void)memset_s(hmac_device->hmac_device_feature_arr, sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT,
88 0, sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT);
89
90 return OAL_SUCC;
91 }
92
93 /*****************************************************************************
94 函 数 名 : hmac_device_feature_deinit
95 功能描述 : 在hmac_device结构体下特性指针数组内存释放
96 *****************************************************************************/
hmac_device_feature_deinit(hmac_device_stru * hmac_device)97 static INLINE__ osal_u32 hmac_device_feature_deinit(hmac_device_stru *hmac_device)
98 {
99 if (hmac_device->hmac_device_feature_arr != OAL_PTR_NULL) {
100 oal_mem_free(hmac_device->hmac_device_feature_arr, OAL_TRUE);
101 hmac_device->hmac_device_feature_arr = OAL_PTR_NULL;
102 }
103
104 return OAL_SUCC;
105 }
106
107 /*****************************************************************************
108 函 数 名 : hmac_vap_get_feature_ptr
109 功能描述 : 通过特性索引获取hmac_vap下的特性指针
110 *****************************************************************************/
hmac_vap_get_feature_ptr(const hmac_vap_stru * hmac_vap,wlan_feature_index_enum feature_index)111 static INLINE__ osal_void *hmac_vap_get_feature_ptr(const hmac_vap_stru *hmac_vap,
112 wlan_feature_index_enum feature_index)
113 {
114 if (hmac_vap->hmac_vap_feature_arr == OSAL_NULL) {
115 return OSAL_NULL;
116 }
117 return (osal_void *)hmac_vap->hmac_vap_feature_arr[feature_index];
118 }
119
120 /*****************************************************************************
121 函 数 名 : hmac_vap_feature_registered
122 功能描述 : 在hmac_vap结构体下注册特性指针
123 *****************************************************************************/
hmac_vap_feature_registered(hmac_vap_stru * hmac_vap,wlan_feature_index_enum feature_index,osal_void * feature_ptr)124 static INLINE__ osal_u32 hmac_vap_feature_registered(hmac_vap_stru *hmac_vap,
125 wlan_feature_index_enum feature_index, osal_void *feature_ptr)
126 {
127 if (hmac_vap->hmac_vap_feature_arr[feature_index] != OAL_PTR_NULL) {
128 return OAL_FAIL;
129 }
130 hmac_vap->hmac_vap_feature_arr[feature_index] = feature_ptr;
131
132 return OAL_SUCC;
133 }
134
135 /*****************************************************************************
136 函 数 名 : hmac_vap_feature_cancellation
137 功能描述 : 在hmac_vap结构体下去注册特性指针
138 *****************************************************************************/
hmac_vap_feature_unregister(hmac_vap_stru * hmac_vap,wlan_feature_index_enum feature_index)139 static INLINE__ osal_void hmac_vap_feature_unregister(hmac_vap_stru *hmac_vap,
140 wlan_feature_index_enum feature_index)
141 {
142 hmac_vap->hmac_vap_feature_arr[feature_index] = OAL_PTR_NULL;
143 }
144
145 /*****************************************************************************
146 函 数 名 : hmac_vap_feature_init
147 功能描述 : 在hmac_vap结构体下特性指针数组内存申请
148 *****************************************************************************/
hmac_vap_feature_init(hmac_vap_stru * hmac_vap)149 static INLINE__ osal_u32 hmac_vap_feature_init(hmac_vap_stru *hmac_vap)
150 {
151 if (hmac_vap->hmac_vap_feature_arr != OAL_PTR_NULL) {
152 return OAL_SUCC;
153 }
154
155 hmac_vap->hmac_vap_feature_arr = (osal_void **)oal_mem_alloc(OAL_MEM_POOL_ID_LOCAL,
156 sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT, OAL_TRUE);
157 if (hmac_vap->hmac_vap_feature_arr == OAL_PTR_NULL) {
158 return OAL_FAIL;
159 }
160 (osal_void)memset_s(hmac_vap->hmac_vap_feature_arr, sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT,
161 0, sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT);
162
163 return OAL_SUCC;
164 }
165
166 /*****************************************************************************
167 函 数 名 : hmac_vap_feature_deinit
168 功能描述 : 在hmac_vap结构体下特性指针数组内存释放
169 *****************************************************************************/
hmac_vap_feature_deinit(hmac_vap_stru * hmac_vap)170 static INLINE__ osal_u32 hmac_vap_feature_deinit(hmac_vap_stru *hmac_vap)
171 {
172 if (hmac_vap->hmac_vap_feature_arr != OAL_PTR_NULL) {
173 oal_mem_free(hmac_vap->hmac_vap_feature_arr, OAL_TRUE);
174 hmac_vap->hmac_vap_feature_arr = OAL_PTR_NULL;
175 }
176
177 return OAL_SUCC;
178 }
179
180 /*****************************************************************************
181 函 数 名 : hmac_user_get_feature_ptr
182 功能描述 : 通过特性索引获取hmac_user下的特性指针
183 *****************************************************************************/
hmac_user_get_feature_ptr(hmac_user_stru * hmac_user,wlan_feature_index_enum feature_index)184 static INLINE__ osal_u8 *hmac_user_get_feature_ptr(hmac_user_stru *hmac_user,
185 wlan_feature_index_enum feature_index)
186 {
187 return (osal_u8 *)hmac_user->hmac_user_feature_arr[feature_index];
188 }
189
190 /*****************************************************************************
191 函 数 名 : hmac_user_feature_registered
192 功能描述 : 在hmac_user结构体下注册特性指针
193 *****************************************************************************/
hmac_user_feature_registered(hmac_user_stru * hmac_user,wlan_feature_index_enum feature_index,osal_void * feature_ptr)194 static INLINE__ osal_u32 hmac_user_feature_registered(hmac_user_stru *hmac_user,
195 wlan_feature_index_enum feature_index, osal_void *feature_ptr)
196 {
197 if (hmac_user->hmac_user_feature_arr[feature_index] != OAL_PTR_NULL) {
198 return OAL_FAIL;
199 }
200 hmac_user->hmac_user_feature_arr[feature_index] = feature_ptr;
201
202 return OAL_SUCC;
203 }
204
205 /*****************************************************************************
206 函 数 名 : hmac_user_feature_cancellation
207 功能描述 : 在hmac_user结构体下去注册特性指针
208 *****************************************************************************/
hmac_user_feature_unregister(hmac_user_stru * hmac_user,wlan_feature_index_enum feature_index)209 static INLINE__ osal_void hmac_user_feature_unregister(hmac_user_stru *hmac_user,
210 wlan_feature_index_enum feature_index)
211 {
212 hmac_user->hmac_user_feature_arr[feature_index] = OAL_PTR_NULL;
213 }
214
215 /*****************************************************************************
216 函 数 名 : hmac_user_feature_init
217 功能描述 : 在hmac_user结构体下特性指针数组内存申请
218 *****************************************************************************/
hmac_user_feature_init(hmac_user_stru * hmac_user)219 static INLINE__ osal_u32 hmac_user_feature_init(hmac_user_stru *hmac_user)
220 {
221 if (hmac_user->hmac_user_feature_arr == OAL_PTR_NULL) {
222 hmac_user->hmac_user_feature_arr = (osal_void **) oal_mem_alloc(OAL_MEM_POOL_ID_LOCAL,
223 sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT, OAL_TRUE);
224 if (hmac_user->hmac_user_feature_arr == OAL_PTR_NULL) {
225 return OAL_FAIL;
226 }
227 }
228 (osal_void)memset_s(hmac_user->hmac_user_feature_arr, sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT,
229 0, sizeof(osal_void *) * WLAN_FEATURE_INDEX_BUTT);
230
231 return OAL_SUCC;
232 }
233
234 /*****************************************************************************
235 函 数 名 : hmac_user_feature_deinit
236 功能描述 : 在hmac_user结构体下特性指针数组内存释放
237 *****************************************************************************/
hmac_user_feature_deinit(hmac_user_stru * hmac_user)238 static INLINE__ osal_u32 hmac_user_feature_deinit(hmac_user_stru *hmac_user)
239 {
240 if (hmac_user->hmac_user_feature_arr != OAL_PTR_NULL) {
241 oal_mem_free(hmac_user->hmac_user_feature_arr, OAL_TRUE);
242 hmac_user->hmac_user_feature_arr = OAL_PTR_NULL;
243 }
244
245 return OAL_SUCC;
246 }
247
248 #ifdef __cplusplus
249 #if __cplusplus
250 }
251 #endif
252 #endif
253
254 #endif
255