developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 1 | From 985f076026a2e4d7083272da975601be9b74d806 Mon Sep 17 00:00:00 2001 |
| 2 | From: MeiChia Chiu <meichia.chiu@mediatek.com> |
| 3 | Date: Thu, 27 Apr 2023 15:28:43 +0800 |
| 4 | Subject: [PATCH] hostapd: mtk: Add muru user number debug command |
| 5 | |
| 6 | --- |
| 7 | hostapd/ctrl_iface.c | 11 ++++++++++- |
| 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, 53 insertions(+), 16 deletions(-) |
| 15 | |
| 16 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
| 17 | index becb09c..3391015 100644 |
| 18 | --- a/hostapd/ctrl_iface.c |
| 19 | +++ b/hostapd/ctrl_iface.c |
| 20 | @@ -3473,6 +3473,8 @@ hostapd_ctrl_iface_set_mu(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 | @@ -3490,13 +3492,20 @@ hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
| 30 | return -1; |
| 31 | } |
| 32 | hapd->iconf->mu_onoff = (u8) mu; |
| 33 | + mode = MU_CTRL_ONOFF; |
| 34 | + } else if (os_strcmp(config, "ul_user_cnt") == 0) { |
| 35 | + mode = MU_CTRL_UL_USER_CNT; |
| 36 | + wpa_printf(MSG_ERROR, "ul_user_cnt:%d\n", (u8)atoi(value)); |
| 37 | + } else if (os_strcmp(config, "dl_user_cnt") == 0) { |
| 38 | + mode = MU_CTRL_DL_USER_CNT; |
| 39 | + wpa_printf(MSG_ERROR, "dl_user_cnt:%d\n", (u8)atoi(value)); |
| 40 | } else { |
| 41 | wpa_printf(MSG_ERROR, |
| 42 | "Unsupported parameter %s for SET_MU", config); |
| 43 | return -1; |
| 44 | } |
| 45 | |
| 46 | - if(hostapd_drv_mu_ctrl(hapd) == 0) { |
| 47 | + if(hostapd_drv_mu_ctrl(hapd, mode, (u8)atoi(value)) == 0) { |
| 48 | return os_snprintf(buf, buflen, "OK\n"); |
| 49 | } else { |
| 50 | return -1; |
| 51 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
| 52 | index eafa588..bf64b77 100644 |
| 53 | --- a/src/ap/ap_drv_ops.c |
| 54 | +++ b/src/ap/ap_drv_ops.c |
| 55 | @@ -1040,11 +1040,11 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value) |
| 56 | return hapd->driver->get_edcca(hapd->drv_priv, mode, value); |
| 57 | } |
| 58 | |
| 59 | -int hostapd_drv_mu_ctrl(struct hostapd_data *hapd) |
| 60 | +int hostapd_drv_mu_ctrl(struct hostapd_data *hapd, u8 mode, u8 val) |
| 61 | { |
| 62 | if (!hapd->driver || !hapd->driver->mu_ctrl) |
| 63 | return 0; |
| 64 | - return hapd->driver->mu_ctrl(hapd->drv_priv, hapd->iconf->mu_onoff); |
| 65 | + return hapd->driver->mu_ctrl(hapd->drv_priv, mode, val); |
| 66 | } |
| 67 | |
| 68 | int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff) |
| 69 | diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h |
| 70 | index 28f2a4d..2a89b99 100644 |
| 71 | --- a/src/ap/ap_drv_ops.h |
| 72 | +++ b/src/ap/ap_drv_ops.h |
| 73 | @@ -142,7 +142,7 @@ int hostapd_drv_configure_edcca_enable(struct hostapd_data *hapd); |
| 74 | int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd, |
| 75 | const int *threshold); |
| 76 | int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value); |
| 77 | -int hostapd_drv_mu_ctrl(struct hostapd_data *hapd); |
| 78 | +int hostapd_drv_mu_ctrl(struct hostapd_data *hapd, u8 mode, u8 val); |
| 79 | int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff); |
| 80 | int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd); |
| 81 | int hostapd_drv_ibf_ctrl(struct hostapd_data *hapd); |
| 82 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
| 83 | index b2fd9b9..49a1d30 100644 |
| 84 | --- a/src/ap/hostapd.c |
| 85 | +++ b/src/ap/hostapd.c |
| 86 | @@ -55,7 +55,7 @@ |
| 87 | #include "hs20.h" |
| 88 | #include "airtime_policy.h" |
| 89 | #include "wpa_auth_kay.h" |
| 90 | - |
| 91 | +#include "common/mtk_vendor.h" |
| 92 | |
| 93 | static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason); |
| 94 | #ifdef CONFIG_WEP |
| 95 | @@ -2360,7 +2360,7 @@ dfs_offload: |
| 96 | if (hostapd_drv_configure_edcca_threshold(hapd, |
| 97 | hapd->iconf->edcca_threshold) < 0) |
| 98 | goto fail; |
| 99 | - if (hostapd_drv_mu_ctrl(hapd) < 0) |
| 100 | + if (hostapd_drv_mu_ctrl(hapd, MU_CTRL_ONOFF, hapd->iconf->mu_onoff) < 0) |
| 101 | goto fail; |
| 102 | if (hostapd_drv_three_wire_ctrl(hapd) < 0) |
| 103 | goto fail; |
| 104 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
| 105 | index 74f467c..7dd2fc4 100644 |
| 106 | --- a/src/common/mtk_vendor.h |
| 107 | +++ b/src/common/mtk_vendor.h |
| 108 | @@ -197,6 +197,8 @@ enum mtk_vendor_attr_mu_ctrl { |
| 109 | |
| 110 | MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
| 111 | MTK_VENDOR_ATTR_MU_CTRL_DUMP, |
| 112 | + MTK_VENDOR_ATTR_MU_CTRL_OFDMA_MODE, |
| 113 | + MTK_VENDOR_ATTR_MU_CTRL_OFDMA_VAL, |
| 114 | |
| 115 | /* keep last */ |
| 116 | NUM_MTK_VENDOR_ATTRS_MU_CTRL, |
| 117 | @@ -270,4 +272,9 @@ struct amnt_resp_data { |
| 118 | struct amnt_data resp_data[0]; |
| 119 | }; |
| 120 | |
| 121 | +enum { |
| 122 | + MU_CTRL_ONOFF, |
| 123 | + MU_CTRL_DL_USER_CNT, |
| 124 | + MU_CTRL_UL_USER_CNT, |
| 125 | +}; |
| 126 | #endif /* MTK_VENDOR_H */ |
| 127 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
| 128 | index 1444cbe..01281a1 100644 |
| 129 | --- a/src/drivers/driver.h |
| 130 | +++ b/src/drivers/driver.h |
| 131 | @@ -4742,11 +4742,11 @@ struct wpa_driver_ops { |
| 132 | int (*get_edcca)(void *priv, const u8 mode, u8 *value); |
| 133 | |
| 134 | /** |
| 135 | - * mu_ctrl - ctrl on off for UL/DL MURU |
| 136 | + * mu_ctrl - ctrl for UL/DL MURU |
| 137 | * @priv: Private driver interface data |
| 138 | * |
| 139 | */ |
| 140 | - int (*mu_ctrl)(void *priv, u8 mu_onoff); |
| 141 | + int (*mu_ctrl)(void *priv, u8 mode, u8 val); |
| 142 | int (*mu_dump)(void *priv, u8 *mu_onoff); |
| 143 | |
| 144 | /** |
| 145 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
| 146 | index 0470079..3d71405 100644 |
| 147 | --- a/src/drivers/driver_nl80211.c |
| 148 | +++ b/src/drivers/driver_nl80211.c |
| 149 | @@ -12430,13 +12430,13 @@ fail: |
| 150 | |
| 151 | |
| 152 | #ifdef CONFIG_IEEE80211AX |
| 153 | -static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
| 154 | +static int nl80211_mu_ctrl(void *priv, u8 mode, u8 val) |
| 155 | { |
| 156 | struct i802_bss *bss = priv; |
| 157 | struct wpa_driver_nl80211_data *drv = bss->drv; |
| 158 | struct nl_msg *msg; |
| 159 | struct nlattr *data; |
| 160 | - int ret; |
| 161 | + int ret = -ENOBUFS; |
| 162 | |
| 163 | if (!drv->mtk_mu_vendor_cmd_avail) { |
| 164 | wpa_printf(MSG_INFO, |
| 165 | @@ -12447,17 +12447,38 @@ static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
| 166 | if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || |
| 167 | nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 168 | nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_MU_CTRL) || |
| 169 | - !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) || |
| 170 | - nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, mu_onoff)) { |
| 171 | - nlmsg_free(msg); |
| 172 | - return -ENOBUFS; |
| 173 | + !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA))) |
| 174 | + goto fail; |
| 175 | + |
| 176 | + switch (mode) { |
| 177 | + case MU_CTRL_ONOFF: |
| 178 | + if (nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, val)) |
| 179 | + goto fail; |
| 180 | + break; |
| 181 | + case MU_CTRL_UL_USER_CNT: |
| 182 | + case MU_CTRL_DL_USER_CNT: |
| 183 | + if (nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_OFDMA_MODE, mode) || |
| 184 | + nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_OFDMA_VAL, val)) |
| 185 | + goto fail; |
| 186 | + break; |
| 187 | + default: |
| 188 | + wpa_printf(MSG_ERROR, "nl80211: Wrong mu mode !"); |
| 189 | + ret = -EINVAL; |
| 190 | + goto fail; |
| 191 | } |
| 192 | + |
| 193 | nla_nest_end(msg, data); |
| 194 | + |
| 195 | ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 196 | if(ret){ |
| 197 | - wpa_printf(MSG_ERROR, "Failed to set mu_onoff. ret=%d (%s)", ret, strerror(-ret)); |
| 198 | + wpa_printf(MSG_ERROR, "Failed to set mu_ctrl. ret=%d (%s)", ret, strerror(-ret)); |
| 199 | } |
| 200 | return ret; |
| 201 | + |
| 202 | +fail: |
| 203 | + nl80211_nlmsg_clear(msg); |
| 204 | + nlmsg_free(msg); |
| 205 | + return ret; |
| 206 | } |
| 207 | |
| 208 | |
| 209 | @@ -13512,7 +13533,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 210 | .update_connect_params = nl80211_update_connection_params, |
| 211 | .send_external_auth_status = nl80211_send_external_auth_status, |
| 212 | .set_4addr_mode = nl80211_set_4addr_mode, |
| 213 | - .mu_ctrl = nl80211_mu_onoff, |
| 214 | + .mu_ctrl = nl80211_mu_ctrl, |
| 215 | .mu_dump = nl80211_mu_dump, |
| 216 | #ifdef CONFIG_DPP |
| 217 | .dpp_listen = nl80211_dpp_listen, |
| 218 | -- |
| 219 | 2.39.0 |
| 220 | |