Skip to content

Commit d7c1a9a

Browse files
Aloka Dixitjmberg-intel
authored andcommitted
wifi: nl80211: validate and configure puncturing bitmap
- New feature flag, NL80211_EXT_FEATURE_PUNCT, to advertise driver support for preamble puncturing in AP mode. - New attribute, NL80211_ATTR_PUNCT_BITMAP, to receive a puncturing bitmap from the userspace during AP bring up (NL80211_CMD_START_AP) and channel switch (NL80211_CMD_CHANNEL_SWITCH) operations. Each bit corresponds to a 20 MHz channel in the operating bandwidth, lowest bit for the lowest channel. Bit set to 1 indicates that the channel is punctured. Higher 16 bits are reserved. - New members added to structures cfg80211_ap_settings and cfg80211_csa_settings to propagate the bitmap to the driver after validation. Signed-off-by: Aloka Dixit <[email protected]> Signed-off-by: Muna Sinada <[email protected]> Link: https://lore.kernel.org/r/[email protected] [move validation against 0xffff into policy] Signed-off-by: Johannes Berg <[email protected]>
1 parent b25413f commit d7c1a9a

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

include/net/cfg80211.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,9 @@ struct cfg80211_unsol_bcast_probe_resp {
13161316
* @fils_discovery: FILS discovery transmission parameters
13171317
* @unsol_bcast_probe_resp: Unsolicited broadcast probe response parameters
13181318
* @mbssid_config: AP settings for multiple bssid
1319+
* @punct_bitmap: Preamble puncturing bitmap. Each bit represents
1320+
* a 20 MHz channel, lowest bit corresponding to the lowest channel.
1321+
* Bit set to 1 indicates that the channel is punctured.
13191322
*/
13201323
struct cfg80211_ap_settings {
13211324
struct cfg80211_chan_def chandef;
@@ -1350,6 +1353,7 @@ struct cfg80211_ap_settings {
13501353
struct cfg80211_fils_discovery fils_discovery;
13511354
struct cfg80211_unsol_bcast_probe_resp unsol_bcast_probe_resp;
13521355
struct cfg80211_mbssid_config mbssid_config;
1356+
u16 punct_bitmap;
13531357
};
13541358

13551359
/**
@@ -1367,6 +1371,9 @@ struct cfg80211_ap_settings {
13671371
* @radar_required: whether radar detection is required on the new channel
13681372
* @block_tx: whether transmissions should be blocked while changing
13691373
* @count: number of beacons until switch
1374+
* @punct_bitmap: Preamble puncturing bitmap. Each bit represents
1375+
* a 20 MHz channel, lowest bit corresponding to the lowest channel.
1376+
* Bit set to 1 indicates that the channel is punctured.
13701377
*/
13711378
struct cfg80211_csa_settings {
13721379
struct cfg80211_chan_def chandef;
@@ -1379,6 +1386,7 @@ struct cfg80211_csa_settings {
13791386
bool radar_required;
13801387
bool block_tx;
13811388
u8 count;
1389+
u16 punct_bitmap;
13821390
};
13831391

13841392
/**

include/uapi/linux/nl80211.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,12 @@ enum nl80211_commands {
27692769
* the incoming frame RX timestamp.
27702770
* @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent
27712771
* (re)associations.
2772+
*
2773+
* @NL80211_ATTR_PUNCT_BITMAP: (u32) Preamble puncturing bitmap, lowest
2774+
* bit corresponds to the lowest 20 MHz channel. Each bit set to 1
2775+
* indicates that the sub-channel is punctured. Higher 16 bits are
2776+
* reserved.
2777+
*
27722778
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
27732779
* @NL80211_ATTR_MAX: highest attribute number currently defined
27742780
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3298,6 +3304,8 @@ enum nl80211_attrs {
32983304
NL80211_ATTR_RX_HW_TIMESTAMP,
32993305
NL80211_ATTR_TD_BITMAP,
33003306

3307+
NL80211_ATTR_PUNCT_BITMAP,
3308+
33013309
/* add attributes here, update the policy in nl80211.c */
33023310

33033311
__NL80211_ATTR_AFTER_LAST,
@@ -6313,6 +6321,8 @@ enum nl80211_feature_flags {
63136321
* might apply, e.g. no scans in progress, no offchannel operations
63146322
* in progress, and no active connections.
63156323
*
6324+
* @NL80211_EXT_FEATURE_PUNCT: Driver supports preamble puncturing in AP mode.
6325+
*
63166326
* @NUM_NL80211_EXT_FEATURES: number of extended features.
63176327
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
63186328
*/
@@ -6381,6 +6391,7 @@ enum nl80211_ext_feature_index {
63816391
NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
63826392
NL80211_EXT_FEATURE_RADAR_BACKGROUND,
63836393
NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE,
6394+
NL80211_EXT_FEATURE_PUNCT,
63846395

63856396
/* add new features before the definition below */
63866397
NUM_NL80211_EXT_FEATURES,

net/wireless/nl80211.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
805805
[NL80211_ATTR_MLD_ADDR] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
806806
[NL80211_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG },
807807
[NL80211_ATTR_MAX_NUM_AKM_SUITES] = { .type = NLA_REJECT },
808+
[NL80211_ATTR_PUNCT_BITMAP] = NLA_POLICY_RANGE(NLA_U8, 0, 0xffff),
808809
};
809810

810811
/* policy for the key attributes */
@@ -3173,6 +3174,21 @@ static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev)
31733174
wdev->iftype == NL80211_IFTYPE_P2P_GO;
31743175
}
31753176

3177+
static int nl80211_parse_punct_bitmap(struct cfg80211_registered_device *rdev,
3178+
struct genl_info *info,
3179+
const struct cfg80211_chan_def *chandef,
3180+
u16 *punct_bitmap)
3181+
{
3182+
if (!wiphy_ext_feature_isset(&rdev->wiphy, NL80211_EXT_FEATURE_PUNCT))
3183+
return -EINVAL;
3184+
3185+
*punct_bitmap = nla_get_u32(info->attrs[NL80211_ATTR_PUNCT_BITMAP]);
3186+
if (!cfg80211_valid_disable_subchannel_bitmap(punct_bitmap, chandef))
3187+
return -EINVAL;
3188+
3189+
return 0;
3190+
}
3191+
31763192
int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
31773193
struct genl_info *info,
31783194
struct cfg80211_chan_def *chandef)
@@ -5957,6 +5973,14 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
59575973
goto out;
59585974
}
59595975

5976+
if (info->attrs[NL80211_ATTR_PUNCT_BITMAP]) {
5977+
err = nl80211_parse_punct_bitmap(rdev, info,
5978+
&params->chandef,
5979+
&params->punct_bitmap);
5980+
if (err)
5981+
goto out;
5982+
}
5983+
59605984
if (!cfg80211_reg_can_beacon_relax(&rdev->wiphy, &params->chandef,
59615985
wdev->iftype)) {
59625986
err = -EINVAL;
@@ -10114,6 +10138,14 @@ static int nl80211_channel_switch(struct sk_buff *skb, struct genl_info *info)
1011410138
if (info->attrs[NL80211_ATTR_CH_SWITCH_BLOCK_TX])
1011510139
params.block_tx = true;
1011610140

10141+
if (info->attrs[NL80211_ATTR_PUNCT_BITMAP]) {
10142+
err = nl80211_parse_punct_bitmap(rdev, info,
10143+
&params.chandef,
10144+
&params.punct_bitmap);
10145+
if (err)
10146+
goto free;
10147+
}
10148+
1011710149
wdev_lock(wdev);
1011810150
err = rdev_channel_switch(rdev, dev, &params);
1011910151
wdev_unlock(wdev);

0 commit comments

Comments
 (0)