Commit 7e899c1d authored by Johannes Berg's avatar Johannes Berg

wifi: cfg80211: clean up cfg80211_inform_bss_frame_data()

Make cfg80211_inform_bss_frame_data() call the existing
cfg80211_inform_bss_data() after parsing the frame in the
appropriate way, so we have less code duplication. This
required introducing a new CFG80211_BSS_FTYPE_S1G_BEACON,
but that can be used by other drivers as well.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240216135047.874aed1eff5f.Ib7d88d126eec50c64763251a78cb432bb5df14df@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 317bad4c
...@@ -7175,11 +7175,13 @@ size_t cfg80211_merge_profile(const u8 *ie, size_t ielen, ...@@ -7175,11 +7175,13 @@ size_t cfg80211_merge_profile(const u8 *ie, size_t ielen,
* from a beacon or probe response * from a beacon or probe response
* @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon * @CFG80211_BSS_FTYPE_BEACON: data comes from a beacon
* @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response * @CFG80211_BSS_FTYPE_PRESP: data comes from a probe response
* @CFG80211_BSS_FTYPE_S1G_BEACON: data comes from an S1G beacon
*/ */
enum cfg80211_bss_frame_type { enum cfg80211_bss_frame_type {
CFG80211_BSS_FTYPE_UNKNOWN, CFG80211_BSS_FTYPE_UNKNOWN,
CFG80211_BSS_FTYPE_BEACON, CFG80211_BSS_FTYPE_BEACON,
CFG80211_BSS_FTYPE_PRESP, CFG80211_BSS_FTYPE_PRESP,
CFG80211_BSS_FTYPE_S1G_BEACON,
}; };
/** /**
......
...@@ -2213,6 +2213,7 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy, ...@@ -2213,6 +2213,7 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy,
switch (data->ftype) { switch (data->ftype) {
case CFG80211_BSS_FTYPE_BEACON: case CFG80211_BSS_FTYPE_BEACON:
case CFG80211_BSS_FTYPE_S1G_BEACON:
ies->from_beacon = true; ies->from_beacon = true;
fallthrough; fallthrough;
case CFG80211_BSS_FTYPE_UNKNOWN: case CFG80211_BSS_FTYPE_UNKNOWN:
...@@ -3057,6 +3058,10 @@ cfg80211_inform_bss_data(struct wiphy *wiphy, ...@@ -3057,6 +3058,10 @@ cfg80211_inform_bss_data(struct wiphy *wiphy,
if (!res) if (!res)
return NULL; return NULL;
/* don't do any further MBSSID/ML handling for S1G */
if (ftype == CFG80211_BSS_FTYPE_S1G_BEACON)
return res;
cfg80211_parse_mbssid_data(wiphy, &inform_data, res, gfp); cfg80211_parse_mbssid_data(wiphy, &inform_data, res, gfp);
cfg80211_parse_ml_sta_data(wiphy, &inform_data, res, gfp); cfg80211_parse_ml_sta_data(wiphy, &inform_data, res, gfp);
...@@ -3071,17 +3076,16 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy, ...@@ -3071,17 +3076,16 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
struct ieee80211_mgmt *mgmt, size_t len, struct ieee80211_mgmt *mgmt, size_t len,
gfp_t gfp) gfp_t gfp)
{ {
struct cfg80211_inform_single_bss_data inform_data = {
.drv_data = data,
.use_for = data->restrict_use ?
data->use_for :
NL80211_BSS_USE_FOR_ALL,
.cannot_use_reasons = data->cannot_use_reasons,
};
size_t min_hdr_len = offsetof(struct ieee80211_mgmt, size_t min_hdr_len = offsetof(struct ieee80211_mgmt,
u.probe_resp.variable); u.probe_resp.variable);
struct ieee80211_ext *ext = NULL; struct ieee80211_ext *ext = NULL;
struct cfg80211_bss *res; enum cfg80211_bss_frame_type ftype;
u16 beacon_interval;
const u8 *bssid;
u16 capability;
const u8 *ie;
size_t ielen;
u64 tsf;
if (WARN_ON(!mgmt)) if (WARN_ON(!mgmt))
return NULL; return NULL;
...@@ -3105,56 +3109,45 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy, ...@@ -3105,56 +3109,45 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy,
if (WARN_ON(len < min_hdr_len)) if (WARN_ON(len < min_hdr_len))
return NULL; return NULL;
inform_data.ielen = len - min_hdr_len; ielen = len - min_hdr_len;
inform_data.ie = mgmt->u.probe_resp.variable; ie = mgmt->u.probe_resp.variable;
if (ext) { if (ext) {
const struct ieee80211_s1g_bcn_compat_ie *compat; const struct ieee80211_s1g_bcn_compat_ie *compat;
const struct element *elem; const struct element *elem;
if (ieee80211_is_s1g_short_beacon(mgmt->frame_control)) if (ieee80211_is_s1g_short_beacon(mgmt->frame_control))
inform_data.ie = ext->u.s1g_short_beacon.variable; ie = ext->u.s1g_short_beacon.variable;
else else
inform_data.ie = ext->u.s1g_beacon.variable; ie = ext->u.s1g_beacon.variable;
elem = cfg80211_find_elem(WLAN_EID_S1G_BCN_COMPAT, elem = cfg80211_find_elem(WLAN_EID_S1G_BCN_COMPAT, ie, ielen);
inform_data.ie, inform_data.ielen);
if (!elem) if (!elem)
return NULL; return NULL;
if (elem->datalen < sizeof(*compat)) if (elem->datalen < sizeof(*compat))
return NULL; return NULL;
compat = (void *)elem->data; compat = (void *)elem->data;
memcpy(inform_data.bssid, ext->u.s1g_beacon.sa, ETH_ALEN); bssid = ext->u.s1g_beacon.sa;
inform_data.capability = le16_to_cpu(compat->compat_info); capability = le16_to_cpu(compat->compat_info);
inform_data.beacon_interval = le16_to_cpu(compat->beacon_int); beacon_interval = le16_to_cpu(compat->beacon_int);
} else { } else {
memcpy(inform_data.bssid, mgmt->bssid, ETH_ALEN); bssid = mgmt->bssid;
inform_data.beacon_interval = beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int);
le16_to_cpu(mgmt->u.probe_resp.beacon_int); capability = le16_to_cpu(mgmt->u.probe_resp.capab_info);
inform_data.capability =
le16_to_cpu(mgmt->u.probe_resp.capab_info);
} }
inform_data.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp);
if (ieee80211_is_probe_resp(mgmt->frame_control)) if (ieee80211_is_probe_resp(mgmt->frame_control))
inform_data.ftype = CFG80211_BSS_FTYPE_PRESP; ftype = CFG80211_BSS_FTYPE_PRESP;
else if (ext)
ftype = CFG80211_BSS_FTYPE_S1G_BEACON;
else else
inform_data.ftype = CFG80211_BSS_FTYPE_BEACON; ftype = CFG80211_BSS_FTYPE_BEACON;
res = cfg80211_inform_single_bss_data(wiphy, &inform_data, gfp);
if (!res)
return NULL;
/* don't do any further MBSSID/ML handling for S1G */ return cfg80211_inform_bss_data(wiphy, data, ftype,
if (ext) bssid, tsf, capability,
return res; beacon_interval, ie, ielen,
gfp);
/* process each non-transmitting bss */
cfg80211_parse_mbssid_data(wiphy, &inform_data, res, gfp);
cfg80211_parse_ml_sta_data(wiphy, &inform_data, res, gfp);
return res;
} }
EXPORT_SYMBOL(cfg80211_inform_bss_frame_data); EXPORT_SYMBOL(cfg80211_inform_bss_frame_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment