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 for hmac_tcp_opt_struc.c. 15 * Create: 2021-12-15 16 */ 17 18 #ifndef __HMAC_TCP_OPT_STRUC_H__ 19 #define __HMAC_TCP_OPT_STRUC_H__ 20 21 #ifdef _PRE_WLAN_TCP_OPT 22 23 /***************************************************************************** 24 1 其他头文件包含 25 *****************************************************************************/ 26 #include "oal_types.h" 27 #include "oal_netbuf_ext.h" 28 #include "oam_ext_if.h" 29 30 #ifdef __cplusplus 31 #if __cplusplus 32 extern "C" { 33 #endif 34 #endif 35 36 #undef THIS_FILE_ID 37 #define THIS_FILE_ID OAM_FILE_ID_HMAC_TCP_OPT_STRUC_H 38 39 /***************************************************************************** 40 2 宏定义 41 *****************************************************************************/ 42 #define HMAC_TCP_STREAM 32 43 #define TCPDATA_INFO_MAXNUM 4 44 #define TCPDATA_PSH_INFO_MAXNUM (8 * TCPDATA_INFO_MAXNUM) 45 46 /***************************************************************************** 47 3 枚举定义 48 *****************************************************************************/ 49 enum { 50 TCP_ACK_FILTER_TYPE = 1, 51 TCP_ACK_DUP_TYPE = 2, 52 TCP_TYPE_ERROR 53 }; 54 typedef osal_u8 oal_tcp_ack_type_enum_uint8; 55 /***************************************************************************** 56 4 全局变量声明 57 *****************************************************************************/ 58 59 60 /***************************************************************************** 61 5 消息头定义 62 *****************************************************************************/ 63 64 65 /***************************************************************************** 66 6 消息定义 67 *****************************************************************************/ 68 69 70 /***************************************************************************** 71 7 STRUCT定义 72 *****************************************************************************/ 73 typedef struct _wlan_perform_tcp_impl_ { 74 osal_u64 ull_drop_count; 75 osal_u64 ull_send_count; 76 osal_u64 ull_dup_ack_count; 77 } wlan_perform_tcp_impl; 78 79 typedef struct _wlan_perform_tcp_impls_ { 80 osal_u32 ack_limit; 81 osal_u64 ull_ignored_count; 82 wlan_perform_tcp_impl tcp_info[HMAC_TCP_STREAM]; 83 } wlan_perform_tcp_impls; 84 85 struct skb_tcp_cb { 86 osal_u16 us_index; 87 osal_u16 reserve; 88 osal_u32 tcp_type; 89 osal_u32 tcp_ack_no; 90 }; 91 92 struct wlan_perform_tcp { 93 /* hcc rx/tx tcp ack param */ 94 oal_netbuf_head_stru hcc_ack_queue[HMAC_TCP_STREAM]; 95 osal_u32 hcc_ack_count[HMAC_TCP_STREAM]; /* ack num in each queue */ 96 osal_u32 hcc_duplicate_ack_count[HMAC_TCP_STREAM]; 97 osal_u32 hcc_tcp_ack_no[HMAC_TCP_STREAM]; 98 osal_spinlock hmac_tcp_ack_lock; 99 }; 100 struct wlan_tcp_flow { 101 osal_u32 src_ip; 102 osal_u32 dst_ip; 103 osal_u16 src_port; 104 osal_u16 dst_port; 105 osal_u8 protocol; 106 }; 107 struct tcp_list_node { 108 struct osal_list_head list; 109 osal_u32 used; /* 0-free, 1-used */ 110 struct wlan_tcp_flow wlan_tcp_info; 111 osal_u32 index; 112 osal_ulong last_ts; /* time of last frame */ 113 }; 114 struct wlan_perform_tcp_list { 115 struct tcp_list_node tcp_pool[HMAC_TCP_STREAM]; 116 osal_u32 free_count; 117 osal_spinlock tcp_lock; /* lock for tcp pool */ 118 osal_spinlock tcp_list_lock; /* lock for tcp list */ 119 struct osal_list_head tcp_list; 120 }; 121 122 typedef enum _hmac_tcp_opt_queue_ { 123 HMAC_TCP_ACK_QUEUE = 0, 124 HMAC_TCP_OPT_QUEUE_BUTT 125 } hmac_tcp_opt_queue; 126 127 typedef osal_u16 (*hmac_trans_cb_func)(void *hmac_device, hmac_tcp_opt_queue type, hcc_chan_type dir, void *data); 128 129 /* tcp_ack优化 */ 130 typedef struct { 131 struct wlan_perform_tcp hmac_tcp_ack; 132 struct wlan_perform_tcp_list hmac_tcp_ack_list; 133 wlan_perform_tcp_impls filter_info; 134 hmac_trans_cb_func filter[HMAC_TCP_OPT_QUEUE_BUTT]; // 过滤处理钩子函数 135 osal_u64 all_ack_count[HMAC_TCP_OPT_QUEUE_BUTT]; // 丢弃的TCP ACK统计 136 osal_u64 drop_count[HMAC_TCP_OPT_QUEUE_BUTT]; // 丢弃的TCP ACK统计 137 oal_netbuf_head_stru data_queue[HMAC_TCP_OPT_QUEUE_BUTT]; 138 osal_spinlock data_queue_lock[HMAC_TCP_OPT_QUEUE_BUTT]; 139 } hmac_tcp_ack_stru; 140 141 typedef struct { 142 /* 定制化是否打开tcp ack过滤 */ 143 osal_u8 tcp_ack_filter_en; 144 /* 当前状态 */ 145 osal_u8 cur_filter_status; 146 osal_u16 rx_filter_throughput_high; 147 osal_u16 rx_filter_throughput_low; 148 osal_u8 tcp_ack_max_num_start_process; 149 osal_u8 resv; 150 } mac_tcp_ack_filter_stru; 151 extern mac_tcp_ack_filter_stru g_st_tcp_ack_filter; 152 153 /***************************************************************************** 154 8 UNION定义 155 *****************************************************************************/ 156 157 158 /***************************************************************************** 159 9 OTHERS定义 160 *****************************************************************************/ 161 162 163 /***************************************************************************** 164 10 函数声明 165 *****************************************************************************/ 166 /***************************************************************************** 167 11 内联函数定义 168 *****************************************************************************/ 169 170 #ifdef __cplusplus 171 #if __cplusplus 172 } 173 #endif 174 #endif 175 176 #endif /* end of _PRE_WLAN_TCP_OPT */ 177 178 #endif /* end of hmac_tcp_opt_struc.h */ 179