Skip to content

Commit b25413f

Browse files
Aloka Dixitjmberg-intel
authored andcommitted
wifi: cfg80211: move puncturing bitmap validation from mac80211
- Move ieee80211_valid_disable_subchannel_bitmap() from mlme.c to chan.c, rename it as cfg80211_valid_disable_subchannel_bitmap() and export it. - Modify the prototype to include struct cfg80211_chan_def instead of only bandwidth to support a check which returns false if the primary channel is punctured. Signed-off-by: Aloka Dixit <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 90b2c3c commit b25413f

File tree

3 files changed

+87
-67
lines changed

3 files changed

+87
-67
lines changed

include/net/cfg80211.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8952,4 +8952,16 @@ static inline int cfg80211_color_change_notify(struct net_device *dev)
89528952
0, 0);
89538953
}
89548954

8955+
/**
8956+
* cfg80211_valid_disable_subchannel_bitmap - validate puncturing bitmap
8957+
* @bitmap: bitmap to be validated
8958+
* @chandef: channel definition
8959+
*
8960+
* Validate the puncturing bitmap.
8961+
*
8962+
* Return: %true if the bitmap is valid. %false otherwise.
8963+
*/
8964+
bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap,
8965+
const struct cfg80211_chan_def *chandef);
8966+
89558967
#endif /* __NET_CFG80211_H */

