Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 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 | */ |
Felix Fietkau | 7f2e12e | 2019-03-25 09:50:15 +0100 | [diff] [blame] | 16 | #define MINSTREL_MAX_STREAMS 4 |
Karl Beldan | 8a0ee4f | 2014-10-20 15:46:00 +0200 | [diff] [blame] | 17 | #define MINSTREL_HT_STREAM_GROUPS 4 /* BW(=2) * SGI(=2) */ |
Karl Beldan | 9208247 | 2014-10-21 10:38:38 +0200 | [diff] [blame] | 18 | #define MINSTREL_VHT_STREAM_GROUPS 6 /* BW(=3) * SGI(=2) */ |
Karl Beldan | 8a0ee4f | 2014-10-20 15:46:00 +0200 | [diff] [blame] | 19 | |
| 20 | #define MINSTREL_HT_GROUPS_NB (MINSTREL_MAX_STREAMS * \ |
| 21 | MINSTREL_HT_STREAM_GROUPS) |
Karl Beldan | 9208247 | 2014-10-21 10:38:38 +0200 | [diff] [blame] | 22 | #define MINSTREL_VHT_GROUPS_NB (MINSTREL_MAX_STREAMS * \ |
| 23 | MINSTREL_VHT_STREAM_GROUPS) |
Karl Beldan | 8a0ee4f | 2014-10-20 15:46:00 +0200 | [diff] [blame] | 24 | #define MINSTREL_CCK_GROUPS_NB 1 |
| 25 | #define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB + \ |
Karl Beldan | 9208247 | 2014-10-21 10:38:38 +0200 | [diff] [blame] | 26 | MINSTREL_VHT_GROUPS_NB + \ |
Karl Beldan | 8a0ee4f | 2014-10-20 15:46:00 +0200 | [diff] [blame] | 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) |
Karl Beldan | 9208247 | 2014-10-21 10:38:38 +0200 | [diff] [blame] | 31 | #define MINSTREL_VHT_GROUP_0 (MINSTREL_CCK_GROUP + 1) |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 32 | |
Karl Beldan | 9208247 | 2014-10-21 10:38:38 +0200 | [diff] [blame] | 33 | #define MCS_GROUP_RATES 10 |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 34 | |
| 35 | struct mcs_group { |
Felix Fietkau | 202df50 | 2018-10-06 19:35:02 +0200 | [diff] [blame] | 36 | u16 flags; |
| 37 | u8 streams; |
| 38 | u8 shift; |
| 39 | u16 duration[MCS_GROUP_RATES]; |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 40 | }; |
| 41 | |
John W. Linville | de66bfd | 2010-06-24 13:03:14 -0400 | [diff] [blame] | 42 | extern const struct mcs_group minstrel_mcs_groups[]; |
| 43 | |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 44 | struct minstrel_mcs_group_data { |
| 45 | u8 index; |
| 46 | u8 column; |
| 47 | |
Thomas Huehn | 5935839 | 2014-09-09 23:22:14 +0200 | [diff] [blame] | 48 | /* sorted rate set within a MCS group*/ |
Karl Beldan | d4d141c | 2014-10-20 15:45:59 +0200 | [diff] [blame] | 49 | u16 max_group_tp_rate[MAX_THR_RATES]; |
| 50 | u16 max_group_prob_rate; |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 51 | |
| 52 | /* MCS rate statistics */ |
| 53 | struct minstrel_rate_stats rates[MCS_GROUP_RATES]; |
| 54 | }; |
| 55 | |
| 56 | struct minstrel_ht_sta { |
Felix Fietkau | a856666 | 2013-04-22 16:14:42 +0200 | [diff] [blame] | 57 | struct ieee80211_sta *sta; |
| 58 | |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 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 | |
Thomas Huehn | 5935839 | 2014-09-09 23:22:14 +0200 | [diff] [blame] | 66 | /* overall sorted rate set */ |
Karl Beldan | d4d141c | 2014-10-20 15:45:59 +0200 | [diff] [blame] | 67 | u16 max_tp_rate[MAX_THR_RATES]; |
| 68 | u16 max_prob_rate; |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 69 | |
| 70 | /* time of last status update */ |
Thomas Huehn | 9134073 | 2015-03-24 21:09:39 +0100 | [diff] [blame] | 71 | unsigned long last_stats_update; |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 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 | |
Felix Fietkau | a0497f9 | 2013-02-13 10:51:08 +0100 | [diff] [blame] | 91 | u8 cck_supported; |
| 92 | u8 cck_supported_short; |
| 93 | |
Felix Fietkau | 41d0858 | 2016-12-14 20:46:54 +0100 | [diff] [blame] | 94 | /* Bitfield of supported MCS rates of all groups */ |
| 95 | u16 supported[MINSTREL_GROUPS_NB]; |
| 96 | |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 97 | /* MCS rate group info and statistics */ |
Karl Beldan | 8a0ee4f | 2014-10-20 15:46:00 +0200 | [diff] [blame] | 98 | struct minstrel_mcs_group_data groups[MINSTREL_GROUPS_NB]; |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | struct minstrel_ht_sta_priv { |
| 102 | union { |
| 103 | struct minstrel_ht_sta ht; |
| 104 | struct minstrel_sta_info legacy; |
| 105 | }; |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 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); |
Thomas Huehn | 50e55a8 | 2015-03-24 21:09:41 +0100 | [diff] [blame] | 112 | int minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, |
| 113 | int prob_ewma); |
Felix Fietkau | ec8aa66 | 2010-05-13 16:48:03 +0200 | [diff] [blame] | 114 | |
| 115 | #endif |