wlan-ap-Telecominfraproject/feeds/qca/hostapd/patches/r03-029-hostapd-Enable-WDS-AP-MLO-Support.patch
John Crispin 008ca9618d
Some checks failed
Build OpenWrt/uCentral images / build (cig_wf186h) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf186w) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf188n) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf189) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cig_wf196) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cybertan_eww631-a1) (push) Has been cancelled
Build OpenWrt/uCentral images / build (cybertan_eww631-b1) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap101) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap102) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap104) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap105) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap111) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_eap112) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101-6e) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101e) (push) Has been cancelled
Build OpenWrt/uCentral images / build (edgecore_oap101e-6e) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x_2) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x_3) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4x_w) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4xe) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4xi) (push) Has been cancelled
Build OpenWrt/uCentral images / build (hfcl_ion4xi_w) (push) Has been cancelled
Build OpenWrt/uCentral images / build (indio_um-305ax) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sercomm_ap72tip) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sonicfi_rap630c-311g) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sonicfi_rap630w-211g) (push) Has been cancelled
Build OpenWrt/uCentral images / build (sonicfi_rap630w-311g) (push) Has been cancelled
Build OpenWrt/uCentral images / build (udaya_a6-id2) (push) Has been cancelled
Build OpenWrt/uCentral images / build (udaya_a6-od2) (push) Has been cancelled
Build OpenWrt/uCentral images / build (wallys_dr5018) (push) Has been cancelled
Build OpenWrt/uCentral images / build (wallys_dr6018) (push) Has been cancelled
Build OpenWrt/uCentral images / build (wallys_dr6018-v4) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_ax820) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_ax840) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_fap640) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_fap650) (push) Has been cancelled
Build OpenWrt/uCentral images / build (yuncore_fap655) (push) Has been cancelled
Build OpenWrt/uCentral images / trigger-testing (push) Has been cancelled
Build OpenWrt/uCentral images / create-x64_vm-ami (push) Has been cancelled
ipq95xx: import ath12.4-cs kernel and drivers
Signed-off-by: John Crispin <john@phrozen.org>
2024-10-20 09:25:13 +02:00

269 lines
7.9 KiB
Diff

