Merge tag 'apparmor-pr-2018-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / net / mac80211 / rc80211_minstrel_ht.h
1 /*
2  * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #ifndef __RC_MINSTREL_HT_H
10 #define __RC_MINSTREL_HT_H
11
12 /*
13  * The number of streams can be changed to 2 to reduce code
14  * size and memory footprint.
15  */
16 #define MINSTREL_MAX_STREAMS            3
17 #define MINSTREL_HT_STREAM_GROUPS       4 /* BW(=2) * SGI(=2) */
18 #define MINSTREL_VHT_STREAM_GROUPS      6 /* BW(=3) * SGI(=2) */
19
20 #define MINSTREL_HT_GROUPS_NB   (MINSTREL_MAX_STREAMS *         \
21                                  MINSTREL_HT_STREAM_GROUPS)
22 #define MINSTREL_VHT_GROUPS_NB  (MINSTREL_MAX_STREAMS *         \
23                                  MINSTREL_VHT_STREAM_GROUPS)
24 #define MINSTREL_CCK_GROUPS_NB  1
25 #define MINSTREL_GROUPS_NB      (MINSTREL_HT_GROUPS_NB +        \
26                                  MINSTREL_VHT_GROUPS_NB +       \
27                                  MINSTREL_CCK_GROUPS_NB)
28
29 #define MINSTREL_HT_GROUP_0     0
30 #define MINSTREL_CCK_GROUP      (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
31 #define MINSTREL_VHT_GROUP_0    (MINSTREL_CCK_GROUP + 1)
32
33 #define MCS_GROUP_RATES         10
34
35 struct mcs_group {
36         u16 flags;
37         u8 streams;
38         u8 shift;
39         u16 duration[MCS_GROUP_RATES];
40 };
41
42 extern const struct mcs_group minstrel_mcs_groups[];
43
44 struct minstrel_mcs_group_data {
45         u8 index;
46         u8 column;
47
48         /* sorted rate set within a MCS group*/
49         u16 max_group_tp_rate[MAX_THR_RATES];
50         u16 max_group_prob_rate;
51
52         /* MCS rate statistics */
53         struct minstrel_rate_stats rates[MCS_GROUP_RATES];
54 };
55
56 struct minstrel_ht_sta {
57         struct ieee80211_sta *sta;
58
59         /* ampdu length (average, per sampling interval) */
60         unsigned int ampdu_len;
61         unsigned int ampdu_packets;
62
63         /* ampdu length (EWMA) */
64         unsigned int avg_ampdu_len;
65
66         /* overall sorted rate set */
67         u16 max_tp_rate[MAX_THR_RATES];
68         u16 max_prob_rate;
69
70         /* time of last status update */
71         unsigned long last_stats_update;
72
73         /* overhead time in usec for each frame */
74         unsigned int overhead;
75         unsigned int overhead_rtscts;
76
77         unsigned int total_packets;
78         unsigned int sample_packets;
79
80         /* tx flags to add for frames for this sta */
81         u32 tx_flags;
82
83         u8 sample_wait;
84         u8 sample_tries;
85         u8 sample_count;
86         u8 sample_slow;
87
88         /* current MCS group to be sampled */
89         u8 sample_group;
90
91         u8 cck_supported;
92         u8 cck_supported_short;
93
94         /* Bitfield of supported MCS rates of all groups */
95         u16 supported[MINSTREL_GROUPS_NB];
96
97         /* MCS rate group info and statistics */
98         struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
99 };
100
101 struct minstrel_ht_sta_priv {
102         union {
103                 struct minstrel_ht_sta ht;
104                 struct minstrel_sta_info legacy;
105         };
106         void *ratelist;
107         void *sample_table;
108         bool is_ht;
109 };
110
111 void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
112 int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
113                            int prob_ewma);
114
115 #endif