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 dmac public interface. 15 * Author: 16 */ 17 18 #ifndef FRW_DMAC_ROM_H 19 #define FRW_DMAC_ROM_H 20 21 #include "osal_types.h" 22 #include "oal_net_rom.h" 23 #include "dmac_ext_if_rom.h" 24 #include "frw_msg_rom.h" 25 #include "dmac_pkt_debug_rom.h" 26 #ifdef __cplusplus 27 #if __cplusplus 28 extern "C" { 29 #endif 30 #endif 31 32 #define frw_dbg(fmt, ...) 33 34 #define TIME_OUT_MS 2000 35 36 typedef osal_s32 (*dmac_frw_msg_callback)(dmac_vap_stru *dmac_vap, frw_msg *msg); 37 typedef struct { 38 frw_msg msg; 39 struct osal_list_head list; 40 osal_s32 cb_return; 41 osal_u16 msg_id; 42 osal_u8 wait_cond : 1; 43 osal_u8 sync : 1; 44 osal_u8 wait_cond_thread : 1; 45 osal_u8 pool_used : 1; 46 osal_u8 pool_idx : 4; 47 osal_u8 vap_id; 48 osal_u16 time_out; 49 osal_u16 seq; 50 osal_atomic wait_fail; 51 } frw_msg_node; 52 53 typedef struct { 54 struct osal_list_head list; 55 osal_u32 cnt; 56 osal_u32 seq; 57 osal_spinlock lock; 58 } frw_msg_que; 59 60 typedef struct { 61 dmac_frw_msg_callback msg_cb; 62 } frw_msg_item; 63 64 typedef struct { 65 osal_u16 msg_id_min; 66 osal_u16 msg_id_max; 67 frw_msg_item *msg_table; 68 frw_msg_que que[FRW_POST_PRI_NUM]; 69 #ifdef _PRE_OS_VERSION_LITEOS 70 osal_wait que_wait; /* 异步事件 */ 71 #endif 72 } frw_ctrl; 73 74 /* 75 约定:对于dmac侧而言,无论是配置消息,还是数据帧/管理帧: 76 send: dmac -> wal/hmac 77 post: dmac -> dmac 78 rcv : wal/hmac - > dmac 79 对于数据帧/管理帧 80 rx: air -> dmac 81 tx: dmac -> air 82 */ 83 84 /* msg_id:配置消息ID; 85 用于从device侧发起的消息/配置,且消息/配置一定会被发往host侧 86 d2h没有同步消息; 87 */ 88 osal_s32 frw_send_cfg_to_host(osal_u16 msg_id, osal_u8 vap_id, frw_msg *msg); 89 90 /* 用于wal->hmac的异步配置 */ 91 osal_s32 dmac_frw_post_async_msg(osal_u16 msg_id, osal_u8 pri, osal_u8 vap_id, frw_msg *msg, osal_u32 seq); 92 93 /* 94 netbuf: 数据帧报文指针,调用者申请,HCC释放; 95 发送数据帧到hmac侧的接口 96 调用者要填写优先级,cb域具体填写位置待定 97 */ 98 osal_u32 frw_dmac_msg_hook_register(osal_u16 msg_id, dmac_frw_msg_callback msg_cb); 99 osal_void frw_dmac_msg_hook_unregister(osal_u16 msg_id); 100 101 osal_s32 dmac_frw_netbuf_exec_callback(dmac_vap_stru *dmac_vap, osal_u8 data_type, 102 osal_u16 netbuf_type, frw_msg *msg); 103 104 osal_u32 dmac_send_msg_to_host(osal_u8 vap_id, osal_u16 msg_id, osal_u8 *data, osal_u32 data_len); 105 osal_s32 dmac_frw_msg_exec_callback(osal_u16 msg_id, osal_u8 vap_id, frw_msg *msg); 106 osal_s32 dmac_hal_post_async_msg(osal_u16 msg_id, osal_u8 pri, osal_u8 vap_id, osal_u8 *data, osal_u32 data_len); 107 osal_s32 dmac_frw_msg_exec(osal_u16 msg_id, osal_u8 vap_id, osal_u8 *data, osal_u32 data_len); 108 frw_ctrl *get_dmac_frw_ctrl(osal_void); 109 osal_void frw_dump_stats(osal_void); 110 111 osal_void frw_thread_process_msg(osal_void); 112 #ifdef _PRE_OS_VERSION_LITEOS 113 osal_u8 frw_thread_condition_check(osal_void); 114 osal_wait *frw_thread_get_wait(osal_void); 115 #endif 116 117 osal_s32 dmac_config_flush_event_msg(dmac_vap_stru *dmac_vap, frw_msg *msg); 118 frw_msg_node* frw_fetch_msg_node(osal_void); 119 osal_void frw_free_msg_node(frw_msg_node *node); 120 osal_void frw_thread_process_msg_node(frw_msg_node *node, osal_bool drop); 121 osal_s32 frw_send_mgmt_to_host(oal_dmac_netbuf_stru *netbuf, osal_u32 buf_len, osal_u32 msg_type, osal_u32 vap_id); 122 osal_s32 frw_send_data_to_host(oal_dmac_netbuf_stru *netbuf, osal_u32 buf_len, osal_u32 msg_type, osal_u32 vap_id); 123 #ifdef _PRE_WLAN_FEATURE_CENTRALIZE 124 typedef osal_u32 (*frw_rx_msg_cb)(osal_u16 msg_id, osal_u8 vap_id, osal_u32 seq, osal_s32 dev_cb_ret, frw_msg *msg); 125 typedef osal_u32 (*frw_rx_netbuf_cb)(oal_dmac_netbuf_stru *netbuf, osal_u32 payload_len); 126 #endif 127 #define OSAL_FRW_CB_CONTINUE 1 128 typedef osal_u32 (*frw_recv_msg_callback)(frw_msg_adapt *msg_adapt); 129 typedef osal_u32 (*frw_hcc_flowctrl_type_callback)(osal_u8 data_type, osal_u16 *fc_flag, osal_u8 *queue_id); 130 typedef osal_s32 (*frw_msg_exec_callback_hook)(osal_u16 msg_id, osal_u8 vap_id, frw_msg *msg); 131 device_frw_stat *get_frw_device_stat_info(osal_void); 132 typedef osal_void (*frw_event_flush_cb)(osal_u16 event_type); 133 osal_u8 is_frw_queue_empty(osal_void); 134 #ifdef __cplusplus 135 #if __cplusplus 136 } 137 #endif 138 #endif 139 140 #endif // FRW_DMAC_H 141