blob: f762e5ba7c2ed65095f0f05c2ffbf495b3dc4ff4 [file] [log] [blame]
Felix Fietkauec8aa662010-05-13 16:48:03 +02001/*
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 */
Felix Fietkau7f2e12e2019-03-25 09:50:15 +010016#define MINSTREL_MAX_STREAMS 4
Karl Beldan8a0ee4f2014-10-20 15:46:00 +020017#define MINSTREL_HT_STREAM_GROUPS 4 /* BW(=2) * SGI(=2) */
Karl Beldan92082472014-10-21 10:38:38 +020018#define MINSTREL_VHT_STREAM_GROUPS 6 /* BW(=3) * SGI(=2) */
Karl Beldan8a0ee4f2014-10-20 15:46:00 +020019
20#define MINSTREL_HT_GROUPS_NB (MINSTREL_MAX_STREAMS * \
21 MINSTREL_HT_STREAM_GROUPS)
Karl Beldan92082472014-10-21 10:38:38 +020022#define MINSTREL_VHT_GROUPS_NB (MINSTREL_MAX_STREAMS * \
23 MINSTREL_VHT_STREAM_GROUPS)
Karl Beldan8a0ee4f2014-10-20 15:46:00 +020024#define MINSTREL_CCK_GROUPS_NB 1
25#define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB + \
Karl Beldan92082472014-10-21 10:38:38 +020026 MINSTREL_VHT_GROUPS_NB + \
Karl Beldan8a0ee4f2014-10-20 15:46:00 +020027 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)
Karl Beldan92082472014-10-21 10:38:38 +020031#define MINSTREL_VHT_GROUP_0 (MINSTREL_CCK_GROUP + 1)
Felix Fietkauec8aa662010-05-13 16:48:03 +020032
Karl Beldan92082472014-10-21 10:38:38 +020033#define MCS_GROUP_RATES 10
Felix Fietkauec8aa662010-05-13 16:48:03 +020034
35struct mcs_group {
Felix Fietkau202df502018-10-06 19:35:02 +020036 u16 flags;
37 u8 streams;
38 u8 shift;
39 u16 duration[MCS_GROUP_RATES];
Felix Fietkauec8aa662010-05-13 16:48:03 +020040};
41
John W. Linvillede66bfd2010-06-24 13:03:14 -040042extern const struct mcs_group minstrel_mcs_groups[];
43
Felix Fietkauec8aa662010-05-13 16:48:03 +020044struct minstrel_mcs_group_data {
45 u8 index;
46 u8 column;
47
Thomas Huehn59358392014-09-09 23:22:14 +020048 /* sorted rate set within a MCS group*/
Karl Beldand4d141c2014-10-20 15:45:59 +020049 u16 max_group_tp_rate[MAX_THR_RATES];
50 u16 max_group_prob_rate;
Felix Fietkauec8aa662010-05-13 16:48:03 +020051
52 /* MCS rate statistics */
53 struct minstrel_rate_stats rates[MCS_GROUP_RATES];
54};
55
56struct minstrel_ht_sta {
Felix Fietkaua8566662013-04-22 16:14:42 +020057 struct ieee80211_sta *sta;
58
Felix Fietkauec8aa662010-05-13 16:48:03 +020059 /* 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
Thomas Huehn59358392014-09-09 23:22:14 +020066 /* overall sorted rate set */
Karl Beldand4d141c2014-10-20 15:45:59 +020067 u16 max_tp_rate[MAX_THR_RATES];
68 u16 max_prob_rate;
Felix Fietkauec8aa662010-05-13 16:48:03 +020069
70 /* time of last status update */
Thomas Huehn91340732015-03-24 21:09:39 +010071 unsigned long last_stats_update;
Felix Fietkauec8aa662010-05-13 16:48:03 +020072
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
Felix Fietkaua0497f92013-02-13 10:51:08 +010091 u8 cck_supported;
92 u8 cck_supported_short;
93
Felix Fietkau41d08582016-12-14 20:46:54 +010094 /* Bitfield of supported MCS rates of all groups */
95 u16 supported[MINSTREL_GROUPS_NB];
96
Felix Fietkauec8aa662010-05-13 16:48:03 +020097 /* MCS rate group info and statistics */
Karl Beldan8a0ee4f2014-10-20 15:46:00 +020098 struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB];
Felix Fietkauec8aa662010-05-13 16:48:03 +020099};
100
101struct minstrel_ht_sta_priv {
102 union {
103 struct minstrel_ht_sta ht;
104 struct minstrel_sta_info legacy;
105 };
Felix Fietkauec8aa662010-05-13 16:48:03 +0200106 void *ratelist;
107 void *sample_table;
108 bool is_ht;
109};
110
111void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
Thomas Huehn50e55a82015-03-24 21:09:41 +0100112int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate,
113 int prob_ewma);
Felix Fietkauec8aa662010-05-13 16:48:03 +0200114
115#endif