net/mac80211/mlme.c

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -88,67 +88,6 @@ MODULE_PARM_DESC(probe_wait_ms,
8888
*/
8989
#define IEEE80211_SIGNAL_AVE_MIN_COUNT 4
9090

91-
struct ieee80211_per_bw_puncturing_values {
92-
u8 len;
93-
const u16 *valid_values;
94-
};
95-
96-
static const u16 puncturing_values_80mhz[] = {
97-
0x8, 0x4, 0x2, 0x1
98-
};
99-
100-
static const u16 puncturing_values_160mhz[] = {
101-
0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1, 0xc0, 0x30, 0xc, 0x3
102-
};
103-
104-
static const u16 puncturing_values_320mhz[] = {
105-
0xc000, 0x3000, 0xc00, 0x300, 0xc0, 0x30, 0xc, 0x3, 0xf000, 0xf00,
106-
0xf0, 0xf, 0xfc00, 0xf300, 0xf0c0, 0xf030, 0xf00c, 0xf003, 0xc00f,
107-
0x300f, 0xc0f, 0x30f, 0xcf, 0x3f
108-
};
109-
110-
#define IEEE80211_PER_BW_VALID_PUNCTURING_VALUES(_bw) \
111-
{ \
112-
.len = ARRAY_SIZE(puncturing_values_ ## _bw ## mhz), \
113-
.valid_values = puncturing_values_ ## _bw ## mhz \
114-
}
115-
116-
static const struct ieee80211_per_bw_puncturing_values per_bw_puncturing[] = {
117-
IEEE80211_PER_BW_VALID_PUNCTURING_VALUES(80),
118-
IEEE80211_PER_BW_VALID_PUNCTURING_VALUES(160),
119-
IEEE80211_PER_BW_VALID_PUNCTURING_VALUES(320)
120-
};
121-
122-
static bool ieee80211_valid_disable_subchannel_bitmap(u16 *bitmap,
123-
enum nl80211_chan_width bw)
124-
{
125-
u32 idx, i;
126-
127-
switch (bw) {
128-
case NL80211_CHAN_WIDTH_80:
129-
idx = 0;
130-
break;
131-
case NL80211_CHAN_WIDTH_160:
132-
idx = 1;
133-
break;
134-
case NL80211_CHAN_WIDTH_320:
135-
idx = 2;
136-
break;
137-
default:
138-
*bitmap = 0;
139-
break;
140-
}
141-
142-
if (!*bitmap)
143-
return true;
144-
145-
for (i = 0; i < per_bw_puncturing[idx].len; i++)
146-
if (per_bw_puncturing[idx].valid_values[i] == *bitmap)
147-
return true;
148-
149-
return false;
150-
}
151-
15291
/*
15392
* Extract from the given disabled subchannel bitmap (raw format
15493
* from the EHT Operation Element) the bits for the subchannel
@@ -206,8 +145,8 @@ ieee80211_handle_puncturing_bitmap(struct ieee80211_link_data *link,
206145
ieee80211_extract_dis_subch_bmap(eht_oper, chandef,
207146
bitmap);
208147

209-
if (ieee80211_valid_disable_subchannel_bitmap(&bitmap,
210-
chandef->width))
148+
if (cfg80211_valid_disable_subchannel_bitmap(&bitmap,
149+
chandef))
211150
break;
212151
link->u.mgd.conn_flags |=
213152
ieee80211_chandef_downgrade(chandef);
@@ -5638,8 +5577,8 @@ static bool ieee80211_config_puncturing(struct ieee80211_link_data *link,
56385577
extracted == link->conf->eht_puncturing)
56395578
return true;
56405579

5641-
if (!ieee80211_valid_disable_subchannel_bitmap(&bitmap,
5642-
link->conf->chandef.width)) {
5580+
if (!cfg80211_valid_disable_subchannel_bitmap(&bitmap,
5581+
&link->conf->chandef)) {
56435582
link_info(link,
56445583
"Got an invalid disable subchannel bitmap from AP %pM: bitmap = 0x%x, bw = 0x%x. disconnect\n",
56455584
link->u.mgd.bssid,
@@ -7132,8 +7071,8 @@ ieee80211_setup_assoc_link(struct ieee80211_sub_if_data *sdata,
71327071
u16 bitmap;
71337072

71347073
bitmap = get_unaligned_le16(disable_subchannel_bitmap);
7135-
if (ieee80211_valid_disable_subchannel_bitmap(&bitmap,
7136-
link->conf->chandef.width))
7074+
if (cfg80211_valid_disable_subchannel_bitmap(&bitmap,
7075+
&link->conf->chandef))
71377076
ieee80211_handle_puncturing_bitmap(link,
71387077
eht_oper,
71397078
bitmap,

net/wireless/chan.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,3 +1460,72 @@ struct cfg80211_chan_def *wdev_chandef(struct wireless_dev *wdev,
14601460
}
14611461
}
14621462
EXPORT_SYMBOL(wdev_chandef);
1463+
1464+
struct cfg80211_per_bw_puncturing_values {
1465+
u8 len;
1466+
const u16 *valid_values;
1467+
};
1468+
1469+
static const u16 puncturing_values_80mhz[] = {
1470+
0x8, 0x4, 0x2, 0x1
1471+
};
1472+
1473+
static const u16 puncturing_values_160mhz[] = {
1474+
0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1, 0xc0, 0x30, 0xc, 0x3
1475+
};
1476+
1477+
static const u16 puncturing_values_320mhz[] = {
1478+
0xc000, 0x3000, 0xc00, 0x300, 0xc0, 0x30, 0xc, 0x3, 0xf000, 0xf00,
1479+
0xf0, 0xf, 0xfc00, 0xf300, 0xf0c0, 0xf030, 0xf00c, 0xf003, 0xc00f,
1480+
0x300f, 0xc0f, 0x30f, 0xcf, 0x3f
1481+
};
1482+
1483+
#define CFG80211_PER_BW_VALID_PUNCTURING_VALUES(_bw) \
1484+
{ \
1485+
.len = ARRAY_SIZE(puncturing_values_ ## _bw ## mhz), \
1486+
.valid_values = puncturing_values_ ## _bw ## mhz \
1487+
}
1488+
1489+
static const struct cfg80211_per_bw_puncturing_values per_bw_puncturing[] = {
1490+
CFG80211_PER_BW_VALID_PUNCTURING_VALUES(80),
1491+
CFG80211_PER_BW_VALID_PUNCTURING_VALUES(160),
1492+
CFG80211_PER_BW_VALID_PUNCTURING_VALUES(320)
1493+
};
1494+
1495+
bool cfg80211_valid_disable_subchannel_bitmap(u16 *bitmap,
1496+
const struct cfg80211_chan_def *chandef)
1497+
{
1498+
u32 idx, i, start_freq;
1499+
1500+
switch (chandef->width) {
1501+
case NL80211_CHAN_WIDTH_80:
1502+
idx = 0;
1503+
start_freq = chandef->center_freq1 - 40;
1504+
break;
1505+
case NL80211_CHAN_WIDTH_160:
1506+
idx = 1;
1507+
start_freq = chandef->center_freq1 - 80;
1508+
break;
1509+
case NL80211_CHAN_WIDTH_320:
1510+
idx = 2;
1511+
start_freq = chandef->center_freq1 - 160;
1512+
break;
1513+
default:
1514+
*bitmap = 0;
1515+
break;
1516+
}
1517+
1518+
if (!*bitmap)
1519+
return true;
1520+
1521+
/* check if primary channel is punctured */
1522+
if (*bitmap & (u16)BIT((chandef->chan->center_freq - start_freq) / 20))
1523+
return false;
1524+
1525+
for (i = 0; i < per_bw_puncturing[idx].len; i++)
1526+
if (per_bw_puncturing[idx].valid_values[i] == *bitmap)
1527+
return true;
1528+
1529+
return false;
1530+
}
1531+
EXPORT_SYMBOL(cfg80211_valid_disable_subchannel_bitmap);

0 commit comments

Comments
 (0)