mac80211: update to version 4.19.85
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / subsys / 321-cfg80211-Add-airtime-statistics-and-settings.patch
1 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
2 Date: Tue, 18 Dec 2018 17:02:07 -0800
3 Subject: [PATCH] cfg80211: Add airtime statistics and settings
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 This adds TX airtime statistics to the cfg80211 station dump (to go along
9 with the RX info already present), and adds a new parameter to set the
10 airtime weight of each station. The latter allows userspace to implement
11 policies for different stations by varying their weights.
12
13 Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
14 [rmanohar@codeaurora.org: fixed checkpatch warnings]
15 Signed-off-by: Rajkumar Manoharan <rmanohar@codeaurora.org>
16 [move airtime weight != 0 check into policy]
17 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
18 ---
19
20 --- a/include/net/cfg80211.h
21 +++ b/include/net/cfg80211.h
22 @@ -988,6 +988,7 @@ enum station_parameters_apply_mask {
23 * @support_p2p_ps: information if station supports P2P PS mechanism
24 * @he_capa: HE capabilities of station
25 * @he_capa_len: the length of the HE capabilities
26 + * @airtime_weight: airtime scheduler weight for this station
27 */
28 struct station_parameters {
29 const u8 *supported_rates;
30 @@ -1017,6 +1018,7 @@ struct station_parameters {
31 int support_p2p_ps;
32 const struct ieee80211_he_cap_elem *he_capa;
33 u8 he_capa_len;
34 + u16 airtime_weight;
35 };
36
37 /**
38 @@ -1284,6 +1286,8 @@ struct cfg80211_tid_stats {
39 * @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received
40 * from this peer
41 * @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer
42 + * @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer
43 + * @airtime_weight: current airtime scheduling weight
44 * @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last
45 * (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs.
46 * Note that this doesn't use the @filled bit, but is used if non-NULL.
47 @@ -1330,12 +1334,15 @@ struct station_info {
48
49 u32 expected_throughput;
50
51 - u64 rx_beacon;
52 + u64 tx_duration;
53 u64 rx_duration;
54 + u64 rx_beacon;
55 u8 rx_beacon_signal_avg;
56 struct cfg80211_tid_stats *pertid;
57 s8 ack_signal;
58 s8 avg_ack_signal;
59 +
60 + u16 airtime_weight;
61 };
62
63 #if IS_ENABLED(CPTCFG_CFG80211)
64 @@ -2361,6 +2368,8 @@ enum wiphy_params_flags {
65 WIPHY_PARAM_TXQ_QUANTUM = 1 << 8,
66 };
67
68 +#define IEEE80211_DEFAULT_AIRTIME_WEIGHT 256
69 +
70 /**
71 * struct cfg80211_pmksa - PMK Security Association
72 *
73 --- a/include/uapi/linux/nl80211.h
74 +++ b/include/uapi/linux/nl80211.h
75 @@ -2241,6 +2241,9 @@ enum nl80211_commands {
76 * association request when used with NL80211_CMD_NEW_STATION). Can be set
77 * only if %NL80211_STA_FLAG_WME is set.
78 *
79 + * @NL80211_ATTR_AIRTIME_WEIGHT: Station's weight when scheduled by the airtime
80 + * scheduler.
81 + *
82 * @NUM_NL80211_ATTR: total number of nl80211_attrs available
83 * @NL80211_ATTR_MAX: highest attribute number currently defined
84 * @__NL80211_ATTR_AFTER_LAST: internal use
85 @@ -2682,6 +2685,14 @@ enum nl80211_attrs {
86
87 NL80211_ATTR_HE_CAPABILITY,
88
89 + /* not backported yet */
90 + NL80211_ATTR_FTM_RESPONDER,
91 + NL80211_ATTR_FTM_RESPONDER_STATS,
92 + NL80211_ATTR_TIMEOUT,
93 + NL80211_ATTR_PEER_MEASUREMENTS,
94 +
95 + NL80211_ATTR_AIRTIME_WEIGHT,
96 +
97 /* add attributes here, update the policy in nl80211.c */
98
99 __NL80211_ATTR_AFTER_LAST,
100 @@ -3052,6 +3063,9 @@ enum nl80211_sta_bss_param {
101 * @NL80211_STA_INFO_ACK_SIGNAL: signal strength of the last ACK frame(u8, dBm)
102 * @NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG: avg signal strength of (data)
103 * ACK frame (s8, dBm)
104 + * @NL80211_STA_INFO_TX_DURATION: aggregate PPDU duration for all frames
105 + * sent to the station (u64, usec)
106 + * @NL80211_STA_INFO_AIRTIME_WEIGHT: current airtime weight for station (u16)
107 * @__NL80211_STA_INFO_AFTER_LAST: internal
108 * @NL80211_STA_INFO_MAX: highest possible station info attribute
109 */
110 @@ -3093,6 +3107,14 @@ enum nl80211_sta_info {
111 NL80211_STA_INFO_ACK_SIGNAL,
112 NL80211_STA_INFO_DATA_ACK_SIGNAL_AVG,
113
114 + /* not backported yet */
115 + NL80211_STA_INFO_RX_MPDUS,
116 + NL80211_STA_INFO_FCS_ERROR_COUNT,
117 + NL80211_STA_INFO_CONNECTED_TO_GATE,
118 +
119 + NL80211_STA_INFO_TX_DURATION,
120 + NL80211_STA_INFO_AIRTIME_WEIGHT,
121 +
122 /* keep last */
123 __NL80211_STA_INFO_AFTER_LAST,
124 NL80211_STA_INFO_MAX = __NL80211_STA_INFO_AFTER_LAST - 1
125 @@ -5224,6 +5246,10 @@ enum nl80211_feature_flags {
126 * except for supported rates from the probe request content if requested
127 * by the %NL80211_SCAN_FLAG_MIN_PREQ_CONTENT flag.
128 *
129 + * @NL80211_EXT_FEATURE_AIRTIME_FAIRNESS: Driver supports getting airtime
130 + * fairness for transmitted packets and has enabled airtime fairness
131 + * scheduling.
132 + *
133 * @NUM_NL80211_EXT_FEATURES: number of extended features.
134 * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
135 */
136 @@ -5260,6 +5286,12 @@ enum nl80211_ext_feature_index {
137 NL80211_EXT_FEATURE_SCAN_RANDOM_SN,
138 NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT,
139
140 + /* --- not backported yet --- */
141 + NL80211_EXT_FEATURE_CAN_REPLACE_PTK0,
142 + NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER,
143 +
144 + NL80211_EXT_FEATURE_AIRTIME_FAIRNESS,
145 +
146 /* add new features before the definition below */
147 NUM_NL80211_EXT_FEATURES,
148 MAX_NL80211_EXT_FEATURES = NUM_NL80211_EXT_FEATURES - 1
149 --- a/net/wireless/nl80211.c
150 +++ b/net/wireless/nl80211.c
151 @@ -463,6 +463,7 @@ static const struct nla_policy nl80211_p
152 [NL80211_ATTR_TXQ_QUANTUM] = { .type = NLA_U32 },
153 [NL80211_ATTR_HE_CAPABILITY] = { .type = NLA_BINARY,
154 .len = NL80211_HE_MAX_CAPABILITY_LEN },
155 + [NL80211_ATTR_AIRTIME_WEIGHT] = NLA_POLICY_MIN(NLA_U16, 1),
156 };
157
158 /* policy for the key attributes */
159 @@ -4703,6 +4704,11 @@ static int nl80211_send_station(struct s
160 PUT_SINFO(PLID, plid, u16);
161 PUT_SINFO(PLINK_STATE, plink_state, u8);
162 PUT_SINFO_U64(RX_DURATION, rx_duration);
163 + PUT_SINFO_U64(TX_DURATION, tx_duration);
164 +
165 + if (wiphy_ext_feature_isset(&rdev->wiphy,
166 + NL80211_EXT_FEATURE_AIRTIME_FAIRNESS))
167 + PUT_SINFO(AIRTIME_WEIGHT, airtime_weight, u16);
168
169 switch (rdev->wiphy.signal_type) {
170 case CFG80211_SIGNAL_TYPE_MBM:
171 @@ -5339,6 +5345,15 @@ static int nl80211_set_station(struct sk
172 nla_get_u8(info->attrs[NL80211_ATTR_OPMODE_NOTIF]);
173 }
174
175 + if (info->attrs[NL80211_ATTR_AIRTIME_WEIGHT])
176 + params.airtime_weight =
177 + nla_get_u16(info->attrs[NL80211_ATTR_AIRTIME_WEIGHT]);
178 +
179 + if (params.airtime_weight &&
180 + !wiphy_ext_feature_isset(&rdev->wiphy,
181 + NL80211_EXT_FEATURE_AIRTIME_FAIRNESS))
182 + return -EOPNOTSUPP;
183 +
184 /* Include parameters for TDLS peer (will check later) */
185 err = nl80211_set_station_tdls(info, &params);
186 if (err)
187 @@ -5477,6 +5492,15 @@ static int nl80211_new_station(struct sk
188 return -EINVAL;
189 }
190
191 + if (info->attrs[NL80211_ATTR_AIRTIME_WEIGHT])
192 + params.airtime_weight =
193 + nla_get_u16(info->attrs[NL80211_ATTR_AIRTIME_WEIGHT]);
194 +
195 + if (params.airtime_weight &&
196 + !wiphy_ext_feature_isset(&rdev->wiphy,
197 + NL80211_EXT_FEATURE_AIRTIME_FAIRNESS))
198 + return -EOPNOTSUPP;
199 +
200 err = nl80211_parse_sta_channel_info(info, &params);
201 if (err)
202 return err;