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_stat.c. 15 */ 16 #ifndef __HMAC_STAT_H__ 17 #define __HMAC_STAT_H__ 18 19 #include "frw_ext_common_rom.h" 20 #include "frw_osal.h" 21 #include "frw_msg_rom.h" 22 #include "osal_adapt.h" 23 #include "mac_vap_ext.h" 24 25 typedef struct { 26 osal_u32 pre_time; /* 用于差值计算确切时间,排除函数调用时间 */ 27 frw_timeout_stru hmac_freq_timer; /* auto freq timer */ 28 } hmac_stat_control_stru; 29 30 #define HMAC_STAT_TIMER_PERIOD 200 /* 定时器周期, 单位ms */ 31 32 void hmac_throughput_timer_init(void); 33 void hmac_throughput_timer_deinit(void); 34 osal_s32 hmac_config_pk_mode_th(hmac_vap_stru *hmac_vap, frw_msg *msg); 35 /* HMAC device级别统计 */ 36 typedef struct hmac_device_stat { 37 osal_atomic tx_packets; 38 osal_atomic rx_packets; 39 osal_atomic rx_bytes; 40 osal_atomic tx_bytes; 41 } hmac_device_stat_stru; 42 hmac_device_stat_stru *hmac_stat_get_device_stats(void); hmac_stat_device_tx_netbuf(osal_u32 netbuf_len)43OAL_STATIC OAL_INLINE void hmac_stat_device_tx_netbuf(osal_u32 netbuf_len) 44 { 45 hmac_device_stat_stru *hmac_device_stats = hmac_stat_get_device_stats(); 46 osal_adapt_atomic_inc(&hmac_device_stats->tx_packets); 47 osal_adapt_atomic_add(&hmac_device_stats->tx_bytes, (osal_s32)netbuf_len); 48 } hmac_stat_device_rx_netbuf(uint32_t netbuf_len)49OAL_STATIC OAL_INLINE void hmac_stat_device_rx_netbuf(uint32_t netbuf_len) 50 { 51 hmac_device_stat_stru *hmac_device_stats = hmac_stat_get_device_stats(); 52 osal_adapt_atomic_inc(&hmac_device_stats->rx_packets); 53 osal_adapt_atomic_set(&hmac_device_stats->rx_bytes, (int32_t)netbuf_len); 54 } 55 #endif