developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 1 | From adc0d43ecd5ad2f8932c7a25c6b0e1dea336aef8 Mon Sep 17 00:00:00 2001 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 2 | From: TomLiu <tomml.liu@mediatek.com> |
| 3 | Date: Tue, 9 Aug 2022 10:23:44 -0700 |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH] hostapd: mtk: Add hostapd MU SET/GET control |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
| 7 | hostapd/config_file.c | 9 +++ |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 8 | hostapd/ctrl_iface.c | 66 ++++++++++++++++++ |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 9 | hostapd/hostapd_cli.c | 18 +++++ |
| 10 | src/ap/ap_config.c | 1 + |
| 11 | src/ap/ap_config.h | 1 + |
| 12 | src/ap/ap_drv_ops.c | 14 ++++ |
| 13 | src/ap/ap_drv_ops.h | 2 + |
| 14 | src/ap/hostapd.c | 2 + |
| 15 | src/common/mtk_vendor.h | 15 ++++ |
| 16 | src/drivers/driver.h | 13 ++++ |
| 17 | src/drivers/driver_nl80211.c | 110 ++++++++++++++++++++++++++++++ |
| 18 | src/drivers/driver_nl80211.h | 1 + |
| 19 | src/drivers/driver_nl80211_capa.c | 3 + |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 20 | 13 files changed, 255 insertions(+) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 21 | |
| 22 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 23 | index b5024cc..62e8b33 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 24 | --- a/hostapd/config_file.c |
| 25 | +++ b/hostapd/config_file.c |
developer | d8126d1 | 2023-02-17 11:50:45 +0800 | [diff] [blame] | 26 | @@ -3661,6 +3661,15 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 27 | return 1; |
| 28 | } |
| 29 | bss->unsol_bcast_probe_resp_interval = val; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 30 | + } else if (os_strcmp(buf, "mu_onoff") == 0) { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 31 | + int val = atoi(pos); |
| 32 | + if (val < 0 || val > 15) { |
| 33 | + wpa_printf(MSG_ERROR, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 34 | + "Line %d: invalid mu_onoff value", |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 35 | + line); |
| 36 | + return 1; |
| 37 | + } |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 38 | + conf->mu_onoff = val; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 39 | #endif /* CONFIG_IEEE80211AX */ |
| 40 | } else if (os_strcmp(buf, "max_listen_interval") == 0) { |
| 41 | bss->max_listen_interval = atoi(pos); |
| 42 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 43 | index 9c70d54..894c47a 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 44 | --- a/hostapd/ctrl_iface.c |
| 45 | +++ b/hostapd/ctrl_iface.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 46 | @@ -3441,6 +3441,67 @@ hostapd_ctrl_iface_get_edcca(struct hostapd_data *hapd, char *cmd, char *buf, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | |
| 50 | +static int |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 51 | +hostapd_ctrl_iface_set_mu(struct hostapd_data *hapd, char *cmd, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 52 | + char *buf, size_t buflen) |
| 53 | +{ |
| 54 | + char *pos, *config, *value; |
| 55 | + config = cmd; |
| 56 | + pos = os_strchr(config, ' '); |
| 57 | + if (pos == NULL) |
| 58 | + return -1; |
| 59 | + *pos++ = '\0'; |
| 60 | + |
| 61 | + if(pos == NULL) |
| 62 | + return -1; |
| 63 | + value = pos; |
| 64 | + |
| 65 | + if (os_strcmp(config, "onoff") == 0) { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 66 | + int mu = atoi(value); |
| 67 | + if (mu < 0 || mu > 15) { |
| 68 | + wpa_printf(MSG_ERROR, "Invalid value for mu"); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 69 | + return -1; |
| 70 | + } |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 71 | + hapd->iconf->mu_onoff = (u8) mu; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 72 | + } else { |
| 73 | + wpa_printf(MSG_ERROR, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 74 | + "Unsupported parameter %s for SET_MU", config); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 75 | + return -1; |
| 76 | + } |
| 77 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 78 | + if(hostapd_drv_mu_ctrl(hapd) == 0) { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 79 | + return os_snprintf(buf, buflen, "OK\n"); |
| 80 | + } else { |
| 81 | + return -1; |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | + |
| 86 | +static int |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 87 | +hostapd_ctrl_iface_get_mu(struct hostapd_data *hapd, char *buf, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 88 | + size_t buflen) |
| 89 | +{ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 90 | + u8 mu_onoff; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 91 | + char *pos, *end; |
| 92 | + |
| 93 | + pos = buf; |
| 94 | + end = buf + buflen; |
| 95 | + |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 96 | + if (hapd->iface->state != HAPD_IFACE_ENABLED) |
| 97 | + return os_snprintf(pos, end - pos, "Not allowed to get_mu when current state is %s\n", |
| 98 | + hostapd_state_text(hapd->iface->state)); |
| 99 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 100 | + if (hostapd_drv_mu_dump(hapd, &mu_onoff) == 0) { |
| 101 | + hapd->iconf->mu_onoff = mu_onoff; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 102 | + return os_snprintf(pos, end - pos, "[hostapd_cli] = UL MU-MIMO: %d, DL MU-MIMO: %d, UL OFDMA: %d, DL OFDMA: %d\n", |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 103 | + !!(mu_onoff&BIT(3)), !!(mu_onoff&BIT(2)), !!(mu_onoff&BIT(1)), !!(mu_onoff&BIT(0))); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 104 | + } else { |
| 105 | + wpa_printf(MSG_INFO, "ctrl iface failed to call"); |
| 106 | + return -1; |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | + |
| 111 | static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
| 112 | char *buf, char *reply, |
| 113 | int reply_size, |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 114 | @@ -3993,6 +4054,11 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 115 | } else if (os_strncmp(buf, "GET_EDCCA ", 10) == 0) { |
| 116 | reply_len = hostapd_ctrl_iface_get_edcca(hapd, buf+10, reply, |
| 117 | reply_size); |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 118 | + } else if (os_strncmp(buf, "SET_MU ", 7) == 0) { |
| 119 | + reply_len = hostapd_ctrl_iface_set_mu(hapd, buf + 7, reply, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 120 | + reply_size); |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 121 | + } else if (os_strncmp(buf, "GET_MU", 6) == 0) { |
| 122 | + reply_len = hostapd_ctrl_iface_get_mu(hapd, reply, reply_size); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 123 | } else { |
| 124 | os_memcpy(reply, "UNKNOWN COMMAND\n", 16); |
| 125 | reply_len = 16; |
| 126 | diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 127 | index db21258..e16a1dc 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 128 | --- a/hostapd/hostapd_cli.c |
| 129 | +++ b/hostapd/hostapd_cli.c |
| 130 | @@ -1380,6 +1380,20 @@ static int hostapd_cli_cmd_driver_flags(struct wpa_ctrl *ctrl, int argc, |
| 131 | } |
| 132 | |
| 133 | |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 134 | +static int hostapd_cli_cmd_set_mu(struct wpa_ctrl *ctrl, int argc, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 135 | + char *argv[]) |
| 136 | +{ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 137 | + return hostapd_cli_cmd(ctrl, "SET_MU", 1, argc, argv); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 138 | +} |
| 139 | + |
| 140 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 141 | +static int hostapd_cli_cmd_get_mu(struct wpa_ctrl *ctrl, int argc, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 142 | + char *argv[]) |
| 143 | +{ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 144 | + return hostapd_cli_cmd(ctrl, "GET_MU", 0, NULL, NULL); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 145 | +} |
| 146 | + |
| 147 | + |
| 148 | #ifdef CONFIG_DPP |
| 149 | |
| 150 | static int hostapd_cli_cmd_dpp_qr_code(struct wpa_ctrl *ctrl, int argc, |
| 151 | @@ -1705,6 +1719,10 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { |
| 152 | " = send FTM range request"}, |
| 153 | { "driver_flags", hostapd_cli_cmd_driver_flags, NULL, |
| 154 | " = show supported driver flags"}, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 155 | + { "set_mu", hostapd_cli_cmd_set_mu, NULL, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 156 | + "<value> [0-15] bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0)"}, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 157 | + { "get_mu", hostapd_cli_cmd_get_mu, NULL, |
| 158 | + " = show mu onoff value in 0-15 bitmap"}, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 159 | #ifdef CONFIG_DPP |
| 160 | { "dpp_qr_code", hostapd_cli_cmd_dpp_qr_code, NULL, |
| 161 | "report a scanned DPP URI from a QR Code" }, |
| 162 | diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 163 | index 344585a..9e5a2ec 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 164 | --- a/src/ap/ap_config.c |
| 165 | +++ b/src/ap/ap_config.c |
| 166 | @@ -280,6 +280,7 @@ struct hostapd_config * hostapd_config_defaults(void) |
| 167 | conf->he_6ghz_max_ampdu_len_exp = 7; |
| 168 | conf->he_6ghz_rx_ant_pat = 1; |
| 169 | conf->he_6ghz_tx_ant_pat = 1; |
developer | f0fd705 | 2023-08-14 20:23:42 +0800 | [diff] [blame] | 170 | + conf->mu_onoff = 0xf; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 171 | #endif /* CONFIG_IEEE80211AX */ |
| 172 | |
| 173 | /* The third octet of the country string uses an ASCII space character |
| 174 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 175 | index 4ac4699..37779b7 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 176 | --- a/src/ap/ap_config.h |
| 177 | +++ b/src/ap/ap_config.h |
developer | d8126d1 | 2023-02-17 11:50:45 +0800 | [diff] [blame] | 178 | @@ -1115,6 +1115,7 @@ struct hostapd_config { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 179 | u8 he_6ghz_rx_ant_pat; |
| 180 | u8 he_6ghz_tx_ant_pat; |
| 181 | u8 he_6ghz_reg_pwr_type; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 182 | + u8 mu_onoff; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 183 | #endif /* CONFIG_IEEE80211AX */ |
| 184 | |
| 185 | /* VHT enable/disable config from CHAN_SWITCH */ |
| 186 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 187 | index 25e967d..60b9fc0 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 188 | --- a/src/ap/ap_drv_ops.c |
| 189 | +++ b/src/ap/ap_drv_ops.c |
| 190 | @@ -1039,3 +1039,17 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value) |
| 191 | return 0; |
| 192 | return hapd->driver->get_edcca(hapd->drv_priv, mode, value); |
| 193 | } |
| 194 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 195 | +int hostapd_drv_mu_ctrl(struct hostapd_data *hapd) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 196 | +{ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 197 | + if (!hapd->driver || !hapd->driver->mu_ctrl) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 198 | + return 0; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 199 | + return hapd->driver->mu_ctrl(hapd->drv_priv, hapd->iconf->mu_onoff); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 200 | +} |
| 201 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 202 | +int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 203 | +{ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 204 | + if (!hapd->driver || !hapd->driver->mu_dump) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 205 | + return 0; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 206 | + return hapd->driver->mu_dump(hapd->drv_priv, mu_onoff); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 207 | +} |
| 208 | diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 209 | index 70a99f4..185d5f3 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 210 | --- a/src/ap/ap_drv_ops.h |
| 211 | +++ b/src/ap/ap_drv_ops.h |
| 212 | @@ -142,6 +142,8 @@ int hostapd_drv_configure_edcca_enable(struct hostapd_data *hapd); |
| 213 | int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd, |
| 214 | const int *threshold); |
| 215 | int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value); |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 216 | +int hostapd_drv_mu_ctrl(struct hostapd_data *hapd); |
| 217 | +int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 218 | |
| 219 | #include "drivers/driver.h" |
| 220 | |
| 221 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 222 | index 3bb38fe..71d7bfa 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 223 | --- a/src/ap/hostapd.c |
| 224 | +++ b/src/ap/hostapd.c |
developer | d8126d1 | 2023-02-17 11:50:45 +0800 | [diff] [blame] | 225 | @@ -2302,6 +2302,8 @@ dfs_offload: |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 226 | if (hostapd_drv_configure_edcca_threshold(hapd, |
| 227 | hapd->iconf->edcca_threshold) < 0) |
| 228 | goto fail; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 229 | + if (hostapd_drv_mu_ctrl(hapd) < 0) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 230 | + goto fail; |
| 231 | |
| 232 | wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", |
| 233 | iface->bss[0]->conf->iface); |
| 234 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 235 | index 7056126..ef8618e 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 236 | --- a/src/common/mtk_vendor.h |
| 237 | +++ b/src/common/mtk_vendor.h |
| 238 | @@ -10,6 +10,8 @@ enum mtk_nl80211_vendor_subcmds { |
| 239 | MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2, |
| 240 | MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3, |
| 241 | MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 242 | + MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 243 | + MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL= 0xc6, |
| 244 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 245 | }; |
| 246 | |
| 247 | @@ -174,6 +176,19 @@ enum mtk_vendor_attr_rfeature_ctrl { |
| 248 | NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1 |
| 249 | }; |
| 250 | |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 251 | +enum mtk_vendor_attr_mu_ctrl { |
| 252 | + MTK_VENDOR_ATTR_MU_CTRL_UNSPEC, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 253 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 254 | + MTK_VENDOR_ATTR_MU_CTRL_ONOFF, |
| 255 | + MTK_VENDOR_ATTR_MU_CTRL_DUMP, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 256 | + |
| 257 | + /* keep last */ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 258 | + NUM_MTK_VENDOR_ATTRS_MU_CTRL, |
| 259 | + MTK_VENDOR_ATTR_MU_CTRL_MAX = |
| 260 | + NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 261 | +}; |
| 262 | + |
| 263 | + |
| 264 | #define CSI_MAX_COUNT 256 |
| 265 | #define ETH_ALEN 6 |
| 266 | |
| 267 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 268 | index 3559974..fa5ad45 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 269 | --- a/src/drivers/driver.h |
| 270 | +++ b/src/drivers/driver.h |
| 271 | @@ -1623,6 +1623,11 @@ struct wpa_driver_ap_params { |
| 272 | * Unsolicited broadcast Probe Response template length |
| 273 | */ |
| 274 | size_t unsol_bcast_probe_resp_tmpl_len; |
| 275 | + |
| 276 | + /** |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 277 | + * mu onoff=<val> (bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0)) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 278 | + */ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 279 | + u8 mu_onoff; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | struct wpa_driver_mesh_bss_params { |
| 283 | @@ -4680,6 +4685,14 @@ struct wpa_driver_ops { |
| 284 | const s8 edcca_compensation); |
| 285 | int (*configure_edcca_threshold)(void *priv, const int *threshold); |
| 286 | int (*get_edcca)(void *priv, const u8 mode, u8 *value); |
| 287 | + |
| 288 | + /** |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 289 | + * mu_ctrl - ctrl on off for UL/DL MURU |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 290 | + * @priv: Private driver interface data |
| 291 | + * |
| 292 | + */ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 293 | + int (*mu_ctrl)(void *priv, u8 mu_onoff); |
| 294 | + int (*mu_dump)(void *priv, u8 *mu_onoff); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | /** |
| 298 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 299 | index 6d4a4db..0523aab 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 300 | --- a/src/drivers/driver_nl80211.c |
| 301 | +++ b/src/drivers/driver_nl80211.c |
| 302 | @@ -12304,6 +12304,114 @@ fail: |
| 303 | } |
| 304 | |
| 305 | |
| 306 | +#ifdef CONFIG_IEEE80211AX |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 307 | +static int nl80211_mu_onoff(void *priv, u8 mu_onoff) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 308 | +{ |
| 309 | + struct i802_bss *bss = priv; |
| 310 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 311 | + struct nl_msg *msg; |
| 312 | + struct nlattr *data; |
| 313 | + int ret; |
| 314 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 315 | + if (!drv->mtk_mu_vendor_cmd_avail) { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 316 | + wpa_printf(MSG_INFO, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 317 | + "nl80211: Driver does not support setting mu control"); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 318 | + return 0; |
| 319 | + } |
| 320 | + |
| 321 | + if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || |
| 322 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 323 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_MU_CTRL) || |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 324 | + !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) || |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 325 | + nla_put_u8(msg, MTK_VENDOR_ATTR_MU_CTRL_ONOFF, mu_onoff)) { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 326 | + nlmsg_free(msg); |
| 327 | + return -ENOBUFS; |
| 328 | + } |
| 329 | + nla_nest_end(msg, data); |
| 330 | + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 331 | + if(ret){ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 332 | + wpa_printf(MSG_ERROR, "Failed to set mu_onoff. ret=%d (%s)", ret, strerror(-ret)); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 333 | + } |
| 334 | + return ret; |
| 335 | +} |
| 336 | + |
| 337 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 338 | +static int mu_dump_handler(struct nl_msg *msg, void *arg) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 339 | +{ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 340 | + u8 *mu_onoff = (u8 *) arg; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 341 | + struct nlattr *tb[NL80211_ATTR_MAX + 1]; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 342 | + struct nlattr *tb_vendor[MTK_VENDOR_ATTR_MU_CTRL_MAX + 1]; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 343 | + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
| 344 | + struct nlattr *nl_vend, *attr; |
| 345 | + |
| 346 | + static const struct nla_policy |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 347 | + mu_ctrl_policy[NUM_MTK_VENDOR_ATTRS_MU_CTRL + 1] = { |
| 348 | + [MTK_VENDOR_ATTR_MU_CTRL_ONOFF] = {.type = NLA_U8 }, |
| 349 | + [MTK_VENDOR_ATTR_MU_CTRL_DUMP] = {.type = NLA_U8 }, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 350 | + }; |
| 351 | + |
| 352 | + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 353 | + genlmsg_attrlen(gnlh, 0), NULL); |
| 354 | + |
| 355 | + nl_vend = tb[NL80211_ATTR_VENDOR_DATA]; |
| 356 | + if (!nl_vend) |
| 357 | + return NL_SKIP; |
| 358 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 359 | + nla_parse(tb_vendor, MTK_VENDOR_ATTR_MU_CTRL_MAX, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 360 | + nla_data(nl_vend), nla_len(nl_vend), NULL); |
| 361 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 362 | + attr = tb_vendor[MTK_VENDOR_ATTR_MU_CTRL_DUMP]; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 363 | + if (!attr) { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 364 | + wpa_printf(MSG_ERROR, "nl80211: cannot find MTK_VENDOR_ATTR_MU_CTRL_DUMP"); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 365 | + return NL_SKIP; |
| 366 | + } |
| 367 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 368 | + *mu_onoff = nla_get_u8(attr); |
| 369 | + wpa_printf(MSG_DEBUG, "nla_get mu_onoff: %d\n", *mu_onoff); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 370 | + |
| 371 | + return 0; |
| 372 | +} |
| 373 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 374 | +static int nl80211_mu_dump(void *priv, u8 *mu_onoff) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 375 | +{ |
| 376 | + struct i802_bss *bss = priv; |
| 377 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 378 | + struct nl_msg *msg; |
| 379 | + struct nlattr *attr; |
| 380 | + int ret; |
| 381 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 382 | + if (!drv->mtk_mu_vendor_cmd_avail) { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 383 | + wpa_printf(MSG_INFO, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 384 | + "nl80211: Driver does not support setting mu control"); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 385 | + return 0; |
| 386 | + } |
| 387 | + |
| 388 | + if (!(msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_VENDOR)) || |
| 389 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 390 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_MU_CTRL)) { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 391 | + nlmsg_free(msg); |
| 392 | + return -ENOBUFS; |
| 393 | + } |
| 394 | + |
| 395 | + attr = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA); |
| 396 | + if (!attr) { |
| 397 | + nlmsg_free(msg); |
| 398 | + return -1; |
| 399 | + } |
| 400 | + |
| 401 | + nla_nest_end(msg, attr); |
| 402 | + |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 403 | + ret = send_and_recv_msgs(drv, msg, mu_dump_handler, mu_onoff, NULL, NULL); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 404 | + |
| 405 | + if(ret){ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 406 | + wpa_printf(MSG_ERROR, "Failed to get mu_onoff. ret=%d (%s)", ret, strerror(-ret)); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 407 | + } |
| 408 | + |
| 409 | + return ret; |
| 410 | +} |
| 411 | +#endif /* CONFIG_IEEE80211AX */ |
| 412 | + |
| 413 | + |
| 414 | #ifdef CONFIG_DPP |
| 415 | static int nl80211_dpp_listen(void *priv, bool enable) |
| 416 | { |
| 417 | @@ -12668,6 +12776,8 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 418 | .update_connect_params = nl80211_update_connection_params, |
| 419 | .send_external_auth_status = nl80211_send_external_auth_status, |
| 420 | .set_4addr_mode = nl80211_set_4addr_mode, |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 421 | + .mu_ctrl = nl80211_mu_onoff, |
| 422 | + .mu_dump = nl80211_mu_dump, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 423 | #ifdef CONFIG_DPP |
| 424 | .dpp_listen = nl80211_dpp_listen, |
| 425 | #endif /* CONFIG_DPP */ |
| 426 | diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 427 | index 13e5d24..1dd984c 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 428 | --- a/src/drivers/driver_nl80211.h |
| 429 | +++ b/src/drivers/driver_nl80211.h |
| 430 | @@ -182,6 +182,7 @@ struct wpa_driver_nl80211_data { |
| 431 | unsigned int brcm_do_acs:1; |
| 432 | unsigned int uses_6ghz:1; |
| 433 | unsigned int mtk_edcca_vendor_cmd_avail:1; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 434 | + unsigned int mtk_mu_vendor_cmd_avail:1; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 435 | |
| 436 | u64 vendor_scan_cookie; |
| 437 | u64 remain_on_chan_cookie; |
| 438 | diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 439 | index 732ae29..cc11891 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 440 | --- a/src/drivers/driver_nl80211_capa.c |
| 441 | +++ b/src/drivers/driver_nl80211_capa.c |
| 442 | @@ -1056,6 +1056,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) |
| 443 | case MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL : |
| 444 | drv->mtk_edcca_vendor_cmd_avail = 1; |
| 445 | break; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 446 | + case MTK_NL80211_VENDOR_SUBCMD_MU_CTRL : |
| 447 | + drv->mtk_mu_vendor_cmd_avail = 1; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 448 | + break; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | -- |
developer | 1a17367 | 2023-12-21 14:49:33 +0800 | [diff] [blame^] | 453 | 2.18.0 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 454 | |