344-v6.3-0002-wifi-nl80211-validate-and-configure-puncturing-bitma.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. From d7c1a9a0ed180d8884798ce97afe7283622a484f Mon Sep 17 00:00:00 2001
  2. From: Aloka Dixit <quic_alokad@quicinc.com>
  3. Date: Mon, 30 Jan 2023 16:12:25 -0800
  4. Subject: [PATCH] wifi: nl80211: validate and configure puncturing bitmap
  5. - New feature flag, NL80211_EXT_FEATURE_PUNCT, to advertise
  6. driver support for preamble puncturing in AP mode.
  7. - New attribute, NL80211_ATTR_PUNCT_BITMAP, to receive a puncturing
  8. bitmap from the userspace during AP bring up (NL80211_CMD_START_AP)
  9. and channel switch (NL80211_CMD_CHANNEL_SWITCH) operations. Each bit
  10. corresponds to a 20 MHz channel in the operating bandwidth, lowest
  11. bit for the lowest channel. Bit set to 1 indicates that the channel
  12. is punctured. Higher 16 bits are reserved.
  13. - New members added to structures cfg80211_ap_settings and
  14. cfg80211_csa_settings to propagate the bitmap to the driver after
  15. validation.
  16. Signed-off-by: Aloka Dixit <quic_alokad@quicinc.com>
  17. Signed-off-by: Muna Sinada <quic_msinada@quicinc.com>
  18. Link: https://lore.kernel.org/r/20230131001227.25014-3-quic_alokad@quicinc.com
  19. [move validation against 0xffff into policy]
  20. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  21. ---
  22. include/net/cfg80211.h | 8 ++++++++
  23. include/uapi/linux/nl80211.h | 11 +++++++++++
  24. net/wireless/nl80211.c | 32 ++++++++++++++++++++++++++++++++
  25. 3 files changed, 51 insertions(+)
  26. --- a/include/net/cfg80211.h
  27. +++ b/include/net/cfg80211.h
  28. @@ -1330,6 +1330,9 @@ struct cfg80211_unsol_bcast_probe_resp {
  29. * @fils_discovery: FILS discovery transmission parameters
  30. * @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
  31. * @mbssid_config: AP settings for multiple bssid
  32. + * @punct_bitmap: Preamble puncturing bitmap. Each bit represents
  33. + * a 20 MHz channel, lowest bit corresponding to the lowest channel.
  34. + * Bit set to 1 indicates that the channel is punctured.
  35. */
  36. struct cfg80211_ap_settings {
  37. struct cfg80211_chan_def chandef;
  38. @@ -1364,6 +1367,7 @@ struct cfg80211_ap_settings {
  39. struct cfg80211_fils_discovery fils_discovery;
  40. struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
  41. struct cfg80211_mbssid_config mbssid_config;
  42. + u16 punct_bitmap;
  43. };
  44. /**
  45. @@ -1381,6 +1385,9 @@ struct cfg80211_ap_settings {
  46. * @radar_required: whether radar detection is required on the new channel
  47. * @block_tx: whether transmissions should be blocked while changing
  48. * @count: number of beacons until switch
  49. + * @punct_bitmap: Preamble puncturing bitmap. Each bit represents
  50. + * a 20 MHz channel, lowest bit corresponding to the lowest channel.
  51. + * Bit set to 1 indicates that the channel is punctured.
  52. */
  53. struct cfg80211_csa_settings {
  54. struct cfg80211_chan_def chandef;
  55. @@ -1393,6 +1400,7 @@ struct cfg80211_csa_settings {
  56. bool radar_required;
  57. bool block_tx;
  58. u8 count;
  59. + u16 punct_bitmap;
  60. };
  61. /**
  62. --- a/include/uapi/linux/nl80211.h
  63. +++ b/include/uapi/linux/nl80211.h
  64. @@ -2751,6 +2751,12 @@ enum nl80211_commands {
  65. * the incoming frame RX timestamp.
  66. * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent
  67. * (re)associations.
  68. + *
  69. + * @NL80211_ATTR_PUNCT_BITMAP: (u32) Preamble puncturing bitmap, lowest
  70. + * bit corresponds to the lowest 20 MHz channel. Each bit set to 1
  71. + * indicates that the sub-channel is punctured. Higher 16 bits are
  72. + * reserved.
  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. @@ -3280,6 +3286,8 @@ enum nl80211_attrs {
  78. NL80211_ATTR_RX_HW_TIMESTAMP,
  79. NL80211_ATTR_TD_BITMAP,
  80. + NL80211_ATTR_PUNCT_BITMAP,
  81. +
  82. /* add attributes here, update the policy in nl80211.c */
  83. __NL80211_ATTR_AFTER_LAST,
  84. @@ -6294,6 +6302,8 @@ enum nl80211_feature_flags {
  85. * might apply, e.g. no scans in progress, no offchannel operations
  86. * in progress, and no active connections.
  87. *
  88. + * @NL80211_EXT_FEATURE_PUNCT: Driver supports preamble puncturing in AP mode.
  89. + *
  90. * @NUM_NL80211_EXT_FEATURES: number of extended features.
  91. * @MAX_NL80211_EXT_FEATURES: highest extended feature index.
  92. */
  93. @@ -6362,6 +6372,7 @@ enum nl80211_ext_feature_index {
  94. NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
  95. NL80211_EXT_FEATURE_RADAR_BACKGROUND,
  96. NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE,
  97. + NL80211_EXT_FEATURE_PUNCT,
  98. /* add new features before the definition below */
  99. NUM_NL80211_EXT_FEATURES,
  100. --- a/net/wireless/nl80211.c
  101. +++ b/net/wireless/nl80211.c
  102. @@ -799,6 +799,7 @@ static const struct nla_policy nl80211_p
  103. [NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
  104. [NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG },
  105. [NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT },
  106. + [NL80211_ATTR_PUNCT_BITMAP] = NLA_POLICY_RANGE(NLA_U8, 0, 0xffff),
  107. };
  108. /* policy for the key attributes */
  109. @@ -3167,6 +3168,21 @@ static bool nl80211_can_set_dev_channel(
  110. wdev->iftype == NL80211_IFTYPE_P2P_GO;
  111. }
  112. +static int nl80211_parse_punct_bitmap(struct cfg80211_registered_device *rdev,
  113. + struct genl_info *info,
  114. + const struct cfg80211_chan_def *chandef,
  115. + u16 *punct_bitmap)
  116. +{
  117. + if (!wiphy_ext_feature_isset(&rdev->wiphy, NL80211_EXT_FEATURE_PUNCT))
  118. + return -EINVAL;
  119. +
  120. + *punct_bitmap = nla_get_u32(info->attrs[NL80211_ATTR_PUNCT_BITMAP]);
  121. + if (!cfg80211_valid_disable_subchannel_bitmap(punct_bitmap, chandef))
  122. + return -EINVAL;
  123. +
  124. + return 0;
  125. +}
  126. +
  127. int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
  128. struct genl_info *info,
  129. struct cfg80211_chan_def *chandef)
  130. @@ -5912,6 +5928,14 @@ static int nl80211_start_ap(struct sk_bu
  131. goto out;
  132. }
  133. + if (info->attrs[NL80211_ATTR_PUNCT_BITMAP]) {
  134. + err = nl80211_parse_punct_bitmap(rdev, info,
  135. + &params->chandef,
  136. + &params->punct_bitmap);
  137. + if (err)
  138. + goto out;
  139. + }
  140. +
  141. if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &params->chandef,
  142. wdev->iftype)) {
  143. err = -EINVAL;
  144. @@ -10050,6 +10074,14 @@ skip_beacons:
  145. if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX])
  146. params.block_tx = true;
  147. + if (info->attrs[NL80211_ATTR_PUNCT_BITMAP]) {
  148. + err = nl80211_parse_punct_bitmap(rdev, info,
  149. + &params.chandef,
  150. + &params.punct_bitmap);
  151. + if (err)
  152. + goto free;
  153. + }
  154. +
  155. wdev_lock(wdev);
  156. err = rdev_channel_switch(rdev, dev, &params);
  157. wdev_unlock(wdev);