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_SCHED_H__ 20 #define __FRW_EVENT_SCHED_H__ 21 22 /* **************************************************************************** 23 1 其他头文件包含 24 **************************************************************************** */ 25 #include "oal_ext_if.h" 26 27 #ifdef __cplusplus 28 #if __cplusplus 29 extern "C" { 30 #endif 31 #endif 32 33 /* **************************************************************************** 34 2 宏定义 35 **************************************************************************** */ 36 /* 获取事件队列中已经缓存的事件个数 */ 37 #define frw_event_queue_get_pending_events_num(_pst_event_queue) oal_queue_get_length(&(_pst_event_queue)->queue) 38 39 /* **************************************************************************** 40 3 枚举定义 41 **************************************************************************** */ 42 /* **************************************************************************** 43 枚举名 : frw_sched_policy_enum_uint8 44 协议表格: 45 枚举说明: 事件队列对应的调度策略 46 **************************************************************************** */ 47 typedef enum { 48 FRW_SCHED_POLICY_HI = 0, /* 高优先级队列 */ 49 FRW_SCHED_POLICY_NORMAL = 1, /* 普通优先级队列 */ 50 FRW_SCHED_HCC_ASSEM = 2, /* 特殊事件,用于HCC聚合 */ 51 52 FRW_SCHED_POLICY_BUTT 53 } frw_sched_policy_enum; 54 typedef hi_u8 frw_sched_policy_enum_uint8; 55 56 /* **************************************************************************** 57 枚举名 : frw_event_queue_state_enum_uint8 58 协议表格: 59 枚举说明: 事件队列状态 60 **************************************************************************** */ 61 typedef enum { 62 FRW_EVENT_QUEUE_STATE_INACTIVE = 0, /* 事件队列不活跃(不可被调度) */ 63 FRW_EVENT_QUEUE_STATE_ACTIVE, /* 事件队列活跃(可被调度) */ 64 65 FRW_EVENT_QUEUE_STATE_BUTT 66 } frw_event_queue_state_enum; 67 typedef hi_u8 frw_event_queue_state_enum_uint8; 68 69 /* **************************************************************************** 70 枚举名 : frw_vap_state_enum_uint8 71 协议表格: 72 枚举说明: 事件部署类型 73 **************************************************************************** */ 74 typedef enum { 75 FRW_VAP_STATE_RESUME = 0, /* VAP恢复 */ 76 FRW_VAP_STATE_PAUSE, /* VAP暂停 */ 77 78 FRW_VAP_STATE_BUTT 79 } frw_vap_state_enum; 80 typedef hi_u8 frw_vap_state_enum_uint8; 81 82 /* **************************************************************************** 83 5 消息头定义 84 **************************************************************************** */ 85 /* **************************************************************************** 86 6 消息定义 87 **************************************************************************** */ 88 /* **************************************************************************** 89 7 STRUCT定义 90 **************************************************************************** */ 91 /* **************************************************************************** 92 结构名 : frw_event_sched_queue_stru 93 结构说明: 可调度队列 94 **************************************************************************** */ 95 typedef struct { 96 oal_spin_lock_stru st_lock; 97 hi_u32 total_weight_cnt; /* 可调度队列上的总权重计数器 */ 98 hi_list head; /* 可调度队列的事件链表头 */ 99 } frw_event_sched_queue_stru; 100 101 /* **************************************************************************** 102 结构名 : frw_event_queue_stru 103 结构说明: 事件队列结构体 104 **************************************************************************** */ 105 typedef struct tag_frw_event_queue_stru { 106 oal_spin_lock_stru st_lock; 107 oal_queue_stru queue; /* 队列 */ 108 frw_event_queue_state_enum_uint8 state; /* 队列状态 */ 109 frw_sched_policy_enum_uint8 policy; /* 队列调度策略(高优先级、普通优先级) */ 110 111 hi_u8 weight; /* WRR权重配置值 */ 112 hi_u8 weight_cnt; /* WRR权重计数器 */ 113 114 frw_vap_state_enum_uint8 vap_state; /* VAP的状态值,0为恢复,1为暂停 */ 115 hi_u8 auc_resv[3]; /* 3:保留数组大小 */ 116 hi_list list; 117 }frw_event_queue_stru; 118 119 /* **************************************************************************** 120 4 全局变量声明 121 **************************************************************************** */ 122 /* **************************************************************************** 123 8 UNION定义 124 **************************************************************************** */ 125 /* **************************************************************************** 126 10 函数声明 127 **************************************************************************** */ 128 hi_u32 frw_event_sched_init(frw_event_sched_queue_stru *sched_queue); 129 hi_u32 frw_event_queue_init(frw_event_queue_stru *event_queue, hi_u8 weight, frw_sched_policy_enum_uint8 policy, 130 frw_event_queue_state_enum_uint8 state, hi_u8 max_events); 131 hi_void frw_event_queue_destroy(frw_event_queue_stru *event_queue); 132 hi_void *frw_event_sched_pick_next_event_queue_wrr(frw_event_sched_queue_stru *sched_queue); 133 hi_void frw_event_sched_deactivate_queue(frw_event_sched_queue_stru *sched_queue, frw_event_queue_stru *event_queue); 134 hi_u32 frw_event_sched_activate_queue_no_lock(frw_event_sched_queue_stru *sched_queue, 135 frw_event_queue_stru *event_queue); 136 hi_void* frw_event_schedule(frw_event_sched_queue_stru *sched_queue); 137 138 /* **************************************************************************** 139 9 OTHERS定义 140 **************************************************************************** */ 141 #ifdef __cplusplus 142 #if __cplusplus 143 } 144 #endif 145 #endif 146 147 #endif /* end of frw_event_sched.h */ 148