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 mac_regdomain_rom.c. 15 * Create: 2020-7-8 16 */ 17 #ifndef __MAC_RESOURCE_EXT_H__ 18 #define __MAC_RESOURCE_EXT_H__ 19 20 /* 文件合一后去掉HMAC、DMAC两个宏 */ 21 #include "oal_ext_if.h" 22 #include "mac_device_ext.h" 23 #include "wlan_resource_common.h" 24 25 #undef THIS_FILE_ID 26 #define THIS_FILE_ID OAM_FILE_ID_MAC_RESOURCE_H 27 28 #ifdef __cplusplus 29 #if __cplusplus 30 extern "C" { 31 #endif 32 #endif 33 34 /***************************************************************************** 35 宏定义 36 *****************************************************************************/ 37 /* 最大dev数量 */ 38 #define MAC_RES_MAX_DEV_NUM WLAN_SERVICE_DEVICE_SUPPORT_MAX_NUM_SPEC 39 40 /* board最大关联用户数 = 1个CHIP支持的最大关联用户数 * board上面的CHIP数目 */ 41 #define MAC_RES_MAX_ASOC_USER_NUM (WLAN_ASSOC_USER_MAX_NUM * WLAN_CHIP_MAX_NUM_PER_BOARD) 42 /* board最大组播用户数 = 整board支持的业务vap个数(每个业务vap一个组播用户) */ 43 #define MAC_RES_MAX_BCAST_USER_NUM (WLAN_MULTI_USER_MAX_NUM_LIMIT) 44 /* board资源最大用户数 = 最大关联用户数 + 组播用户个数 */ 45 #define MAC_RES_MAX_USER_LIMIT (MAC_RES_MAX_ASOC_USER_NUM + MAC_RES_MAX_BCAST_USER_NUM) 46 47 osal_u16 mac_chip_get_max_asoc_user(osal_u8 chip_id); 48 osal_u16 hmac_board_get_max_user(void); 49 hmac_device_stru *hmac_res_get_mac_dev_etc(osal_u32 dev_idx); 50 void* mac_res_get_hmac_vap(osal_u8 idx); 51 void *_mac_res_alloc_hmac_user(osal_u16 idx); 52 void _mac_res_free_hmac_user(osal_u16 idx); 53 void* _mac_res_get_hmac_user(osal_u16 idx); 54 osal_u32 mac_get_hal_vap_id(osal_u8 p2p_mode, osal_u8 vap_mode, osal_u8 *hal_vap_id); 55 56 /***************************************************************************** 57 STRUCT定义 58 *****************************************************************************/ 59 typedef struct { 60 oal_queue_stru queue; 61 osal_ulong idx[MAC_RES_MAX_DEV_NUM]; 62 osal_u8 auc_user_cnt[MAC_RES_MAX_DEV_NUM]; 63 osal_u8 auc_resv[2]; 64 } mac_res_device_stru; 65 66 typedef struct { 67 void *past_vap_info[WLAN_VAP_SUPPORT_MAX_NUM_LIMIT]; 68 oal_queue_stru queue; 69 osal_ulong idx[WLAN_VAP_SUPPORT_MAX_NUM_LIMIT]; 70 osal_u8 auc_user_cnt[WLAN_VAP_SUPPORT_MAX_NUM_LIMIT]; 71 osal_u8 auc_resv[2]; 72 } mac_res_vap_stru; 73 74 typedef struct { 75 void *past_user_info[MAC_RES_MAX_USER_LIMIT]; 76 oal_queue_stru_16 queue; 77 osal_ulong *pul_idx; 78 osal_u8 *user_cnt; 79 } mac_res_user_stru; 80 81 typedef struct { 82 mac_res_device_stru dev_res; 83 mac_res_vap_stru vap_res; 84 mac_res_user_stru user_res; 85 } mac_res_stru; 86 87 /* 存储hmac device结构的资源结构体 */ 88 typedef struct { 89 hmac_device_stru hmac_dev_info[MAC_RES_MAX_DEV_NUM]; 90 oal_queue_stru queue; 91 osal_ulong idx[MAC_RES_MAX_DEV_NUM]; 92 osal_u8 auc_user_cnt[MAC_RES_MAX_DEV_NUM]; 93 #ifdef _PRE_WLAN_FEATURE_DOUBLE_CHIP 94 osal_u8 auc_resv[2]; /* 单芯片下MAC_RES_MAX_DEV_NUM是1,双芯片下MAC_RES_MAX_DEV_NUM是2 */ 95 #else 96 osal_u8 auc_resv[3]; 97 #endif 98 } hmac_res_device_stru; 99 100 /* 存储hmac res资源结构体 */ 101 typedef struct { 102 hmac_res_device_stru hmac_dev_res; 103 } hmac_res_stru; 104 105 /***************************************************************************** 106 全局变量声明 107 *****************************************************************************/ 108 /***************************************************************************** 109 函数声明 110 *****************************************************************************/ 111 mac_res_stru *mac_get_pst_mac_res(osal_void); 112 hmac_res_stru *mac_pst_hmac_res_etc(osal_void); 113 /***************************************************************************** 114 功能描述 : 分配HMAC层的VAP资源 115 *****************************************************************************/ 116 osal_u16 hmac_board_get_max_user(void); 117 mac_res_alloc_hmac_vap(osal_u8 * idx)118static INLINE__ osal_u32 mac_res_alloc_hmac_vap(osal_u8 *idx) 119 { 120 osal_ulong idx_temp; 121 mac_res_stru *mac_res = OSAL_NULL; 122 123 if (OAL_UNLIKELY(idx == OAL_PTR_NULL)) 124 { 125 return OAL_FAIL; 126 } 127 mac_res = mac_get_pst_mac_res(); 128 idx_temp = (osal_ulong)oal_queue_dequeue(&(mac_res->vap_res.queue)); 129 130 /* 0为无效值 */ 131 if (idx_temp == 0) 132 { 133 return OAL_FAIL; 134 } 135 136 *idx = (osal_u8)(idx_temp - 1); 137 138 (mac_res->vap_res.auc_user_cnt[idx_temp - 1])++; 139 140 return OAL_SUCC; 141 } 142 mac_res_alloc_hmac_user(osal_u16 * pus_idx)143static INLINE__ osal_u32 mac_res_alloc_hmac_user(osal_u16 *pus_idx) 144 { 145 osal_ulong idx_temp; 146 mac_res_stru *mac_res = OSAL_NULL; 147 148 if (OAL_UNLIKELY(pus_idx == OAL_PTR_NULL)) 149 { 150 return OAL_FAIL; 151 } 152 mac_res = mac_get_pst_mac_res(); 153 idx_temp = (osal_ulong)oal_queue_dequeue_8user(&(mac_res->user_res.queue)); 154 155 /* 0为无效值 */ 156 if (idx_temp == 0) 157 { 158 return OAL_FAIL; 159 } 160 161 *pus_idx = (osal_u16)(idx_temp - 1); 162 163 (mac_res->user_res.user_cnt[idx_temp - 1])++; 164 165 return OAL_SUCC; 166 } 167 168 /***************************************************************************** 169 函数声明 170 *****************************************************************************/ 171 extern osal_u32 mac_res_alloc_hmac_dev_etc(osal_u8 *dev_idx); 172 extern osal_u32 mac_res_free_dev_etc(osal_u32 dev_idx); 173 extern osal_u32 hmac_res_free_mac_user_etc(osal_u16 idx); 174 extern osal_u32 hmac_res_free_mac_vap_etc(osal_u32 idx); 175 extern osal_u32 mac_res_init_etc(void); 176 extern osal_u32 hmac_res_exit(void); 177 extern mac_chip_stru *mac_res_get_mac_chip(osal_u32 chip_idx); 178 179 /***************************************************************************** 180 2 宏定义 181 *****************************************************************************/ 182 183 /***************************************************************************** 184 3 枚举定义 185 *****************************************************************************/ 186 187 188 /***************************************************************************** 189 4 全局变量声明 190 *****************************************************************************/ 191 192 193 /***************************************************************************** 194 5 消息头定义 195 *****************************************************************************/ 196 197 198 /***************************************************************************** 199 6 消息定义 200 *****************************************************************************/ 201 202 203 /***************************************************************************** 204 7 STRUCT定义 205 *****************************************************************************/ 206 207 208 /***************************************************************************** 209 8 UNION定义 210 *****************************************************************************/ 211 212 213 /***************************************************************************** 214 9 OTHERS定义 215 *****************************************************************************/ 216 217 218 /***************************************************************************** 219 10 函数声明 220 *****************************************************************************/ 221 extern osal_u32 hmac_res_alloc_mac_dev_etc(osal_u32 dev_idx); 222 extern osal_u32 hmac_res_free_mac_dev_etc(osal_u32 dev_idx); 223 extern hmac_device_stru *hmac_res_get_mac_dev_etc(osal_u32 dev_idx); 224 extern mac_chip_stru *hmac_res_get_mac_chip(osal_u32 chip_idx); 225 extern osal_u32 hmac_res_init_etc(osal_void); 226 extern osal_u32 hmac_res_exit_etc(mac_board_stru *hmac_board); 227 228 #ifdef __cplusplus 229 #if __cplusplus 230 } 231 #endif 232 #endif 233 234 #endif 235