blob: 349b19e284b8f71ca96b38af0ebe05b128605ed4 [file] [log] [blame]
developera15518e2022-07-25 19:03:42 +08001From b01a06578df836bc9df2c68134cfebf42d8ffde0 Mon Sep 17 00:00:00 2001
2From: TomLiu <tomml.liu@mediatek.com>
3Date: Thu, 14 Jul 2022 13:43:06 -0700
4Subject: [PATCH-920]Add hemu hostapd vendor command
5
6---
7 hostapd/config_file.c | 9 +++++++++
8 src/ap/ap_config.h | 1 +
9 src/ap/ap_drv_ops.c | 7 +++++++
10 src/ap/beacon.c | 2 ++
11 src/common/mtk_vendor.h | 13 +++++++++++++
12 src/drivers/driver.h | 12 ++++++++++++
13 src/drivers/driver_nl80211.c | 28 ++++++++++++++++++++++++++++
14 7 files changed, 72 insertions(+)
15
16diff --git a/hostapd/config_file.c b/hostapd/config_file.c
17index 19a2fd5..85d58cd 100644
18--- a/hostapd/config_file.c
19+++ b/hostapd/config_file.c
20@@ -3655,6 +3655,15 @@ static int hostapd_config_fill(struct hostapd_config *conf,
21 return 1;
22 }
23 bss->unsol_bcast_probe_resp_interval = val;
24+ } else if (os_strcmp(buf, "hemu_onoff") == 0) {
25+ int val = atoi(pos);
26+ if (val < 0 || val > 15) {
27+ wpa_printf(MSG_ERROR,
28+ "Line %d: invalid hemu_onoff value",
29+ line);
30+ return 1;
31+ }
32+ conf->hemu_onoff = val;
33 #endif /* CONFIG_IEEE80211AX */
34 } else if (os_strcmp(buf, "max_listen_interval") == 0) {
35 bss->max_listen_interval = atoi(pos);
36diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
37index 9bbe7eb..737cc2f 100644
38--- a/src/ap/ap_config.h
39+++ b/src/ap/ap_config.h
40@@ -1111,6 +1111,7 @@ struct hostapd_config {
41 u8 he_6ghz_rx_ant_pat;
42 u8 he_6ghz_tx_ant_pat;
43 u8 he_6ghz_reg_pwr_type;
44+ u8 hemu_onoff;
45 #endif /* CONFIG_IEEE80211AX */
46
47 /* VHT enable/disable config from CHAN_SWITCH */
48diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
49index b8b98e4..517d2a5 100644
50--- a/src/ap/ap_drv_ops.c
51+++ b/src/ap/ap_drv_ops.c
52@@ -1021,3 +1021,10 @@ int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd)
53 hapd->iconf->edcca_enable,
54 hapd->iconf->edcca_compensation);
55 }
56+
57+int hostapd_drv_hemu_ctrl(struct hostapd_data *hapd)
58+{
59+ if (!hapd->driver || !hapd->driver->hemu_ctrl)
60+ return 0;
61+ return hapd->driver->hemu_ctrl(hapd->drv_priv, hapd->iconf->hemu_onoff);
62+}
63diff --git a/src/ap/beacon.c b/src/ap/beacon.c
64index 575c92f..7170711 100644
65--- a/src/ap/beacon.c
66+++ b/src/ap/beacon.c
67@@ -1976,6 +1976,8 @@ static int __ieee802_11_set_beacon(struct hostapd_data *hapd)
68 params.freq = &freq;
69
70 res = hostapd_drv_set_ap(hapd, &params);
71+ if (hostapd_drv_hemu_ctrl(hapd) < 0)
72+ goto fail;
73 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
74 if (res)
75 wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
76diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h
77index 528387f..6a0e60a 100644
78--- a/src/common/mtk_vendor.h
79+++ b/src/common/mtk_vendor.h
80@@ -10,6 +10,8 @@ enum mtk_nl80211_vendor_subcmds {
81 MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2,
82 MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
83 MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
84+ MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5,
85+ MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL= 0xc6,
86 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
87 };
88
89@@ -167,6 +169,17 @@ enum mtk_vendor_attr_rfeature_ctrl {
90 NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1
91 };
92
93+enum mtk_vendor_attr_hemu_ctrl {
94+ MTK_VENDOR_ATTR_HEMU_CTRL_UNSPEC,
95+
96+ MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF,
97+
98+ /* keep last */
99+ NUM_MTK_VENDOR_ATTRS_HEMU_CTRL,
100+ MTK_VENDOR_ATTR_HEMU_CTRL_MAX =
101+ NUM_MTK_VENDOR_ATTRS_HEMU_CTRL - 1
102+};
103+
104 #define CSI_MAX_COUNT 256
105 #define ETH_ALEN 6
106
107diff --git a/src/drivers/driver.h b/src/drivers/driver.h
108index fc96fef..298dbf3 100644
109--- a/src/drivers/driver.h
110+++ b/src/drivers/driver.h
111@@ -1622,6 +1622,11 @@ struct wpa_driver_ap_params {
112 * Unsolicited broadcast Probe Response template length
113 */
114 size_t unsol_bcast_probe_resp_tmpl_len;
115+
116+ /**
117+ * hemu onoff=<val> (bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0))
118+ */
119+ u8 hemu_onoff;
120 };
121
122 struct wpa_driver_mesh_bss_params {
123@@ -4675,6 +4680,13 @@ struct wpa_driver_ops {
124 #endif /* CONFIG_TESTING_OPTIONS */
125 int (*configure_edcca_threshold)(void *priv, const u8 edcca_enable,
126 const s8 edcca_compensation);
127+
128+ /**
129+ * hemu_ctrl - ctrl on off for UL/DL MURU
130+ * @priv: Private driver interface data
131+ *
132+ */
133+ int (*hemu_ctrl)(void *priv, u8 hemu_onoff);
134 };
135
136 /**
137diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
138index b1e7b16..18ccbc7 100644
139--- a/src/drivers/driver_nl80211.c
140+++ b/src/drivers/driver_nl80211.c
141@@ -12287,6 +12287,33 @@ fail:
142 }
143
144
145+#ifdef CONFIG_IEEE80211AX
146+static int nl80211_hemu_muruonoff(void *priv, u8 hemu_onoff)
147+{
148+ struct i802_bss *bss = priv;
149+ struct wpa_driver_nl80211_data *drv = bss->drv;
150+ struct nl_msg *msg;
151+ struct nlattr *data;
152+ int ret;
153+
154+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
155+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) ||
156+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL) ||
157+ !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) ||
158+ nla_put_u8(msg, MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF, hemu_onoff)) {
159+ nlmsg_free(msg);
160+ return -ENOBUFS;
161+ }
162+ nla_nest_end(msg, data);
163+ ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL);
164+ if(ret){
165+ wpa_printf(MSG_ERROR, "Failed to set hemu_onoff. ret=%d (%s)", ret, strerror(-ret));
166+ }
167+ return ret;
168+}
169+#endif /* CONFIG_IEEE80211AX */
170+
171+
172 #ifdef CONFIG_DPP
173 static int nl80211_dpp_listen(void *priv, bool enable)
174 {
175@@ -12531,6 +12558,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
176 .update_connect_params = nl80211_update_connection_params,
177 .send_external_auth_status = nl80211_send_external_auth_status,
178 .set_4addr_mode = nl80211_set_4addr_mode,
179+ .hemu_ctrl = nl80211_hemu_muruonoff,
180 #ifdef CONFIG_DPP
181 .dpp_listen = nl80211_dpp_listen,
182 #endif /* CONFIG_DPP */
183--
1842.32.0
185