blob: 68d2e5b99474e00ff47bd36cb598ab0030d5991c [file] [log] [blame]
developer95671ae2023-09-25 14:16:05 +08001From 5644beb4dc1a11a236d909d4a8f8ad4aa86c6c34 Mon Sep 17 00:00:00 2001
developer505c9432023-05-12 18:58:17 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Fri, 12 May 2023 05:24:19 +0800
developer95671ae2023-09-25 14:16:05 +08004Subject: [PATCH 24/38] hostapd: mtk: Add muru user number debug command
developer505c9432023-05-12 18:58:17 +08005
6---
7 hostapd/ctrl_iface.c | 13 ++++++++++++-
8 src/ap/ap_drv_ops.c | 4 ++--
9 src/ap/ap_drv_ops.h | 2 +-
developer8bff6472023-07-17 11:11:44 +080010 src/ap/hostapd.c | 3 ++-
developer505c9432023-05-12 18:58:17 +080011 src/common/mtk_vendor.h | 7 +++++++
12 src/drivers/driver.h | 4 ++--
13 src/drivers/driver_nl80211.c | 37 ++++++++++++++++++++++++++++--------
developer8bff6472023-07-17 11:11:44 +080014 7 files changed, 55 insertions(+), 15 deletions(-)
developer505c9432023-05-12 18:58:17 +080015
16diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
developerdfb50982023-09-11 13:34:36 +080017index 1bb64ea..f36c138 100644
developer505c9432023-05-12 18:58:17 +080018--- a/hostapd/ctrl_iface.c
19+++ b/hostapd/ctrl_iface.c
developerdfb50982023-09-11 13:34:36 +080020@@ -3398,6 +3398,8 @@ hostapd_ctrl_iface_set_edcca(struct hostapd_data *hapd, char *cmd,
developer505c9432023-05-12 18:58:17 +080021 char *buf, size_t buflen)
22 {
23 char *pos, *config, *value;
24+ u8 mode;
25+
26 config = cmd;
27 pos = os_strchr(config, ' ');
28 if (pos == NULL)
developerdfb50982023-09-11 13:34:36 +080029@@ -3504,6 +3506,8 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd,
developer505c9432023-05-12 18:58:17 +080030 char *buf, size_t buflen)
31 {
32 char *pos, *config, *value;
33+ u8 mode;
34+
35 config = cmd;
36 pos = os_strchr(config, ' ');
37 if (pos == NULL)
developerdfb50982023-09-11 13:34:36 +080038@@ -3521,13 +3525,20 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd,
developer505c9432023-05-12 18:58:17 +080039 return -1;
40 }
41 hapd->iconf->mu_onoff = (u8) mu;
42+ mode = MU_CTRL_ONOFF;
43+ } else if (os_strcmp(config, "ul_user_cnt") == 0) {
44+ mode = MU_CTRL_UL_USER_CNT;
45+ wpa_printf(MSG_ERROR, "ul_user_cnt:%d\n", (u8)atoi(value));
46+ } else if (os_strcmp(config, "dl_user_cnt") == 0) {
47+ mode = MU_CTRL_DL_USER_CNT;
48+ wpa_printf(MSG_ERROR, "dl_user_cnt:%d\n", (u8)atoi(value));
49 } else {
50 wpa_printf(MSG_ERROR,
51 "Unsupported parameter %s for SET_MU", config);
52 return -1;
53 }
54
55- if(hostapd_drv_mu_ctrl(hapd) == 0) {
56+ if(hostapd_drv_mu_ctrl(hapd, mode, (u8)atoi(value)) == 0) {
57 return os_snprintf(buf, buflen, "OK\n");
58 } else {
59 return -1;
60diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
developerdfb50982023-09-11 13:34:36 +080061index b90dd57..0aec9e9 100644
developer505c9432023-05-12 18:58:17 +080062--- a/src/ap/ap_drv_ops.c
63+++ b/src/ap/ap_drv_ops.c
developer8bff6472023-07-17 11:11:44 +080064@@ -1162,11 +1162,11 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value)
developer505c9432023-05-12 18:58:17 +080065 return hapd->driver->get_edcca(hapd->drv_priv, mode, value);
66 }
67
68-int hostapd_drv_mu_ctrl(struct hostapd_data *hapd)
69+int hostapd_drv_mu_ctrl(struct hostapd_data *hapd, u8 mode, u8 val)
70 {
71 if (!hapd->driver || !hapd->driver->mu_ctrl)
72 return 0;
73- return hapd->driver->mu_ctrl(hapd->drv_priv, hapd->iconf->mu_onoff);
74+ return hapd->driver->mu_ctrl(hapd->drv_priv, mode, val);
75 }
76
77 int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff)
78diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h
developer95671ae2023-09-25 14:16:05 +080079index 8a97e0f..464efba 100644
developer505c9432023-05-12 18:58:17 +080080--- a/src/ap/ap_drv_ops.h
81+++ b/src/ap/ap_drv_ops.h
82@@ -148,7 +148,7 @@ int hostapd_drv_configure_edcca_enable(struct hostapd_data *hapd);
83 int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd,
84 const int *threshold);
85 int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value);
86-int hostapd_drv_mu_ctrl(struct hostapd_data *hapd);
87+int hostapd_drv_mu_ctrl(struct hostapd_data *hapd, u8 mode, u8 val);
88 int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff);
89 int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd);
90 int hostapd_drv_ibf_ctrl(struct hostapd_data *hapd);
91diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
developer95671ae2023-09-25 14:16:05 +080092index a166de4..28482c6 100644
developer505c9432023-05-12 18:58:17 +080093--- a/src/ap/hostapd.c
94+++ b/src/ap/hostapd.c
developer8bff6472023-07-17 11:11:44 +080095@@ -57,6 +57,7 @@
developer505c9432023-05-12 18:58:17 +080096 #include "wpa_auth_kay.h"
developer8bff6472023-07-17 11:11:44 +080097 #include "hw_features.h"
98
developer505c9432023-05-12 18:58:17 +080099+#include "common/mtk_vendor.h"
100
101 static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason);
102 #ifdef CONFIG_WEP
developerdfb50982023-09-11 13:34:36 +0800103@@ -2517,7 +2518,7 @@ dfs_offload:
developer505c9432023-05-12 18:58:17 +0800104 if (hostapd_drv_configure_edcca_threshold(hapd,
105 hapd->iconf->edcca_threshold) < 0)
106 goto fail;
107- if (hostapd_drv_mu_ctrl(hapd) < 0)
108+ if (hostapd_drv_mu_ctrl(hapd, MU_CTRL_ONOFF, hapd->iconf->mu_onoff) < 0)
109 goto fail;
110 if (hostapd_drv_three_wire_ctrl(hapd) < 0)
111 goto fail;
112diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h
developerdfb50982023-09-11 13:34:36 +0800113index dd1ca21..99371bf 100644
developer505c9432023-05-12 18:58:17 +0800114--- a/src/common/mtk_vendor.h
115+++ b/src/common/mtk_vendor.h
developer8bff6472023-07-17 11:11:44 +0800116@@ -199,6 +199,8 @@ enum mtk_vendor_attr_mu_ctrl {
developer505c9432023-05-12 18:58:17 +0800117
118 MTK_VENDOR_ATTR_MU_CTRL_ONOFF,
119 MTK_VENDOR_ATTR_MU_CTRL_DUMP,
120+ MTK_VENDOR_ATTR_MU_CTRL_OFDMA_MODE,
121+ MTK_VENDOR_ATTR_MU_CTRL_OFDMA_VAL,
122
123 /* keep last */
124 NUM_MTK_VENDOR_ATTRS_MU_CTRL,
developer8bff6472023-07-17 11:11:44 +0800125@@ -272,4 +274,9 @@ struct amnt_resp_data {
developer505c9432023-05-12 18:58:17 +0800126 struct amnt_data resp_data[0];
127 };
128
129+enum {
130+ MU_CTRL_ONOFF,
131+ MU_CTRL_DL_USER_CNT,
132+ MU_CTRL_UL_USER_CNT,
133+};
134 #endif /* MTK_VENDOR_H */
135diff --git a/src/drivers/driver.h b/src/drivers/driver.h
developer95671ae2023-09-25 14:16:05 +0800136index 8733bb5..a29b6ff 100644
developer505c9432023-05-12 18:58:17 +0800137--- a/src/drivers/driver.h
138+++ b/src/drivers/driver.h
developer95671ae2023-09-25 14:16:05 +0800139@@ -5118,11 +5118,11 @@ struct wpa_driver_ops {
developer505c9432023-05-12 18:58:17 +0800140 int (*get_edcca)(void *priv, const u8 mode, u8 *value);
141
142 /**
143- * mu_ctrl - ctrl on off for UL/DL MURU
144+ * mu_ctrl - ctrl for UL/DL MURU
145 * @priv: Private driver interface data
146 *
147 */
148- int (*mu_ctrl)(void *priv, u8 mu_onoff);
149+ int (*mu_ctrl)(void *priv, u8 mode, u8 val);
150 int (*mu_dump)(void *priv, u8 *mu_onoff);
151
152 /**
153diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
developer95671ae2023-09-25 14:16:05 +0800154index c55d034..fce3ec9 100644
developer505c9432023-05-12 18:58:17 +0800155--- a/src/drivers/driver_nl80211.c
156+++ b/src/drivers/driver_nl80211.c
developer95671ae2023-09-25 14:16:05 +0800157@@ -13678,13 +13678,13 @@ fail:
developer505c9432023-05-12 18:58:17 +0800158
159
160 #ifdef CONFIG_IEEE80211AX
161-static int nl80211_mu_onoff(void *priv, u8 mu_onoff)
162+static int nl80211_mu_ctrl(void *priv, u8 mode, u8 val)
163 {
164 struct i802_bss *bss = priv;
165 struct wpa_driver_nl80211_data *drv = bss->drv;
166 struct nl_msg *msg;
167 struct nlattr *data;
168- int ret;
169+ int ret = -ENOBUFS;
170
171 if (!drv->mtk_mu_vendor_cmd_avail) {
172 wpa_printf(MSG_INFO,
developer95671ae2023-09-25 14:16:05 +0800173@@ -13695,17 +13695,38 @@ static int nl80211_mu_onoff(void *priv, u8 mu_onoff)
developer505c9432023-05-12 18:58:17 +0800174 if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) ||
175 nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) ||
176 nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_MU_CTRL) ||
177- !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) ||
178- nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, mu_onoff)) {
179- nlmsg_free(msg);
180- return -ENOBUFS;
181+ !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)))
182+ goto fail;
183+
184+ switch (mode) {
185+ case MU_CTRL_ONOFF:
186+ if (nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, val))
187+ goto fail;
188+ break;
189+ case MU_CTRL_UL_USER_CNT:
190+ case MU_CTRL_DL_USER_CNT:
191+ if (nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_OFDMA_MODE, mode) ||
192+ nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_OFDMA_VAL, val))
193+ goto fail;
194+ break;
195+ default:
196+ wpa_printf(MSG_ERROR, "nl80211: Wrong mu mode !");
197+ ret = -EINVAL;
198+ goto fail;
199 }
200+
201 nla_nest_end(msg, data);
202+
203 ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL);
204 if(ret){
205- wpa_printf(MSG_ERROR, "Failed to set mu_onoff. ret=%d (%s)", ret, strerror(-ret));
206+ wpa_printf(MSG_ERROR, "Failed to set mu_ctrl. ret=%d (%s)", ret, strerror(-ret));
207 }
208 return ret;
209+
210+fail:
211+ nl80211_nlmsg_clear(msg);
212+ nlmsg_free(msg);
213+ return ret;
214 }
215
216
developer95671ae2023-09-25 14:16:05 +0800217@@ -14849,7 +14870,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
developer505c9432023-05-12 18:58:17 +0800218 .update_connect_params = nl80211_update_connection_params,
219 .send_external_auth_status = nl80211_send_external_auth_status,
220 .set_4addr_mode = nl80211_set_4addr_mode,
221- .mu_ctrl = nl80211_mu_onoff,
222+ .mu_ctrl = nl80211_mu_ctrl,
223 .mu_dump = nl80211_mu_dump,
224 #ifdef CONFIG_DPP
225 .dpp_listen = nl80211_dpp_listen,
226--
developerdfb50982023-09-11 13:34:36 +08002272.18.0
developer505c9432023-05-12 18:58:17 +0800228