1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __WAL_EVENT_MSG_H__ 20 #define __WAL_EVENT_MSG_H__ 21 22 /* **************************************************************************** 23 1 其他头文件包含 24 **************************************************************************** */ 25 #include "oal_ext_if.h" 26 #include "wlan_mib.h" 27 #include "frw_event.h" 28 29 #ifdef __cplusplus 30 #if __cplusplus 31 extern "C" { 32 #endif 33 #endif 34 35 /* **************************************************************************** 36 2 宏定义 37 **************************************************************************** */ 38 #define WAL_MSG_WRITE_MSG_HDR_LENGTH (sizeof(wal_msg_hdr_stru)) 39 #define WAL_MSG_WRITE_MAX_LEN (WLAN_MEM_EVENT_SIZE2 - FRW_EVENT_HDR_LEN - WAL_MSG_WRITE_MSG_HDR_LENGTH) 40 #define WAL_MSG_HDR_LENGTH sizeof(wal_msg_hdr_stru) 41 #define WAL_MSG_WID_LENGTH sizeof(wlan_cfgid_enum_uint16) 42 #define WAL_MSG_QUERY_LEN 16 43 #define WAL_BW_STR_MAX_LEN 20 44 45 /* 填写配置消息头 */ 46 #define wal_cfg_msg_hdr_init(_pst_cfg_msg_hdr, _en_type, _us_len, _uc_sn) \ 47 do { \ 48 (_pst_cfg_msg_hdr)->msg_type = (_en_type); \ 49 (_pst_cfg_msg_hdr)->us_msg_len = (_us_len); \ 50 (_pst_cfg_msg_hdr)->msg_sn = (_uc_sn); \ 51 } while (0) 52 53 /* 填写write msg消息头 */ 54 #define wal_write_msg_hdr_init(_pst_write_msg, _en_wid, _us_len) \ 55 do { \ 56 (_pst_write_msg)->wid = (_en_wid); \ 57 (_pst_write_msg)->us_len = (_us_len); \ 58 } while (0) 59 60 /* **************************************************************************** 61 4 枚举定义 62 **************************************************************************** */ 63 /* 配置消息类型 */ 64 typedef enum { 65 WAL_MSG_TYPE_QUERY, /* 查询 */ 66 WAL_MSG_TYPE_WRITE, /* 设置 */ 67 WAL_MSG_TYPE_RESPONSE, /* 返回 */ 68 69 WAL_MSG_TYPE_BUTT 70 } wal_msg_type_enum; 71 typedef hi_u8 wal_msg_type_enum_uint8; 72 73 /* **************************************************************************** 74 5 STRUCT定义 75 **************************************************************************** */ 76 /* 配置消息头 */ 77 typedef struct { 78 wal_msg_type_enum_uint8 msg_type; /* msg type:W or Q */ 79 hi_u8 msg_sn; /* msg 序列号 */ 80 hi_u16 us_msg_len; /* msg 长度 */ 81 } wal_msg_hdr_stru; 82 83 /* 配置消息 */ 84 typedef struct { 85 wal_msg_hdr_stru msg_hdr; /* 配置消息头 */ 86 hi_u8 auc_msg_data[]; /* 配置消息payload */ 87 } wal_msg_stru; 88 89 /* write消息时的返回消息 */ 90 typedef struct { 91 wlan_cfgid_enum_uint16 wid; 92 hi_u8 auc_resv[2]; /* 2: 保留字节 */ 93 hi_u32 err_code; /* write消息返回的错误码 */ 94 } wal_msg_write_rsp_stru; 95 96 /* write消息格式 */ 97 typedef struct { 98 wlan_cfgid_enum_uint16 wid; 99 hi_u16 us_len; 100 hi_u8 auc_value[WAL_MSG_WRITE_MAX_LEN]; 101 } wal_msg_write_stru; 102 103 /* response消息格式,与Write消息格式相同 */ 104 typedef wal_msg_write_stru wal_msg_rsp_stru; 105 106 /* query消息格式:2字节WID x N */ 107 typedef struct { 108 wlan_cfgid_enum_uint16 wid; 109 } wal_msg_query_stru; 110 111 /* WMM SET消息格式 */ 112 typedef struct { 113 wlan_cfgid_enum_uint16 cfg_id; 114 hi_u8 uc_resv[2]; /* 2: 保留字节 */ 115 hi_u32 ac; 116 hi_u32 value; 117 } wal_msg_wmm_stru; 118 119 /* WMM query消息格式:2字节WID x N */ 120 typedef struct { 121 wlan_cfgid_enum_uint16 wid; 122 hi_u8 uc_resv[2]; /* 2: 保留字节 */ 123 hi_u32 ac; 124 } wal_msg_wmm_query_stru; 125 126 /* WID request struct */ 127 typedef struct { 128 hi_list entry; 129 uintptr_t request_address; 130 hi_void *resp_mem; 131 hi_u32 resp_len; 132 hi_u32 ret; 133 } wal_msg_request_stru; 134 135 typedef struct { 136 uintptr_t request_address; 137 } wal_msg_rep_hdr; 138 139 typedef struct { 140 oal_spin_lock_stru st_lock; 141 hi_list head; 142 oal_wait_queue_head_stru wait_queue; 143 hi_u32 count; 144 } wal_msg_queue; 145 146 #ifdef __cplusplus 147 #if __cplusplus 148 } 149 #endif 150 #endif 151 152 hi_u32 wal_check_and_release_msg_resp(wal_msg_stru *rsp_msg); 153 hi_void wal_msg_queue_init(hi_void); 154 hi_void wal_cfg_msg_task_sched(hi_void); 155 hi_u32 wal_set_msg_response_by_addr(hi_u32 addr, hi_u8 *resp_mem, hi_u32 resp_ret, hi_u32 rsp_len); 156 157 #endif /* end of wal_event_msg.h */ 158