developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame^] | 1 | From a90c24ae2b7558eac18cf92fee6cfaf480233ec2 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 28/28] hostapd: mtk: 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 | 4 ++-- |
| 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(+), 16 deletions(-) |
| 15 | |
| 16 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 17 | index 06d8345..2d99647 100644 |
| 18 | --- a/hostapd/ctrl_iface.c |
| 19 | +++ b/hostapd/ctrl_iface.c |
| 20 | @@ -3441,6 +3441,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 | @@ -3547,6 +3549,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 | @@ -3564,13 +3568,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 0052a6d..d5c7b15 100644 |
| 62 | --- a/src/ap/ap_drv_ops.c |
| 63 | +++ b/src/ap/ap_drv_ops.c |
| 64 | @@ -1079,11 +1079,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 9d5a23b..82283e6 100644 |
| 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 |
| 92 | index 05ddb6f..9bd81d3 100644 |
| 93 | --- a/src/ap/hostapd.c |
| 94 | +++ b/src/ap/hostapd.c |
| 95 | @@ -55,7 +55,7 @@ |
| 96 | #include "hs20.h" |
| 97 | #include "airtime_policy.h" |
| 98 | #include "wpa_auth_kay.h" |
| 99 | - |
| 100 | +#include "common/mtk_vendor.h" |
| 101 | |
| 102 | static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason); |
| 103 | #ifdef CONFIG_WEP |
| 104 | @@ -2398,7 +2398,7 @@ dfs_offload: |
| 105 | if (hostapd_drv_configure_edcca_threshold(hapd, |
| 106 | hapd->iconf->edcca_threshold) < 0) |
| 107 | goto fail; |
| 108 | - if (hostapd_drv_mu_ctrl(hapd) < 0) |
| 109 | + if (hostapd_drv_mu_ctrl(hapd, MU_CTRL_ONOFF, hapd->iconf->mu_onoff) < 0) |
| 110 | goto fail; |
| 111 | if (hostapd_drv_three_wire_ctrl(hapd) < 0) |
| 112 | goto fail; |
| 113 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
| 114 | index 74f467c..7dd2fc4 100644 |
| 115 | --- a/src/common/mtk_vendor.h |
| 116 | +++ b/src/common/mtk_vendor.h |
| 117 | @@ -197,6 +197,8 @@ enum mtk_vendor_attr_mu_ctrl { |
| 118 | |
| 119 | MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
| 120 | MTK_VENDOR_ATTR_MU_CTRL_DUMP, |
| 121 | + MTK_VENDOR_ATTR_MU_CTRL_OFDMA_MODE, |
| 122 | + MTK_VENDOR_ATTR_MU_CTRL_OFDMA_VAL, |
| 123 | |
| 124 | /* keep last */ |
| 125 | NUM_MTK_VENDOR_ATTRS_MU_CTRL, |
| 126 | @@ -270,4 +272,9 @@ struct amnt_resp_data { |
| 127 | struct amnt_data resp_data[0]; |
| 128 | }; |
| 129 | |
| 130 | +enum { |
| 131 | + MU_CTRL_ONOFF, |
| 132 | + MU_CTRL_DL_USER_CNT, |
| 133 | + MU_CTRL_UL_USER_CNT, |
| 134 | +}; |
| 135 | #endif /* MTK_VENDOR_H */ |
| 136 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
| 137 | index cb885f9..6cd4dc9 100644 |
| 138 | --- a/src/drivers/driver.h |
| 139 | +++ b/src/drivers/driver.h |
| 140 | @@ -5017,11 +5017,11 @@ struct wpa_driver_ops { |
| 141 | int (*get_edcca)(void *priv, const u8 mode, u8 *value); |
| 142 | |
| 143 | /** |
| 144 | - * mu_ctrl - ctrl on off for UL/DL MURU |
| 145 | + * mu_ctrl - ctrl for UL/DL MURU |
| 146 | * @priv: Private driver interface data |
| 147 | * |
| 148 | */ |
| 149 | - int (*mu_ctrl)(void *priv, u8 mu_onoff); |
| 150 | + int (*mu_ctrl)(void *priv, u8 mode, u8 val); |
| 151 | int (*mu_dump)(void *priv, u8 *mu_onoff); |
| 152 | |
| 153 | /** |
| 154 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
| 155 | index 088f625..8400e57 100644 |
| 156 | --- a/src/drivers/driver_nl80211.c |
| 157 | +++ b/src/drivers/driver_nl80211.c |
| 158 | @@ -13295,13 +13295,13 @@ fail: |
| 159 | |
| 160 | |
| 161 | #ifdef CONFIG_IEEE80211AX |
| 162 | -static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
| 163 | +static int nl80211_mu_ctrl(void *priv, u8 mode, u8 val) |
| 164 | { |
| 165 | struct i802_bss *bss = priv; |
| 166 | struct wpa_driver_nl80211_data *drv = bss->drv; |
| 167 | struct nl_msg *msg; |
| 168 | struct nlattr *data; |
| 169 | - int ret; |
| 170 | + int ret = -ENOBUFS; |
| 171 | |
| 172 | if (!drv->mtk_mu_vendor_cmd_avail) { |
| 173 | wpa_printf(MSG_INFO, |
| 174 | @@ -13312,17 +13312,38 @@ static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
| 175 | if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || |
| 176 | nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 177 | nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_MU_CTRL) || |
| 178 | - !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) || |
| 179 | - nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, mu_onoff)) { |
| 180 | - nlmsg_free(msg); |
| 181 | - return -ENOBUFS; |
| 182 | + !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA))) |
| 183 | + goto fail; |
| 184 | + |
| 185 | + switch (mode) { |
| 186 | + case MU_CTRL_ONOFF: |
| 187 | + if (nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, val)) |
| 188 | + goto fail; |
| 189 | + break; |
| 190 | + case MU_CTRL_UL_USER_CNT: |
| 191 | + case MU_CTRL_DL_USER_CNT: |
| 192 | + if (nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_OFDMA_MODE, mode) || |
| 193 | + nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_OFDMA_VAL, val)) |
| 194 | + goto fail; |
| 195 | + break; |
| 196 | + default: |
| 197 | + wpa_printf(MSG_ERROR, "nl80211: Wrong mu mode !"); |
| 198 | + ret = -EINVAL; |
| 199 | + goto fail; |
| 200 | } |
| 201 | + |
| 202 | nla_nest_end(msg, data); |
| 203 | + |
| 204 | ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 205 | if(ret){ |
| 206 | - wpa_printf(MSG_ERROR, "Failed to set mu_onoff. ret=%d (%s)", ret, strerror(-ret)); |
| 207 | + wpa_printf(MSG_ERROR, "Failed to set mu_ctrl. ret=%d (%s)", ret, strerror(-ret)); |
| 208 | } |
| 209 | return ret; |
| 210 | + |
| 211 | +fail: |
| 212 | + nl80211_nlmsg_clear(msg); |
| 213 | + nlmsg_free(msg); |
| 214 | + return ret; |
| 215 | } |
| 216 | |
| 217 | |
| 218 | @@ -14454,7 +14475,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 219 | .update_connect_params = nl80211_update_connection_params, |
| 220 | .send_external_auth_status = nl80211_send_external_auth_status, |
| 221 | .set_4addr_mode = nl80211_set_4addr_mode, |
| 222 | - .mu_ctrl = nl80211_mu_onoff, |
| 223 | + .mu_ctrl = nl80211_mu_ctrl, |
| 224 | .mu_dump = nl80211_mu_dump, |
| 225 | #ifdef CONFIG_DPP |
| 226 | .dpp_listen = nl80211_dpp_listen, |
| 227 | -- |
| 228 | 2.18.0 |
| 229 | |