developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 1 | From de53629544ee0f9508554049bc5927ce2f04fcf9 Mon Sep 17 00:00:00 2001 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Fri, 12 May 2023 05:24:19 +0800 |
developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 24/40] hostapd: mtk: Add muru user number debug command |
developer | 505c943 | 2023-05-12 18:58:17 +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 +- |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 10 | src/ap/hostapd.c | 3 ++- |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 11 | src/common/mtk_vendor.h | 7 +++++++ |
| 12 | src/drivers/driver.h | 4 ++-- |
| 13 | src/drivers/driver_nl80211.c | 37 ++++++++++++++++++++++++++++-------- |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 14 | 7 files changed, 55 insertions(+), 15 deletions(-) |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 15 | |
| 16 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 17 | index 1bb64ea..f36c138 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 18 | --- a/hostapd/ctrl_iface.c |
| 19 | +++ b/hostapd/ctrl_iface.c |
developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 20 | @@ -3398,6 +3398,8 @@ hostapd_ctrl_iface_set_edcca(struct hostapd_data *hapd, char *cmd, |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 29 | @@ -3504,6 +3506,8 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 38 | @@ -3521,13 +3525,20 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 61 | index b90dd57..0aec9e9 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 62 | --- a/src/ap/ap_drv_ops.c |
| 63 | +++ b/src/ap/ap_drv_ops.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 64 | @@ -1162,11 +1162,11 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value) |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 79 | index 1e2a92a..5dd701e 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 80 | --- 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); |
| 91 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 92 | index 24e5df8..25ae08f 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 93 | --- a/src/ap/hostapd.c |
| 94 | +++ b/src/ap/hostapd.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 95 | @@ -57,6 +57,7 @@ |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 96 | #include "wpa_auth_kay.h" |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 97 | #include "hw_features.h" |
| 98 | |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 103 | @@ -2517,7 +2518,7 @@ dfs_offload: |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 113 | index dd1ca21..99371bf 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 114 | --- a/src/common/mtk_vendor.h |
| 115 | +++ b/src/common/mtk_vendor.h |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 116 | @@ -199,6 +199,8 @@ enum mtk_vendor_attr_mu_ctrl { |
developer | 505c943 | 2023-05-12 18:58:17 +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 | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 125 | @@ -272,4 +274,9 @@ struct amnt_resp_data { |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 136 | index 5c70ec7..84387a6 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 137 | --- a/src/drivers/driver.h |
| 138 | +++ b/src/drivers/driver.h |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 139 | @@ -5096,11 +5096,11 @@ struct wpa_driver_ops { |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 154 | index 3d8cb95..b682620 100644 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 155 | --- a/src/drivers/driver_nl80211.c |
| 156 | +++ b/src/drivers/driver_nl80211.c |
developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 157 | @@ -13562,13 +13562,13 @@ fail: |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 173 | @@ -13579,17 +13579,38 @@ static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
developer | 505c943 | 2023-05-12 18:58:17 +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_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 | |
developer | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 217 | @@ -14731,7 +14752,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | 505c943 | 2023-05-12 18:58:17 +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 | dfb5098 | 2023-09-11 13:34:36 +0800 | [diff] [blame^] | 227 | 2.18.0 |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 228 | |