321-cfg80211-Add-airtime-statistics-and-settings.patch 6.9 KB

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