developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 1 | From f54048fe93acc757c0cb144077d4e4e3fb2ac9fc Mon Sep 17 00:00:00 2001 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Fri, 12 May 2023 05:24:19 +0800 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 033/126] mtk: hostapd: Add muru user number debug command |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
| 7 | hostapd/ctrl_iface.c | 13 ++++++++++++- |
| 8 | src/ap/ap_drv_ops.c | 4 ++-- |
| 9 | src/ap/ap_drv_ops.h | 2 +- |
| 10 | src/ap/hostapd.c | 3 ++- |
| 11 | src/common/mtk_vendor.h | 7 +++++++ |
| 12 | src/drivers/driver.h | 4 ++-- |
| 13 | src/drivers/driver_nl80211.c | 37 ++++++++++++++++++++++++++++-------- |
| 14 | 7 files changed, 55 insertions(+), 15 deletions(-) |
| 15 | |
| 16 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 17 | index 03831a908..b78ee24c0 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 18 | --- a/hostapd/ctrl_iface.c |
| 19 | +++ b/hostapd/ctrl_iface.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 20 | @@ -3803,6 +3803,8 @@ hostapd_ctrl_iface_set_edcca(struct hostapd_data *hapd, char *cmd, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 21 | 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) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 29 | @@ -4195,6 +4197,8 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 30 | 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) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 38 | @@ -4212,13 +4216,20 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 39 | 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; |
| 60 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 61 | index 5988bd11c..496fd4263 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 62 | --- a/src/ap/ap_drv_ops.c |
| 63 | +++ b/src/ap/ap_drv_ops.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 64 | @@ -1299,11 +1299,11 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 65 | 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) |
| 78 | diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 79 | index d914fd967..a949e168d 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 80 | --- a/src/ap/ap_drv_ops.h |
| 81 | +++ b/src/ap/ap_drv_ops.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 82 | @@ -156,7 +156,7 @@ int hostapd_drv_configure_edcca_enable(struct hostapd_data *hapd); |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 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); |
| 91 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 92 | index 6ab3e6043..9e1ba6a21 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 93 | --- a/src/ap/hostapd.c |
| 94 | +++ b/src/ap/hostapd.c |
| 95 | @@ -58,6 +58,7 @@ |
| 96 | #include "wpa_auth_kay.h" |
| 97 | #include "hw_features.h" |
| 98 | |
| 99 | +#include "common/mtk_vendor.h" |
| 100 | |
| 101 | static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason); |
| 102 | #ifdef CONFIG_WEP |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 103 | @@ -2762,7 +2763,7 @@ dfs_offload: |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 104 | 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; |
| 112 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 113 | index ee0c15eb3..34238f098 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 114 | --- a/src/common/mtk_vendor.h |
| 115 | +++ b/src/common/mtk_vendor.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 116 | @@ -202,6 +202,8 @@ enum mtk_vendor_attr_mu_ctrl { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 117 | |
| 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, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 125 | @@ -275,4 +277,9 @@ struct amnt_resp_data { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 126 | 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 */ |
| 135 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 136 | index 4bc0bbeae..c8910739e 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 137 | --- a/src/drivers/driver.h |
| 138 | +++ b/src/drivers/driver.h |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 139 | @@ -5262,11 +5262,11 @@ struct wpa_driver_ops { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 140 | 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 | /** |
| 153 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 154 | index db8a6f8e4..da1e6a8ed 100644 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 155 | --- a/src/drivers/driver_nl80211.c |
| 156 | +++ b/src/drivers/driver_nl80211.c |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 157 | @@ -14007,13 +14007,13 @@ fail: |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 158 | |
| 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, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 173 | @@ -14024,17 +14024,38 @@ static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 174 | 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_cmd(drv, msg); |
| 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 | |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 217 | @@ -15206,7 +15227,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 218 | .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 | -- |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame^] | 227 | 2.18.0 |
developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame] | 228 | |