From 606a10f3b049841973d43ffaeb8cbf0709f7dd4e Mon Sep 17 00:00:00 2001
From: Ramasamy Kaliappan <quic_rkaliapp@quicinc.com>
Date: Wed, 15 Nov 2023 22:53:36 +0530
Subject: [PATCH] hostapd: Enable WDS AP MLO Support
Turn on wds ap mld for the unknow station 4addr which creates the vlan
interface with the sta link information.
Each associated 4addr client's wds mlo vlan interface name has
to be given a unique name, and logic should be included to establish
a unique id for each station in hapd mld,
which is then used to form a unique vlan interface name.
Signed-off-by: Ramasamy Kaliappan <quic_rkaliapp@quicinc.com>
Signed-off-by: Manish Dharanenthiran <quic_mdharane@quicinc.com>
---
src/ap/hostapd.h | 1 +
src/ap/ieee802_11.c | 85 ++++++++++++++++++++++++++++--
src/ap/ieee802_11.h | 1 +
src/ap/sta_info.c | 16 +++++-
src/ap/sta_info.h | 1 +
src/drivers/driver_nl80211.c | 11 +++-
src/drivers/driver_nl80211_event.c | 16 +++++-
7 files changed, 122 insertions(+), 9 deletions(-)
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -219,6 +219,7 @@ struct hostapd_data {
*/
#define AID_WORDS ((2008 + 31) / 32)
u32 sta_aid[AID_WORDS];
+ u32 wds_sta_uid[AID_WORDS];
const struct wpa_driver_ops *driver;
void *drv_priv;
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -3338,6 +3338,54 @@ static u32 hostapd_get_aid_word(struct h
}
+int hostapd_get_wds_mld_sta_uid(struct hostapd_data *hapd, struct sta_info *sta)
+{
+ struct hostapd_data *link_bss;
+ int i, j = 32, aid;
+
+ /* get a unique ID */
+ if (sta->wds_mld_uid > 0) {
+ wpa_printf(MSG_DEBUG, " old UID %d", sta->wds_mld_uid);
+ return 0;
+ }
+
+ if (!hapd->conf->mld_ap)
+ return -1;
+
+ link_bss = hostapd_mld_get_first_bss(hapd);
+ if (!link_bss)
+ link_bss = hapd;
+
+ for (i = 0; i < AID_WORDS; i++) {
+ if (link_bss->wds_sta_uid[i] == (u32) -1)
+ continue;
+
+ for (j = 0; j < 32; j++) {
+ if (!(link_bss->wds_sta_uid[i] & BIT(j))) {
+ break;
+ }
+ }
+
+ if (j < 32)
+ break;
+ }
+ if (j == 32)
+ return -1;
+
+ aid = i * 32 + j + 1;
+
+ if (aid > 2007)
+ return -1;
+
+ sta->wds_mld_uid = aid;
+ link_bss->wds_sta_uid[i] |= BIT(j);
+
+ wpa_printf(MSG_DEBUG, " new UID %d", sta->wds_mld_uid);
+
+ return 0;
+}
+
+
int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
{
int i, j = 32, aid;
@@ -6477,6 +6525,12 @@ static void handle_assoc_cb(struct hosta
MAC2STR(sta->addr));
sta->pending_wds_enable = 0;
sta->flags |= WLAN_STA_WDS;
+ if (hapd->conf->mld_ap && hostapd_get_wds_mld_sta_uid(hapd, sta) < 0) {
+ wpa_printf(MSG_DEBUG, "No room for uid"
+ "to enable 4-address WDS mode for STA "
+ MACSTR, MAC2STR(sta->addr));
+ return;
+ }
}
/* WPS not supported on backhaul BSS. Disable 4addr mode on fronthaul */
@@ -6486,12 +6540,18 @@ static void handle_assoc_cb(struct hosta
!(sta->flags & WLAN_STA_WPS))) {
int ret;
char ifname_wds[IFNAMSIZ + 1];
+ int aid;
+
+ if (hapd->conf->mld_ap && (sta->flags & WLAN_STA_WDS))
+ aid = sta->wds_mld_uid;
+ else
+ aid = sta->aid;
wpa_printf(MSG_DEBUG, "Reenable 4-address WDS mode for STA "
MACSTR " (aid %u)",
- MAC2STR(sta->addr), sta->aid);
+ MAC2STR(sta->addr), aid);
ret = hostapd_set_wds_sta(hapd, ifname_wds, sta->addr,
- sta->aid, 1);
+ aid, 1);
if (!ret)
hostapd_set_wds_encryption(hapd, sta, ifname_wds);
}
@@ -6802,6 +6862,7 @@ void ieee802_11_rx_from_unknown(struct h
int wds)
{
struct sta_info *sta;
+ int aid = 0;
sta = ap_get_sta(hapd, src);
if (sta &&
@@ -6810,6 +6871,19 @@ void ieee802_11_rx_from_unknown(struct h
if (!hapd->conf->wds_sta)
return;
+ if (hapd->conf->mld_ap && wds) {
+ if (hostapd_get_wds_mld_sta_uid(hapd, sta) < 0) {
+ wpa_printf(MSG_DEBUG, "No room for uid"
+ "to enable 4-address WDS mode for STA "
+ MACSTR, MAC2STR(sta->addr));
+ return;
+ }
+ aid = sta->wds_mld_uid;
+ }
+ else {
+ aid = sta->aid;
+ }
+
if ((sta->flags & (WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK)) ==
WLAN_STA_ASSOC_REQ_OK) {
wpa_printf(MSG_DEBUG,
@@ -6826,10 +6900,15 @@ void ieee802_11_rx_from_unknown(struct h
wpa_printf(MSG_DEBUG, "Enable 4-address WDS mode for "
"STA " MACSTR " (aid %u)",
- MAC2STR(sta->addr), sta->aid);
+ MAC2STR(sta->addr), aid);
+
+ hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
+ HOSTAPD_LEVEL_INFO, "Enable 4-address WDS"
+ "mode for STA with id %u flags 0x%x", aid, sta->flags);
+
sta->flags |= WLAN_STA_WDS;
ret = hostapd_set_wds_sta(hapd, ifname_wds,
- sta->addr, sta->aid, 1);
+ sta->addr, aid, 1);
if (!ret)
hostapd_set_wds_encryption(hapd, sta,
ifname_wds);
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -113,6 +113,7 @@ void hostapd_get_eht_240mhz_capab(struct
size_t len);
int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta);
+int hostapd_get_wds_mld_sta_uid(struct hostapd_data *hapd, struct sta_info *sta);
u16 copy_sta_ht_capab(struct hostapd_data *hapd, struct sta_info *sta,
const u8 *ht_capab);
u16 copy_sta_vendor_vht(struct hostapd_data *hapd, struct sta_info *sta,
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -201,8 +201,16 @@ void ap_free_sta(struct hostapd_data *ha
if ((sta->flags & WLAN_STA_WDS) ||
(sta->flags & WLAN_STA_MULTI_AP &&
!(hapd->conf->multi_ap & FRONTHAUL_BSS) &&
- !(sta->flags & WLAN_STA_WPS)))
- hostapd_set_wds_sta(hapd, NULL, sta->addr, sta->aid, 0);
+ !(sta->flags & WLAN_STA_WPS))) {
+ int aid;
+
+ if (hapd->conf->mld_ap && (sta->flags & WLAN_STA_WDS))
+ aid = sta->wds_mld_uid;
+ else
+ aid = sta->aid;
+
+ hostapd_set_wds_sta(hapd, NULL, sta->addr, aid, 0);
+ }
if (sta->ipaddr)
hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr);
@@ -221,6 +229,10 @@ void ap_free_sta(struct hostapd_data *ha
hapd->sta_aid[(sta->aid - 1) / 32] &=
~BIT((sta->aid - 1) % 32);
+ if (sta->wds_mld_uid > 0)
+ hapd->wds_sta_uid[(sta->wds_mld_uid - 1) / 32] &=
+ ~BIT((sta->wds_mld_uid - 1) % 32);
+
hapd->num_sta--;
if (sta->nonerp_set) {
sta->nonerp_set = 0;
--- a/src/ap/sta_info.h
+++ b/src/ap/sta_info.h
@@ -107,6 +107,7 @@ struct sta_info {
be32 ipaddr;
struct dl_list ip6addr; /* list head for struct ip6addr */
u16 aid; /* STA's unique AID (1 .. 2007) or 0 if not yet assigned */
+ u16 wds_mld_uid; /* STA's vlan ifname unique id (1 .. 2007) or 0 if not */
u16 disconnect_reason_code; /* RADIUS server override */
u32 flags; /* Bitfield of WLAN_STA_* */
u16 capability;
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -8476,6 +8476,7 @@ static int i802_set_wds_sta(void *priv,
wpa_printf(MSG_DEBUG, "nl80211: Set WDS STA addr=" MACSTR
" aid=%d val=%d name=%s", MAC2STR(addr), aid, val, name);
+
if (val) {
if (!if_nametoindex(name)) {
if (nl80211_create_iface(drv, name,
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -2675,7 +2675,10 @@ static void nl80211_spurious_frame(struc
int wds)
{
struct wpa_driver_nl80211_data *drv = bss->drv;
+ struct i802_link *mld_link;
union wpa_event_data event;
+ void *ctx = bss->ctx;
+ int link_id = -1;
if (!tb[NL80211_ATTR_MAC])
return;
@@ -2685,7 +2688,19 @@ static void nl80211_spurious_frame(struc
event.rx_from_unknown.addr = nla_data(tb[NL80211_ATTR_MAC]);
event.rx_from_unknown.wds = wds;
- wpa_supplicant_event(drv->ctx, EVENT_RX_FROM_UNKNOWN, &event);
+ if (wds && tb[NL80211_ATTR_MLO_LINK_ID]) {
+ link_id = nla_get_u8(tb[NL80211_ATTR_MLO_LINK_ID]);
+ mld_link = nl80211_get_link_or_null(bss, link_id);
+ if (!mld_link) {
+ wpa_printf(MSG_DEBUG,
+ "ignoring unknown RX event from link_id:%d", link_id);
+ return;
+ }
+ ctx = mld_link->ctx;
+ event.rx_from_unknown.bssid = mld_link->addr;
+ }
+
+ wpa_supplicant_event(ctx, EVENT_RX_FROM_UNKNOWN, &event);
}