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