1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Header file for QOS Algorithm on DHD 3*4882a593Smuzhiyun * 4*4882a593Smuzhiyun * Provides type definitions and function prototypes for the QOS Algorithm 5*4882a593Smuzhiyun * Note that this algorithm is a platform independent layer 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * Copyright (C) 2020, Broadcom. 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * Unless you and Broadcom execute a separate written software license 10*4882a593Smuzhiyun * agreement governing use of this software, this software is licensed to you 11*4882a593Smuzhiyun * under the terms of the GNU General Public License version 2 (the "GPL"), 12*4882a593Smuzhiyun * available at http://www.broadcom.com/licenses/GPLv2.php, with the 13*4882a593Smuzhiyun * following added to such license: 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * As a special exception, the copyright holders of this software give you 16*4882a593Smuzhiyun * permission to link this software with independent modules, and to copy and 17*4882a593Smuzhiyun * distribute the resulting executable under terms of your choice, provided that 18*4882a593Smuzhiyun * you also meet, for each linked independent module, the terms and conditions of 19*4882a593Smuzhiyun * the license of that module. An independent module is a module which is not 20*4882a593Smuzhiyun * derived from this software. The special exception does not apply to any 21*4882a593Smuzhiyun * modifications of the software. 22*4882a593Smuzhiyun * 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * <<Broadcom-WL-IPTag/Open:>> 25*4882a593Smuzhiyun * 26*4882a593Smuzhiyun * $Id$ 27*4882a593Smuzhiyun */ 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun #ifndef _DHD_QOS_ALGO_H_ 30*4882a593Smuzhiyun #define _DHD_QOS_ALGO_H_ 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #define LOWLAT_AVG_PKT_SIZE_LOW 50u 33*4882a593Smuzhiyun #define LOWLAT_AVG_PKT_SIZE_HIGH 200u 34*4882a593Smuzhiyun #define LOWLAT_NUM_PKTS_LOW 1u 35*4882a593Smuzhiyun #define LOWLAT_NUM_PKTS_HIGH 8u 36*4882a593Smuzhiyun #define LOWLAT_DETECT_CNT_INC_THRESH 10u 37*4882a593Smuzhiyun #define LOWLAT_DETECT_CNT_DEC_THRESH 0u 38*4882a593Smuzhiyun #define LOWLAT_DETECT_CNT_UPGRADE_THRESH 4u 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun typedef struct qos_stat 41*4882a593Smuzhiyun { 42*4882a593Smuzhiyun /* Statistics */ 43*4882a593Smuzhiyun unsigned long tx_pkts_prev; 44*4882a593Smuzhiyun unsigned long tx_bytes_prev; 45*4882a593Smuzhiyun unsigned long tx_pkts; 46*4882a593Smuzhiyun unsigned long tx_bytes; 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun /* low latency flow detection algorithm counts */ 49*4882a593Smuzhiyun unsigned char lowlat_detect_count; 50*4882a593Smuzhiyun bool lowlat_flow; 51*4882a593Smuzhiyun } qos_stat_t; 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun /* QoS alogrithm parameter, controllable at runtime */ 54*4882a593Smuzhiyun typedef struct _qos_algo_params 55*4882a593Smuzhiyun { 56*4882a593Smuzhiyun /* The avg Tx packet size in the sampling interval must be between 57*4882a593Smuzhiyun * these two thresholds for QoS upgrade to take place. 58*4882a593Smuzhiyun * default values = LOWLAT_AVG_PKT_SIZE_LOW, LOWLAT_AVG_PKT_SIZE_HIGH 59*4882a593Smuzhiyun */ 60*4882a593Smuzhiyun unsigned long avg_pkt_size_low_thresh; 61*4882a593Smuzhiyun unsigned long avg_pkt_size_high_thresh; 62*4882a593Smuzhiyun /* The number of Tx packets in the sampling interval must be 63*4882a593Smuzhiyun * between these two thresholds for QoS upgrade to happen. 64*4882a593Smuzhiyun * default values = LOWLAT_NUM_PKTS_LOW, LOWLAT_NUM_PKTS_HIGH 65*4882a593Smuzhiyun */ 66*4882a593Smuzhiyun unsigned long num_pkts_low_thresh; 67*4882a593Smuzhiyun unsigned long num_pkts_high_thresh; 68*4882a593Smuzhiyun /* If low latency traffic is detected, then the low latency count 69*4882a593Smuzhiyun * is incremented till the first threshold is hit. 70*4882a593Smuzhiyun * If traffic ceases to be low latency, then the count is 71*4882a593Smuzhiyun * decremented till the second threshold is hit. 72*4882a593Smuzhiyun * default values = LOWLAT_DETECT_CNT_INC_THRESH, LOWLAT_DETECT_CNT_DEC_THRESH 73*4882a593Smuzhiyun */ 74*4882a593Smuzhiyun unsigned char detect_cnt_inc_thresh; 75*4882a593Smuzhiyun unsigned char detect_cnt_dec_thresh; 76*4882a593Smuzhiyun /* If the low latency count crosses this threshold, the flow will be upgraded. 77*4882a593Smuzhiyun * Default value = LOWLAT_DETECT_CNT_UPGRADE_THRESH 78*4882a593Smuzhiyun */ 79*4882a593Smuzhiyun unsigned char detect_cnt_upgrade_thresh; 80*4882a593Smuzhiyun } qos_algo_params_t; 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun #define QOS_PARAMS(x) (&x->psk_qos->qos_params); 83*4882a593Smuzhiyun 84*4882a593Smuzhiyun /* 85*4882a593Smuzhiyun * Operates on a flow and returns 1 for upgrade and 0 for 86*4882a593Smuzhiyun * no up-grade 87*4882a593Smuzhiyun */ 88*4882a593Smuzhiyun int dhd_qos_algo(dhd_info_t *dhd, qos_stat_t *qos, qos_algo_params_t *qos_params); 89*4882a593Smuzhiyun int qos_algo_params_init(qos_algo_params_t *qos_params); 90*4882a593Smuzhiyun #endif /* _DHD_QOS_ALGO_H_ */ 91