Skip to content

Commit 62e9c64

Browse files
AyalaBkrjmberg-intel
authored andcommitted
wifi: mac80211: add support for parsing TID to Link mapping element
Add the relevant definitions for TID to Link mapping element according to the P802.11be_D4.0. Signed-off-by: Ayala Beker <ayala.beker@intel.com> Signed-off-by: Gregory Greenman <gregory.greenman@intel.com> Link: https://lore.kernel.org/r/20230920211508.9ea9b0b4412a.I2281ab2c70e8b43a39032dc115db6a80f1f0b3f4@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent f605d10 commit 62e9c64

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

include/linux/ieee80211.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,30 @@ struct ieee80211_twt_setup {
12461246
u8 params[];
12471247
} __packed;
12481248

1249+
#define IEEE80211_TTLM_MAX_CNT 2
1250+
#define IEEE80211_TTLM_CONTROL_DIRECTION 0x03
1251+
#define IEEE80211_TTLM_CONTROL_DEF_LINK_MAP 0x04
1252+
#define IEEE80211_TTLM_CONTROL_SWITCH_TIME_PRESENT 0x08
1253+
#define IEEE80211_TTLM_CONTROL_EXPECTED_DUR_PRESENT 0x10
1254+
#define IEEE80211_TTLM_CONTROL_LINK_MAP_SIZE 0x20
1255+
1256+
#define IEEE80211_TTLM_DIRECTION_DOWN 0
1257+
#define IEEE80211_TTLM_DIRECTION_UP 1
1258+
#define IEEE80211_TTLM_DIRECTION_BOTH 2
1259+
1260+
/**
1261+
* struct ieee80211_ttlm_elem - TID-To-Link Mapping element
1262+
*
1263+
* Defined in section 9.4.2.314 in P802.11be_D4
1264+
*
1265+
* @control: the first part of control field
1266+
* @optional: the second part of control field
1267+
*/
1268+
struct ieee80211_ttlm_elem {
1269+
u8 control;
1270+
u8 optional[];
1271+
} __packed;
1272+
12491273
struct ieee80211_mgmt {
12501274
__le16 frame_control;
12511275
__le16 duration;
@@ -3618,6 +3642,7 @@ enum ieee80211_eid_ext {
36183642
WLAN_EID_EXT_EHT_OPERATION = 106,
36193643
WLAN_EID_EXT_EHT_MULTI_LINK = 107,
36203644
WLAN_EID_EXT_EHT_CAPABILITY = 108,
3645+
WLAN_EID_EXT_TID_TO_LINK_MAPPING = 109,
36213646
WLAN_EID_EXT_BANDWIDTH_INDICATION = 135,
36223647
};
36233648

@@ -5155,6 +5180,39 @@ static inline bool ieee80211_mle_reconf_sta_prof_size_ok(const u8 *data,
51555180
fixed + prof->sta_info_len - 1 <= len;
51565181
}
51575182

5183+
static inline bool ieee80211_tid_to_link_map_size_ok(const u8 *data, size_t len)
5184+
{
5185+
const struct ieee80211_ttlm_elem *t2l = (const void *)data;
5186+
u8 control, fixed = sizeof(*t2l), elem_len = 0;
5187+
5188+
if (len < fixed)
5189+
return false;
5190+
5191+
control = t2l->control;
5192+
5193+
if (control & IEEE80211_TTLM_CONTROL_SWITCH_TIME_PRESENT)
5194+
elem_len += 2;
5195+
if (control & IEEE80211_TTLM_CONTROL_EXPECTED_DUR_PRESENT)
5196+
elem_len += 3;
5197+
5198+
if (!(control & IEEE80211_TTLM_CONTROL_DEF_LINK_MAP)) {
5199+
u8 bm_size;
5200+
5201+
elem_len += 1;
5202+
if (len < fixed + elem_len)
5203+
return false;
5204+
5205+
if (control & IEEE80211_TTLM_CONTROL_LINK_MAP_SIZE)
5206+
bm_size = 1;
5207+
else
5208+
bm_size = 2;
5209+
5210+
elem_len += hweight8(t2l->optional[0]) * bm_size;
5211+
}
5212+
5213+
return len >= fixed + elem_len;
5214+
}
5215+
51585216
#define for_each_mle_subelement(_elem, _data, _len) \
51595217
if (ieee80211_mle_size_ok(_data, _len)) \
51605218
for_each_element(_elem, \

net/mac80211/ieee80211_i.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ struct ieee802_11_elems {
16781678
const struct ieee80211_multi_link_elem *ml_basic;
16791679
const struct ieee80211_multi_link_elem *ml_reconf;
16801680
const struct ieee80211_bandwidth_indication *bandwidth_indication;
1681+
const struct ieee80211_ttlm_elem *ttlm[IEEE80211_TTLM_MAX_CNT];
16811682

16821683
/* length of them, respectively */
16831684
u8 ext_capab_len;
@@ -1711,6 +1712,8 @@ struct ieee802_11_elems {
17111712
/* The reconfiguration Multi-Link element in the original IEs */
17121713
const struct element *ml_reconf_elem;
17131714

1715+
u8 ttlm_num;
1716+
17141717
/*
17151718
* store the per station profile pointer and length in case that the
17161719
* parsing also handled Multi-Link element parsing for a specific link

net/mac80211/util.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,14 @@ ieee80211_parse_extension_element(u32 *crc,
995995
elems->bandwidth_indication = data;
996996
calc_crc = true;
997997
break;
998+
case WLAN_EID_EXT_TID_TO_LINK_MAPPING:
999+
calc_crc = true;
1000+
if (ieee80211_tid_to_link_map_size_ok(data, len) &&
1001+
elems->ttlm_num < ARRAY_SIZE(elems->ttlm)) {
1002+
elems->ttlm[elems->ttlm_num] = (void *)data;
1003+
elems->ttlm_num++;
1004+
}
1005+
break;
9981006
}
9991007

10001008
if (crc && calc_crc)

0 commit comments

Comments
 (0)