developer | 66e89bc | 2024-04-23 14:50:01 +0800 | [diff] [blame^] | 1 | From ccef6202191f2a17f84f021e6e2ade206b8c9cc1 Mon Sep 17 00:00:00 2001 |
| 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Fri, 12 May 2023 05:24:19 +0800 |
| 4 | Subject: [PATCH 051/104] mtk: hostapd: Add muru user number debug command |
| 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 |
| 17 | index 56722384b..88475b321 100644 |
| 18 | --- a/hostapd/ctrl_iface.c |
| 19 | +++ b/hostapd/ctrl_iface.c |
| 20 | @@ -3673,6 +3673,8 @@ hostapd_ctrl_iface_set_edcca(struct hostapd_data *hapd, char *cmd, |
| 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) |
| 29 | @@ -4065,6 +4067,8 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
| 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) |
| 38 | @@ -4082,13 +4086,20 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
| 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 |
| 61 | index df652b12f..8878db380 100644 |
| 62 | --- a/src/ap/ap_drv_ops.c |
| 63 | +++ b/src/ap/ap_drv_ops.c |
| 64 | @@ -1270,11 +1270,11 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value) |
| 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 |
| 79 | index 4805a2e84..f77d07da0 100644 |
| 80 | --- a/src/ap/ap_drv_ops.h |
| 81 | +++ b/src/ap/ap_drv_ops.h |
| 82 | @@ -153,7 +153,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 |
| 92 | index a5b683676..5fd46d53d 100644 |
| 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 |
| 103 | @@ -2699,7 +2700,7 @@ dfs_offload: |
| 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 |
| 113 | index dd1ca2164..99371bf73 100644 |
| 114 | --- a/src/common/mtk_vendor.h |
| 115 | +++ b/src/common/mtk_vendor.h |
| 116 | @@ -199,6 +199,8 @@ enum mtk_vendor_attr_mu_ctrl { |
| 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, |
| 125 | @@ -272,4 +274,9 @@ struct amnt_resp_data { |
| 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 |
| 136 | index dd9c33201..3be4562e7 100644 |
| 137 | --- a/src/drivers/driver.h |
| 138 | +++ b/src/drivers/driver.h |
| 139 | @@ -5236,11 +5236,11 @@ struct wpa_driver_ops { |
| 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 |
| 154 | index a2a6807f4..035a477e2 100644 |
| 155 | --- a/src/drivers/driver_nl80211.c |
| 156 | +++ b/src/drivers/driver_nl80211.c |
| 157 | @@ -13982,13 +13982,13 @@ fail: |
| 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, |
| 173 | @@ -13999,17 +13999,38 @@ static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
| 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 | |
| 217 | @@ -15178,7 +15199,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 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 | -- |
| 227 | 2.39.2 |
| 228 | |