blob: 1e18c72d08922677b1868861f99b1394a079ec41 [file] [log] [blame]
developerc8239512022-07-21 17:43:53 -07001From 390f9431f5a6f8001f6822a3aea4c5e08743806d Mon Sep 17 00:00:00 2001
developer4d30ebf2022-07-07 10:33:21 -07002From: TomLiu <tomml.liu@mediatek.com>
3Date: Thu, 14 Jul 2022 13:43:06 -0700
4Subject: [PATCH-920]Add hemu hostapd vendor command
5
6---
developerc8239512022-07-21 17:43:53 -07007 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 | 36 ++++++++++++++++++++++++++++++-
14 src/drivers/driver_nl80211.h | 1 +
15 src/drivers/driver_nl80211_capa.c | 3 +++
16 9 files changed, 83 insertions(+), 1 deletion(-)
developer4d30ebf2022-07-07 10:33:21 -070017
18diff --git a/hostapd/config_file.c b/hostapd/config_file.c
19index 19a2fd5..85d58cd 100644
20--- a/hostapd/config_file.c
21+++ b/hostapd/config_file.c
22@@ -3655,6 +3655,15 @@ static int hostapd_config_fill(struct hostapd_config *conf,
23 return 1;
24 }
25 bss->unsol_bcast_probe_resp_interval = val;
26+ } else if (os_strcmp(buf, "hemu_onoff") == 0) {
27+ int val = atoi(pos);
28+ if (val < 0 || val > 15) {
29+ wpa_printf(MSG_ERROR,
30+ "Line %d: invalid hemu_onoff value",
31+ line);
32+ return 1;
33+ }
34+ conf->hemu_onoff = val;
35 #endif /* CONFIG_IEEE80211AX */
36 } else if (os_strcmp(buf, "max_listen_interval") == 0) {
37 bss->max_listen_interval = atoi(pos);
38diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
39index 9bbe7eb..737cc2f 100644
40--- a/src/ap/ap_config.h
41+++ b/src/ap/ap_config.h
42@@ -1111,6 +1111,7 @@ struct hostapd_config {
43 u8 he_6ghz_rx_ant_pat;
44 u8 he_6ghz_tx_ant_pat;
45 u8 he_6ghz_reg_pwr_type;
46+ u8 hemu_onoff;
47 #endif /* CONFIG_IEEE80211AX */
developerc8239512022-07-21 17:43:53 -070048
developer4d30ebf2022-07-07 10:33:21 -070049 /* VHT enable/disable config from CHAN_SWITCH */
50diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
51index b8b98e4..517d2a5 100644
52--- a/src/ap/ap_drv_ops.c
53+++ b/src/ap/ap_drv_ops.c
54@@ -1021,3 +1021,10 @@ int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd)
55 hapd->iconf->edcca_enable,
56 hapd->iconf->edcca_compensation);
57 }
58+
59+int hostapd_drv_hemu_ctrl(struct hostapd_data *hapd)
60+{
61+ if (!hapd->driver || !hapd->driver->hemu_ctrl)
62+ return 0;
63+ return hapd->driver->hemu_ctrl(hapd->drv_priv, hapd->iconf->hemu_onoff);
64+}
65diff --git a/src/ap/beacon.c b/src/ap/beacon.c
66index 575c92f..7170711 100644
67--- a/src/ap/beacon.c
68+++ b/src/ap/beacon.c
69@@ -1976,6 +1976,8 @@ static int __ieee802_11_set_beacon(struct hostapd_data *hapd)
70 params.freq = &freq;
developerc8239512022-07-21 17:43:53 -070071
developer4d30ebf2022-07-07 10:33:21 -070072 res = hostapd_drv_set_ap(hapd, &params);
73+ if (hostapd_drv_hemu_ctrl(hapd) < 0)
74+ goto fail;
75 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
76 if (res)
77 wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
78diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h
79index 528387f..6a0e60a 100644
80--- a/src/common/mtk_vendor.h
81+++ b/src/common/mtk_vendor.h
82@@ -10,6 +10,8 @@ enum mtk_nl80211_vendor_subcmds {
83 MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2,
84 MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3,
85 MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4,
86+ MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5,
87+ MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL= 0xc6,
88 MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7,
89 };
developerc8239512022-07-21 17:43:53 -070090
developer4d30ebf2022-07-07 10:33:21 -070091@@ -167,6 +169,17 @@ enum mtk_vendor_attr_rfeature_ctrl {
92 NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1
93 };
developerc8239512022-07-21 17:43:53 -070094
developer4d30ebf2022-07-07 10:33:21 -070095+enum mtk_vendor_attr_hemu_ctrl {
96+ MTK_VENDOR_ATTR_HEMU_CTRL_UNSPEC,
97+
98+ MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF,
99+
100+ /* keep last */
101+ NUM_MTK_VENDOR_ATTRS_HEMU_CTRL,
102+ MTK_VENDOR_ATTR_HEMU_CTRL_MAX =
103+ NUM_MTK_VENDOR_ATTRS_HEMU_CTRL - 1
104+};
105+
106 #define CSI_MAX_COUNT 256
107 #define ETH_ALEN 6
developerc8239512022-07-21 17:43:53 -0700108
developer4d30ebf2022-07-07 10:33:21 -0700109diff --git a/src/drivers/driver.h b/src/drivers/driver.h
110index fc96fef..298dbf3 100644
111--- a/src/drivers/driver.h
112+++ b/src/drivers/driver.h
113@@ -1622,6 +1622,11 @@ struct wpa_driver_ap_params {
114 * Unsolicited broadcast Probe Response template length
115 */
116 size_t unsol_bcast_probe_resp_tmpl_len;
117+
118+ /**
119+ * hemu onoff=<val> (bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0))
120+ */
121+ u8 hemu_onoff;
122 };
developerc8239512022-07-21 17:43:53 -0700123
developer4d30ebf2022-07-07 10:33:21 -0700124 struct wpa_driver_mesh_bss_params {
125@@ -4675,6 +4680,13 @@ struct wpa_driver_ops {
126 #endif /* CONFIG_TESTING_OPTIONS */
127 int (*configure_edcca_threshold)(void *priv, const u8 edcca_enable,
128 const s8 edcca_compensation);
129+
130+ /**
131+ * hemu_ctrl - ctrl on off for UL/DL MURU
132+ * @priv: Private driver interface data
133+ *
134+ */
135+ int (*hemu_ctrl)(void *priv, u8 hemu_onoff);
136 };
developerc8239512022-07-21 17:43:53 -0700137
developer4d30ebf2022-07-07 10:33:21 -0700138 /**
139diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
developerc8239512022-07-21 17:43:53 -0700140index b1e7b16..089c24a 100644
developer4d30ebf2022-07-07 10:33:21 -0700141--- a/src/drivers/driver_nl80211.c
142+++ b/src/drivers/driver_nl80211.c
developerc8239512022-07-21 17:43:53 -0700143@@ -12287,6 +12287,39 @@ fail:
developer4d30ebf2022-07-07 10:33:21 -0700144 }
developerc8239512022-07-21 17:43:53 -0700145
146
developer4d30ebf2022-07-07 10:33:21 -0700147+#ifdef CONFIG_IEEE80211AX
148+static int nl80211_hemu_muruonoff(void *priv, u8 hemu_onoff)
149+{
150+ struct i802_bss *bss = priv;
151+ struct wpa_driver_nl80211_data *drv = bss->drv;
152+ struct nl_msg *msg;
153+ struct nlattr *data;
154+ int ret;
155+
developerc8239512022-07-21 17:43:53 -0700156+ if (!drv->mtk_hemu_vendor_cmd_avail) {
157+ wpa_printf(MSG_INFO,
158+ "nl80211: Driver does not support setting hemu control");
159+ return 0;
160+ }
161+
developer4d30ebf2022-07-07 10:33:21 -0700162+ if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
163+ nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) ||
164+ nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL) ||
165+ !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) ||
166+ nla_put_u8(msg, MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF, hemu_onoff)) {
167+ nlmsg_free(msg);
168+ return -ENOBUFS;
169+ }
170+ nla_nest_end(msg, data);
171+ ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL);
172+ if(ret){
173+ wpa_printf(MSG_ERROR, "Failed to set hemu_onoff. ret=%d (%s)", ret, strerror(-ret));
174+ }
175+ return ret;
176+}
177+#endif /* CONFIG_IEEE80211AX */
178+
179+
180 #ifdef CONFIG_DPP
181 static int nl80211_dpp_listen(void *priv, bool enable)
182 {
developerc8239512022-07-21 17:43:53 -0700183@@ -12531,6 +12564,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
developer4d30ebf2022-07-07 10:33:21 -0700184 .update_connect_params = nl80211_update_connection_params,
185 .send_external_auth_status = nl80211_send_external_auth_status,
186 .set_4addr_mode = nl80211_set_4addr_mode,
187+ .hemu_ctrl = nl80211_hemu_muruonoff,
188 #ifdef CONFIG_DPP
189 .dpp_listen = nl80211_dpp_listen,
190 #endif /* CONFIG_DPP */
developerc8239512022-07-21 17:43:53 -0700191diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h
192index b677907..62d9696 100644
193--- a/src/drivers/driver_nl80211.h
194+++ b/src/drivers/driver_nl80211.h
195@@ -181,6 +181,7 @@ struct wpa_driver_nl80211_data {
196 unsigned int qca_do_acs:1;
197 unsigned int brcm_do_acs:1;
198 unsigned int mtk_edcca_vendor_cmd_avail:1;
199+ unsigned int mtk_hemu_vendor_cmd_avail:1;
developer4d30ebf2022-07-07 10:33:21 -0700200
developerc8239512022-07-21 17:43:53 -0700201 u64 vendor_scan_cookie;
202 u64 remain_on_chan_cookie;
203diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c
204index 6c743bf..b5cd2c5 100644
205--- a/src/drivers/driver_nl80211_capa.c
206+++ b/src/drivers/driver_nl80211_capa.c
207@@ -1050,6 +1050,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg)
208 case MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL :
209 drv->mtk_edcca_vendor_cmd_avail = 1;
210 break;
211+ case MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL :
212+ drv->mtk_hemu_vendor_cmd_avail = 1;
213+ break;
214 }
215 }
216
217--
2182.32.0