• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 __FRW_EVENT_MAIN_H__
20 #define __FRW_EVENT_MAIN_H__
21 
22 /* ****************************************************************************
23   1 其他头文件包含
24 **************************************************************************** */
25 #include "frw_event_sched.h"
26 #include "oal_ext_if.h"
27 
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif
32 #endif
33 
34 /* ****************************************************************************
35   2 宏定义
36 *****************************************************************************/
37 #define HI_EVENT_DEVICE_READY             BIT0
38 #define HI_EVENT_OPEN_BCPU_DONE           BIT1
39 #define HI_EVENT_CLOSE_BCPU_DONE          BIT2
40 #define HI_EVENT_HALT_BCPU_DONE           BIT3
41 #define HI_EVENT_WAKEUP_DONE              BIT4
42 #define HI_EVENT_SLEEP_REQUEST_ACK        BIT5
43 #define HI_EVENT_SLEEP_REQUEST_DONE       BIT6
44 #define HI_EVENT_SLEEPWORK_DONE           BIT7
45 #define HI_EVENT_RESUME_DONE              BIT8
46 #define HI_EVENT_SDIO_DRIVE_READY         BIT9
47 #define HI_EVENT_D2H_READY_EVENT          BIT10
48 #define HI_EVENT_WOW_ENABLE_READY         BIT11
49 #define HI_EVENT_CLOSE_DONE               BIT12
50 #if (_PRE_MULTI_CORE_MODE != _PRE_MULTI_CORE_MODE_OFFLOAD_HMAC)
51 #define HI_EVENT_FRW_TASK                 BIT13
52 #endif
53 
54 #ifdef _PRE_OAL_FEATURE_TASK_NEST_LOCK
55 extern oal_task_lock_stru g_frw_event_task_lock;
56 #define frw_event_task_lock() do {                                           \
57         oal_smp_task_lock(&g_frw_event_task_lock); \
58     } while (0)
59 #define frw_event_task_unlock() do {                                             \
60         oal_smp_task_unlock(&g_frw_event_task_lock); \
61     } while (0)
62 #else
63 #define frw_event_task_lock() do {                      \
64     } while (0)
65 #define frw_event_task_unlock() do {                        \
66     } while (0)
67 #endif
68 /* ****************************************************************************
69   2 枚举定义
70 **************************************************************************** */
71 /* ****************************************************************************
72   枚举名  : frw_event_deploy_enum_uint8
73   协议表格:
74   枚举说明: 事件部署类型
75 **************************************************************************** */
76 typedef enum {
77     FRW_EVENT_DEPLOY_NON_IPC = 0, /* 非核间通信 */
78     FRW_EVENT_DEPLOY_IPC,         /* 核间通讯 */
79 
80     FRW_EVENT_DEPLOY_BUTT
81 } frw_event_deploy_enum;
82 typedef hi_u8 frw_event_deploy_enum_uint8;
83 
84 typedef enum {
85     FRW_TIMEOUT_TIMER_EVENT, /* 以FRW_TIMER_DEFAULT_TIME为周期的定时器事件子类型 */
86 
87     FRW_TIMEOUT_SUB_TYPE_BUTT
88 } hmac_timeout_event_sub_type_enum;
89 typedef hi_u8 hmac_timeout_event_sub_type_enum_uint8;
90 
91 /* ****************************************************************************
92   枚举名  : frw_event_type_enum_uint8
93   协议表格:
94   枚举说明: 事件类型
95 **************************************************************************** */
96 typedef enum {
97     FRW_EVENT_TYPE_HIGH_PRIO = 0,        /* 高优先级事件队列 */
98     FRW_EVENT_TYPE_HOST_CRX,             /* 接收Host侧发来的配置事件 */
99     FRW_EVENT_TYPE_HOST_DRX,             /* 接收Host侧发来的数据事件 */
100     FRW_EVENT_TYPE_HOST_CTX,             /* 发向HOST侧的配置事件 */
101     FRW_EVENT_TYPE_DMAC_TO_HMAC_CFG = 4, /* DMAC发往HMAC的配置事件 */
102     FRW_EVENT_TYPE_WLAN_CRX,             /* 接收Wlan侧发来的管理/控制帧事件 */
103     FRW_EVENT_TYPE_WLAN_DRX,             /* 接收Wlan侧发来的数据帧事件 */
104     FRW_EVENT_TYPE_WLAN_CTX,             /* 管理/控制帧发送至Wlan侧事件 */
105     FRW_EVENT_TYPE_WLAN_DTX,             /* 数据帧发送至Wlan侧事件 */
106     FRW_EVENT_TYPE_WLAN_TX_COMP = 9,     /* 发送完成事件 */
107     FRW_EVENT_TYPE_TBTT,                 /* TBTT中断事件 */
108     FRW_EVENT_TYPE_TIMEOUT,              /* FRW普通超时事件 */
109     FRW_EVENT_TYPE_DMAC_MISC = 12,       /* DMAC杂散事件 */
110     FRW_EVENT_TYPE_HCC = 13,             /* HCC 事件 */
111     /* 添加新的事件类型 */
112     FRW_EVENT_TYPE_BUTT
113 } frw_event_type_enum;
114 typedef hi_u8 frw_event_type_enum_uint8;
115 
116 typedef enum {
117     OAM_DUMP_TYPE = 4,
118     OAM_BACK_TRACE_TYPE,
119     OAM_LOG_TYPE,
120     OAM_PM_TYPE,
121     OAM_HEATBAET_TYPE,
122     OAM_SET_SOFT_RST,
123 } oam_even_type;
124 
125 /* ****************************************************************************
126   枚举名  : frw_event_type_enum_uint8
127   协议表格:
128   枚举说明: 事件分段号,取值[0, 1]
129 **************************************************************************** */
130 typedef enum {
131     FRW_EVENT_PIPELINE_STAGE_0 = 0,
132     FRW_EVENT_PIPELINE_STAGE_1,
133 
134     FRW_EVENT_PIPELINE_STAGE_BUTT
135 } frw_event_pipeline_enum;
136 typedef hi_u8 frw_event_pipeline_enum_uint8;
137 
138 typedef oal_mem_stru frw_event_mem_stru; /* 事件结构体内存块转定义 */
139 
140 /* ****************************************************************************
141   3 宏定义
142 **************************************************************************** */
143 /* 事件表的最大个数 */
144 /* 一种类型的事件对应两个表项,所以事件表的大小为事件类型的2倍 */
145 #define FRW_EVENT_TABLE_MAX_ITEMS (FRW_EVENT_TYPE_BUTT * 2)
146 
147 /* 事件头长度 */
148 #define FRW_EVENT_HDR_LEN            sizeof(frw_event_hdr_stru)
149 #define FRW_RX_EVENT_TRACK_NUM       256
150 #define FRW_EVENT_TRACK_NUM          128
151 
152 #define frw_field_setup(_p, _m, _v) ((_p)->_m = _v)
153 
154 /* 事件头修改宏(修改事件头中的pipeline和subtype) */
155 #define frw_event_hdr_modify_pipeline_and_subtype(_pst_event_hdr, _uc_sub_type) \
156     do {                                                                        \
157         frw_field_setup((_pst_event_hdr), pipeline, 1);                         \
158         frw_field_setup((_pst_event_hdr), sub_type, (_uc_sub_type));            \
159     } while (0)
160 
161 /* 事件头初始化宏 */
162 #define frw_event_hdr_init(_pst_event_hdr, _en_type, _uc_sub_type, _us_length, _en_pipeline, _uc_vap_id) \
163     do {                                                                                                 \
164         frw_field_setup((_pst_event_hdr), us_length, ((_us_length) + FRW_EVENT_HDR_LEN));                \
165         frw_field_setup((_pst_event_hdr), type, (_en_type));                                             \
166         frw_field_setup((_pst_event_hdr), sub_type, (_uc_sub_type));                                     \
167         frw_field_setup((_pst_event_hdr), pipeline, (_en_pipeline));                                     \
168         frw_field_setup((_pst_event_hdr), vap_id, (_uc_vap_id));                                         \
169     } while (0)
170 
171 #define frw_get_event_stru(event_mem) ((frw_event_stru *)(event_mem)->puc_data)
172 #define frw_get_event_hdr(event_mem) ((frw_event_hdr_stru *)(&((frw_event_stru *)(event_mem)->puc_data)->event_hdr))
173 #define frw_get_event_payload(event_mem) ((hi_u8 *)((frw_event_stru *)(event_mem)->puc_data)->auc_event_data)
174 
175 /* ****************************************************************************
176   4 全局变量声明
177 **************************************************************************** */
178 /* ****************************************************************************
179   5 消息头定义
180 **************************************************************************** */
181 /* ****************************************************************************
182   6 消息定义
183 **************************************************************************** */
184 /* ****************************************************************************
185   7 STRUCT定义
186 **************************************************************************** */
187 /* ****************************************************************************
188   结构名  : frw_event_hdr_stru
189   结构说明: 事件头结构体,
190   备注    : uc_length的值为(payload长度 + 事件头长度 - 2)
191 **************************************************************************** */
192 typedef struct {
193     frw_event_type_enum_uint8     type    : 4;    /* 事件类型 */
194     hi_u8                         vap_id  : 4;    /* VAP ID */
195     hi_u8                         sub_type: 6;    /* 事件子类型 */
196     frw_event_pipeline_enum_uint8 pipeline: 2;    /* 事件分段号 */
197     hi_u16                        us_length;      /* 事件总体长度 */
198 } frw_event_hdr_stru;
199 
200 /* ****************************************************************************
201   结构名  : frw_event_stru
202   结构说明: 事件结构体
203 **************************************************************************** */
204 typedef struct {
205     frw_event_hdr_stru    event_hdr;           /* 事件头 */
206     hi_u8                 auc_event_data[];    /* 4:事件数据数组大小 */
207 } frw_event_stru;
208 
209 /* ****************************************************************************
210   结构名  : frw_event_sub_table_item_stru
211   结构说明: 事件子表结构体
212 **************************************************************************** */
213 typedef struct {
214     hi_u32 (*func)(frw_event_mem_stru *); /* (type, subtype, pipeline)类型的事件对应的处理函数 */
215     hi_u32 (*p_tx_adapt_func)(frw_event_mem_stru *);
216     frw_event_mem_stru *(*p_rx_adapt_func)(frw_event_mem_stru *);
217 } frw_event_sub_table_item_stru;
218 
219 /* ****************************************************************************
220   结构名  : frw_event_table_item_stru
221   结构说明: 事件表结构体
222 **************************************************************************** */
223 typedef struct {
224     const frw_event_sub_table_item_stru *sub_table; /* 指向子表的指针 */
225 } frw_event_table_item_stru;
226 
227 typedef struct {
228     hi_u32 event_cnt;
229     hi_u32 aul_event_time[FRW_EVENT_TRACK_NUM];
230     hi_u16 us_event_type[FRW_EVENT_TRACK_NUM];
231     hi_u16 us_event_sub_type[FRW_EVENT_TRACK_NUM];
232 } frw_event_track_time_stru;
233 
234 /* ****************************************************************************
235   结构名  : frw_event_cfg_stru
236   结构说明: 事件队列配置信息结构体
237 **************************************************************************** */
238 typedef struct {
239     hi_u8                       weight;        /* 队列权重 */
240     hi_u8                       max_events;    /* 队列所能容纳的最大事件个数 */
241     frw_sched_policy_enum_uint8 policy;        /* 队列所属调度策略(高优先级、普通优先级) */
242     hi_u8                       auc_resv;
243 } frw_event_cfg_stru;
244 
245 /* ****************************************************************************
246   8 UNION定义
247 **************************************************************************** */
248 /* ****************************************************************************
249   10 函数声明
250 **************************************************************************** */
251 hi_u32 frw_event_init(hi_void);
252 hi_void frw_event_exit(hi_void);
253 hi_u32 frw_event_queue_enqueue(frw_event_queue_stru *event_queue, frw_event_mem_stru *event_mem);
254 frw_event_mem_stru *frw_event_queue_dequeue(frw_event_queue_stru *event_queue);
255 hi_u32 frw_event_vap_flush_event(hi_u8 vap_id, frw_event_type_enum_uint8 event_type, hi_u8 drop);
256 hi_u32 frw_event_lookup_process_entry(frw_event_mem_stru *event_mem, const frw_event_hdr_stru *event_hrd);
257 frw_event_mem_stru *frw_event_alloc(hi_u16 us_payload_length);
258 hi_u32 frw_event_free(frw_event_mem_stru *event_mem);
259 hi_u32 frw_event_dispatch_event(frw_event_mem_stru *event_mem);
260 hi_u32 frw_event_post_event(frw_event_mem_stru *event_mem);
261 hi_void frw_event_table_register(frw_event_type_enum_uint8 type, frw_event_pipeline_enum_uint8 pipeline,
262     const frw_event_sub_table_item_stru *sub_table);
263 hi_u32 frw_event_flush_event_queue(frw_event_type_enum_uint8 event_type);
264 hi_void frw_event_process_all_event(hi_void);
265 hi_u8 frw_is_vap_event_queue_empty(hi_u8 vap_id, hi_u8 event_type);
266 const frw_event_sub_table_item_stru *frw_get_event_sub_table(hi_u8 type, hi_u8 pipeline);
267 hi_u8 frw_task_thread_condition_check(hi_void);
268 #ifdef _PRE_WLAN_FEATURE_OFFLOAD_FLOWCTL
269 hi_void hcc_host_update_vi_flowctl_param(hi_u32 be_cwmin, hi_u32 vi_cwmin);
270 #endif
271 hi_u32 get_app_event_id(hi_void);
272 hi_void frw_event_sub_rx_adapt_table_init(frw_event_sub_table_item_stru *pst_sub_table, hi_u32 ul_table_nums,
273     frw_event_mem_stru *(*p_rx_adapt_func)(frw_event_mem_stru *));
274 
275 /* ****************************************************************************
276   9 OTHERS定义
277 **************************************************************************** */
278 #ifdef __cplusplus
279 #if __cplusplus
280 }
281 #endif
282 #endif
283 
284 #endif /* end of frw_event_main.h */
285