developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 1 | From 32816f9bf56aeff95ddfe4a735028bee0d552f4d Mon Sep 17 00:00:00 2001 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 2 | From: TomLiu <tomml.liu@mediatek.com> |
| 3 | Date: Wed, 21 Sep 2022 15:14:11 -0700 |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 4/6] add hostapd AMPDU and AMSDU control command |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 5 | |
| 6 | --- |
| 7 | hostapd/config_file.c | 18 ++++ |
| 8 | hostapd/ctrl_iface.c | 44 ++++++++ |
| 9 | hostapd/hostapd_cli.c | 9 ++ |
| 10 | src/ap/ap_config.c | 2 + |
| 11 | src/ap/ap_config.h | 2 + |
| 12 | src/ap/ap_drv_ops.c | 23 ++++- |
| 13 | src/ap/ap_drv_ops.h | 3 + |
| 14 | src/ap/hostapd.c | 4 + |
| 15 | src/common/mtk_vendor.h | 18 ++++ |
| 16 | src/drivers/driver.h | 11 ++ |
| 17 | src/drivers/driver_nl80211.c | 160 ++++++++++++++++++++++++++++++ |
| 18 | src/drivers/driver_nl80211.h | 1 + |
| 19 | src/drivers/driver_nl80211_capa.c | 3 + |
| 20 | 13 files changed, 297 insertions(+), 1 deletion(-) |
| 21 | |
| 22 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 23 | index 6b3b88d..9660543 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 24 | --- a/hostapd/config_file.c |
| 25 | +++ b/hostapd/config_file.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 26 | @@ -4843,6 +4843,24 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 27 | } else if (os_strcmp(buf, "ibf_enable") == 0) { /*ibf setting is per device*/ |
| 28 | int val = atoi(pos); |
| 29 | conf->ibf_enable = !!val; |
| 30 | + } else if (os_strcmp(buf, "ampdu") == 0) { |
| 31 | + int val = atoi(pos); |
| 32 | + if (val < 0 || val > 1) { |
| 33 | + wpa_printf(MSG_ERROR, |
| 34 | + "Line %d: invalid ampdu value", |
| 35 | + line); |
| 36 | + return 1; |
| 37 | + } |
| 38 | + conf->ampdu = val; |
| 39 | + } else if (os_strcmp(buf, "amsdu") == 0) { |
| 40 | + int val = atoi(pos); |
| 41 | + if (val < 0 || val > 1) { |
| 42 | + wpa_printf(MSG_ERROR, |
| 43 | + "Line %d: invalid amsdu value", |
| 44 | + line); |
| 45 | + return 1; |
| 46 | + } |
| 47 | + conf->amsdu = val; |
| 48 | } else { |
| 49 | wpa_printf(MSG_ERROR, |
| 50 | "Line %d: unknown configuration item '%s'", |
| 51 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 52 | index c881d37..e51488e 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 53 | --- a/hostapd/ctrl_iface.c |
| 54 | +++ b/hostapd/ctrl_iface.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 55 | @@ -3522,6 +3522,48 @@ hostapd_ctrl_iface_get_ibf(struct hostapd_data *hapd, char *buf, |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | |
| 59 | +static int |
| 60 | +hostapd_ctrl_iface_get_aggregation(struct hostapd_data *hapd, char *buf, |
| 61 | + size_t buflen) |
| 62 | +{ |
| 63 | + u8 aggr; |
| 64 | + int ret; |
| 65 | + char *pos, *end; |
| 66 | + |
| 67 | + pos = buf; |
| 68 | + end = buf + buflen; |
| 69 | + |
| 70 | + if (hostapd_drv_aggregation_dump(hapd, &aggr) == 0) { |
| 71 | + if (aggr == 0) { |
| 72 | + hapd->iconf->ampdu = 0; |
| 73 | + hapd->iconf->amsdu = 0; |
| 74 | + ret = os_snprintf(pos, end - pos, "[hostapd_cli] AMPDU: %u, AMSDU disabled\n", |
| 75 | + hapd->iconf->ampdu); |
| 76 | + } else if (aggr == 1) { |
| 77 | + hapd->iconf->ampdu = 0; |
| 78 | + hapd->iconf->amsdu = 1; |
| 79 | + ret = os_snprintf(pos, end - pos, "[hostapd_cli] AMPDU: %u, AMSDU disabled\n", |
| 80 | + hapd->iconf->ampdu); |
| 81 | + } else if (aggr == 2) { |
| 82 | + hapd->iconf->ampdu = 1; |
| 83 | + hapd->iconf->amsdu = 0; |
| 84 | + ret = os_snprintf(pos, end - pos, "[hostapd_cli] AMPDU: %u, AMSDU: %u\n", |
| 85 | + hapd->iconf->ampdu, hapd->iconf->amsdu); |
| 86 | + } else if (aggr == 3) { |
| 87 | + hapd->iconf->ampdu = 1; |
| 88 | + hapd->iconf->amsdu = 1; |
| 89 | + ret = os_snprintf(pos, end - pos, "[hostapd_cli] AMPDU: %u, AMSDU: %u\n", |
| 90 | + hapd->iconf->ampdu, hapd->iconf->amsdu); |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + if (os_snprintf_error(end - pos, ret)) |
| 95 | + return 0; |
| 96 | + |
| 97 | + return ret; |
| 98 | +} |
| 99 | + |
| 100 | + |
| 101 | static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
| 102 | char *buf, char *reply, |
| 103 | int reply_size, |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 104 | @@ -4081,6 +4123,8 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 105 | reply_len = hostapd_ctrl_iface_get_hemu(hapd, reply, reply_size); |
| 106 | } else if (os_strncmp(buf, "GET_IBF", 7) == 0) { |
| 107 | reply_len = hostapd_ctrl_iface_get_ibf(hapd, reply, reply_size); |
| 108 | + } else if (os_strncmp(buf, "GET_AGGR", 8) == 0) { |
| 109 | + reply_len = hostapd_ctrl_iface_get_aggregation(hapd, reply, reply_size); |
| 110 | } else { |
| 111 | os_memcpy(reply, "UNKNOWN COMMAND\n", 16); |
| 112 | reply_len = 16; |
| 113 | diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 114 | index c2a123a..9a5a6b1 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 115 | --- a/hostapd/hostapd_cli.c |
| 116 | +++ b/hostapd/hostapd_cli.c |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 117 | @@ -1593,6 +1593,13 @@ static int hostapd_cli_cmd_get_ibf(struct wpa_ctrl *ctrl, int argc, |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | |
| 121 | +static int hostapd_cli_cmd_get_aggregation(struct wpa_ctrl *ctrl, int argc, |
| 122 | + char *argv[]) |
| 123 | +{ |
| 124 | + return hostapd_cli_cmd(ctrl, "GET_AGGR", 0, NULL, NULL); |
| 125 | +} |
| 126 | + |
| 127 | + |
| 128 | struct hostapd_cli_cmd { |
| 129 | const char *cmd; |
| 130 | int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]); |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 131 | @@ -1796,6 +1803,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 132 | "<tx type(0/1/2)> <interval> = runtime set inband discovery" }, |
| 133 | { "get_ibf", hostapd_cli_cmd_get_ibf, NULL, |
| 134 | " = show iBF state (enabled/disabled)"}, |
| 135 | + { "get_aggr", hostapd_cli_cmd_get_aggregation, NULL, |
| 136 | + " = show AMPDU and AMSDU state"}, |
| 137 | { NULL, NULL, NULL, NULL } |
| 138 | }; |
| 139 | |
| 140 | diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 141 | index 7a96cb8..3ce8217 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 142 | --- a/src/ap/ap_config.c |
| 143 | +++ b/src/ap/ap_config.c |
| 144 | @@ -299,6 +299,8 @@ struct hostapd_config * hostapd_config_defaults(void) |
| 145 | conf->edcca_compensation = EDCCA_DEFAULT_COMPENSATION; |
| 146 | conf->three_wire_enable = THREE_WIRE_MODE_DISABLE; |
| 147 | conf->ibf_enable = IBF_DEFAULT_ENABLE; |
| 148 | + conf->ampdu = 1; |
| 149 | + conf->amsdu = 1; |
| 150 | |
| 151 | return conf; |
| 152 | } |
| 153 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 154 | index 44a0e7e..3e73236 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 155 | --- a/src/ap/ap_config.h |
| 156 | +++ b/src/ap/ap_config.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 157 | @@ -1159,6 +1159,8 @@ struct hostapd_config { |
| 158 | int *edcca_threshold; |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 159 | u8 three_wire_enable; |
| 160 | u8 ibf_enable; |
| 161 | + u8 ampdu; |
| 162 | + u8 amsdu; |
| 163 | }; |
| 164 | |
| 165 | enum three_wire_mode { |
| 166 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 167 | index 60ae825..5d07272 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 168 | --- a/src/ap/ap_drv_ops.c |
| 169 | +++ b/src/ap/ap_drv_ops.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 170 | @@ -1077,4 +1077,25 @@ int hostapd_drv_ibf_dump(struct hostapd_data *hapd, u8 *ibf_enable) |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 171 | if (!hapd->driver || !hapd->driver->ibf_dump) |
| 172 | return 0; |
| 173 | return hapd->driver->ibf_dump(hapd->drv_priv, ibf_enable); |
| 174 | -} |
| 175 | \ No newline at end of file |
| 176 | +} |
| 177 | + |
| 178 | +int hostapd_drv_ampdu_ctrl(struct hostapd_data *hapd) |
| 179 | +{ |
| 180 | + if (!hapd->driver || !hapd->driver->ampdu_ctrl) |
| 181 | + return 0; |
| 182 | + return hapd->driver->ampdu_ctrl(hapd->drv_priv, hapd->iconf->ampdu); |
| 183 | +} |
| 184 | + |
| 185 | +int hostapd_drv_amsdu_ctrl(struct hostapd_data *hapd) |
| 186 | +{ |
| 187 | + if (!hapd->driver || !hapd->driver->amsdu_ctrl) |
| 188 | + return 0; |
| 189 | + return hapd->driver->amsdu_ctrl(hapd->drv_priv, hapd->iconf->amsdu); |
| 190 | +} |
| 191 | + |
| 192 | +int hostapd_drv_aggregation_dump(struct hostapd_data *hapd, u8 *aggr) |
| 193 | +{ |
| 194 | + if (!hapd->driver || !hapd->driver->aggregation_dump) |
| 195 | + return 0; |
| 196 | + return hapd->driver->aggregation_dump(hapd->drv_priv, aggr); |
| 197 | +} |
| 198 | diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 199 | index ab9aedc..4c1c201 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 200 | --- a/src/ap/ap_drv_ops.h |
| 201 | +++ b/src/ap/ap_drv_ops.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 202 | @@ -147,6 +147,9 @@ int hostapd_drv_hemu_dump(struct hostapd_data *hapd, u8 *hemu_onoff); |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 203 | int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd); |
| 204 | int hostapd_drv_ibf_ctrl(struct hostapd_data *hapd); |
| 205 | int hostapd_drv_ibf_dump(struct hostapd_data *hapd, u8 *ibf_enable); |
| 206 | +int hostapd_drv_ampdu_ctrl(struct hostapd_data *hapd); |
| 207 | +int hostapd_drv_amsdu_ctrl(struct hostapd_data *hapd); |
| 208 | +int hostapd_drv_aggregation_dump(struct hostapd_data *hapd, u8 *aggr); |
| 209 | |
| 210 | #include "drivers/driver.h" |
| 211 | |
| 212 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 213 | index e44b73d..60bd6f3 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 214 | --- a/src/ap/hostapd.c |
| 215 | +++ b/src/ap/hostapd.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 216 | @@ -2307,6 +2307,10 @@ dfs_offload: |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 217 | goto fail; |
| 218 | if (hostapd_drv_ibf_ctrl(hapd) < 0) |
| 219 | goto fail; |
| 220 | + if (hostapd_drv_ampdu_ctrl(hapd) < 0) |
| 221 | + goto fail; |
| 222 | + if (hostapd_drv_amsdu_ctrl(hapd) < 0) |
| 223 | + goto fail; |
| 224 | |
| 225 | wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", |
| 226 | iface->bss[0]->conf->iface); |
| 227 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 228 | index 4050cf8..d78e538 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 229 | --- a/src/common/mtk_vendor.h |
| 230 | +++ b/src/common/mtk_vendor.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 231 | @@ -177,6 +177,24 @@ enum mtk_vendor_attr_wireless_ctrl { |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 232 | NUM_MTK_VENDOR_ATTRS_WIRELESS_CTRL - 1 |
| 233 | }; |
| 234 | |
| 235 | +enum mtk_vendor_attr_wireless_dump { |
| 236 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_UNSPEC, |
| 237 | + |
| 238 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_AMPDU, |
| 239 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU, |
| 240 | + |
| 241 | + /* keep last */ |
| 242 | + NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP, |
| 243 | + MTK_VENDOR_ATTR_WIRELESS_DUMP_MAX = |
| 244 | + NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP - 1 |
| 245 | +}; |
| 246 | + |
| 247 | +static const struct nla_policy |
| 248 | +wireless_dump_policy[NUM_MTK_VENDOR_ATTRS_WIRELESS_DUMP] = { |
| 249 | + [MTK_VENDOR_ATTR_WIRELESS_DUMP_AMPDU] = { .type = NLA_U8 }, |
| 250 | + [MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU] = { .type = NLA_U8 }, |
| 251 | +}; |
| 252 | + |
| 253 | enum mtk_vendor_attr_rfeature_ctrl { |
| 254 | MTK_VENDOR_ATTR_RFEATURE_CTRL_UNSPEC, |
| 255 | |
| 256 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 257 | index 71ded61..57f3be6 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 258 | --- a/src/drivers/driver.h |
| 259 | +++ b/src/drivers/driver.h |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 260 | @@ -4720,6 +4720,17 @@ struct wpa_driver_ops { |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 261 | * |
| 262 | */ |
| 263 | int (*ibf_dump)(void *priv, u8 *ibf_enable); |
| 264 | + |
| 265 | + /** |
| 266 | + * ampdu_ctrl - enable/disable ampdu |
| 267 | + * amsdu_ctrl - enable/disable amsdu |
| 268 | + * aggregation_dump - get current ampdu and amsdu status |
| 269 | + * @priv: Private driver interface data |
| 270 | + * |
| 271 | + */ |
| 272 | + int (*ampdu_ctrl)(void *priv, u8 ampdu); |
| 273 | + int (*amsdu_ctrl)(void *priv, u8 amsdu); |
| 274 | + int (*aggregation_dump)(void *priv, u8 *aggr); |
| 275 | }; |
| 276 | |
| 277 | /** |
| 278 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 279 | index 00f9231..07dac13 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 280 | --- a/src/drivers/driver_nl80211.c |
| 281 | +++ b/src/drivers/driver_nl80211.c |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 282 | @@ -12776,6 +12776,163 @@ fail: |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 283 | return -ENOBUFS; |
| 284 | } |
| 285 | |
| 286 | +static int nl80211_enable_ampdu(void *priv, u8 ampdu) |
| 287 | +{ |
| 288 | + struct i802_bss *bss = priv; |
| 289 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 290 | + struct nl_msg *msg; |
| 291 | + struct nlattr *data; |
| 292 | + int ret; |
| 293 | + |
| 294 | + if (!drv->mtk_wireless_vendor_cmd_avail) { |
| 295 | + wpa_printf(MSG_INFO, |
| 296 | + "nl80211: Driver does not support setting ap wireless control"); |
| 297 | + return 0; |
| 298 | + } |
| 299 | + |
| 300 | + msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR); |
| 301 | + if (!msg) |
| 302 | + goto fail; |
| 303 | + |
| 304 | + if (nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 305 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL)) |
| 306 | + goto fail; |
| 307 | + |
| 308 | + data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA); |
| 309 | + if (!data) |
| 310 | + goto fail; |
| 311 | + |
| 312 | + nla_put_u8(msg, MTK_VENDOR_ATTR_WIRELESS_CTRL_AMPDU, ampdu); |
| 313 | + |
| 314 | + nla_nest_end(msg, data); |
| 315 | + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 316 | + if (ret) { |
| 317 | + wpa_printf(MSG_ERROR, "Failed to set ampdu. ret=%d (%s)", ret, strerror(-ret)); |
| 318 | + } |
| 319 | + |
| 320 | + return ret; |
| 321 | + |
| 322 | +fail: |
| 323 | + nlmsg_free(msg); |
| 324 | + return -ENOBUFS; |
| 325 | +} |
| 326 | + |
| 327 | +static int nl80211_enable_amsdu(void *priv, u8 amsdu) |
| 328 | +{ |
| 329 | + struct i802_bss *bss = priv; |
| 330 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 331 | + struct nl_msg *msg; |
| 332 | + struct nlattr *data; |
| 333 | + int ret; |
| 334 | + |
| 335 | + if (!drv->mtk_wireless_vendor_cmd_avail) { |
| 336 | + wpa_printf(MSG_INFO, |
| 337 | + "nl80211: Driver does not support setting ap wireless control"); |
| 338 | + return 0; |
| 339 | + } |
| 340 | + |
| 341 | + msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR); |
| 342 | + if (!msg) |
| 343 | + goto fail; |
| 344 | + |
| 345 | + if (nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 346 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL)) |
| 347 | + goto fail; |
| 348 | + |
| 349 | + data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA); |
| 350 | + if (!data) |
| 351 | + goto fail; |
| 352 | + |
| 353 | + nla_put_u8(msg, MTK_VENDOR_ATTR_WIRELESS_CTRL_AMSDU, amsdu); |
| 354 | + |
| 355 | + nla_nest_end(msg, data); |
| 356 | + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 357 | + if (ret) { |
| 358 | + wpa_printf(MSG_ERROR, "Failed to set amsdu. ret=%d (%s)", ret, strerror(-ret)); |
| 359 | + } |
| 360 | + |
| 361 | + return ret; |
| 362 | + |
| 363 | +fail: |
| 364 | + nlmsg_free(msg); |
| 365 | + return -ENOBUFS; |
| 366 | +} |
| 367 | + |
| 368 | +static int dump_aggregation_handler(struct nl_msg *msg, void *arg) |
| 369 | +{ |
| 370 | + u8 ampdu, amsdu; |
| 371 | + u8 *aggr = (u8 *) arg; |
| 372 | + struct nlattr *tb[NL80211_ATTR_MAX + 1]; |
| 373 | + struct nlattr *tb_vendor[MTK_VENDOR_ATTR_WIRELESS_DUMP_MAX + 1]; |
| 374 | + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
| 375 | + struct nlattr *nl_vend, *attr_ampdu, *attr_amsdu; |
| 376 | + |
| 377 | + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 378 | + genlmsg_attrlen(gnlh, 0), NULL); |
| 379 | + |
| 380 | + nl_vend = tb[NL80211_ATTR_VENDOR_DATA]; |
| 381 | + if (!nl_vend) |
| 382 | + return NL_SKIP; |
| 383 | + |
| 384 | + nla_parse(tb_vendor, MTK_VENDOR_ATTR_WIRELESS_DUMP_MAX, |
| 385 | + nla_data(nl_vend), nla_len(nl_vend), NULL); |
| 386 | + |
| 387 | + attr_ampdu = tb_vendor[MTK_VENDOR_ATTR_WIRELESS_DUMP_AMPDU]; |
| 388 | + attr_amsdu = tb_vendor[MTK_VENDOR_ATTR_WIRELESS_DUMP_AMSDU]; |
| 389 | + if (!attr_ampdu || !attr_amsdu ){ |
| 390 | + wpa_printf(MSG_ERROR, "nl80211: cannot find vendor attributes"); |
| 391 | + return NL_SKIP; |
| 392 | + } |
| 393 | + |
| 394 | + ampdu = nla_get_u8(attr_ampdu); |
| 395 | + amsdu = nla_get_u8(attr_amsdu); |
| 396 | + |
| 397 | + *aggr = (ampdu<<1) + amsdu; |
| 398 | + return NL_SKIP; |
| 399 | +} |
| 400 | + |
| 401 | +static int |
| 402 | +nl80211_dump_aggregation(void *priv, u8 *aggr) |
| 403 | +{ |
| 404 | + struct i802_bss *bss = priv; |
| 405 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 406 | + struct nl_msg *msg; |
| 407 | + struct nlattr *data; |
| 408 | + int ret; |
| 409 | + |
| 410 | + if (!drv->mtk_wireless_vendor_cmd_avail) { |
| 411 | + wpa_printf(MSG_INFO, |
| 412 | + "nl80211: Driver does not support ap_wireless control"); |
| 413 | + return 0; |
| 414 | + } |
| 415 | + |
| 416 | + msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_VENDOR); |
| 417 | + if (!msg) |
| 418 | + goto fail; |
| 419 | + |
| 420 | + if (nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 421 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL)) |
| 422 | + goto fail; |
| 423 | + |
| 424 | + data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA); |
| 425 | + if (!data) |
| 426 | + goto fail; |
| 427 | + |
| 428 | + nla_nest_end(msg, data); |
| 429 | + |
| 430 | + ret = send_and_recv_msgs(drv, msg, dump_aggregation_handler, aggr, NULL, NULL); |
| 431 | + |
| 432 | + if (ret) { |
| 433 | + wpa_printf(MSG_ERROR, "Failed to dump aggregation. ret=%d (%s)", ret, strerror(-ret)); |
| 434 | + } |
| 435 | + |
| 436 | + return ret; |
| 437 | + |
| 438 | +fail: |
| 439 | + nlmsg_free(msg); |
| 440 | + return -ENOBUFS; |
| 441 | +} |
| 442 | + |
| 443 | const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 444 | .name = "nl80211", |
| 445 | .desc = "Linux nl80211/cfg80211", |
developer | 55a79b5 | 2022-11-18 16:01:14 +0800 | [diff] [blame^] | 446 | @@ -12930,4 +13087,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 447 | .three_wire_ctrl = nl80211_enable_three_wire, |
| 448 | .ibf_ctrl = nl80211_ibf_enable, |
| 449 | .ibf_dump = nl80211_ibf_dump, |
| 450 | + .ampdu_ctrl = nl80211_enable_ampdu, |
| 451 | + .amsdu_ctrl = nl80211_enable_amsdu, |
| 452 | + .aggregation_dump = nl80211_dump_aggregation, |
| 453 | }; |
| 454 | diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 455 | index 607592c..e570224 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 456 | --- a/src/drivers/driver_nl80211.h |
| 457 | +++ b/src/drivers/driver_nl80211.h |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 458 | @@ -185,6 +185,7 @@ struct wpa_driver_nl80211_data { |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 459 | unsigned int mtk_hemu_vendor_cmd_avail:1; |
| 460 | unsigned int mtk_3wire_vendor_cmd_avail:1; |
| 461 | unsigned int mtk_ibf_vendor_cmd_avail:1; |
| 462 | + unsigned int mtk_wireless_vendor_cmd_avail:1; |
| 463 | |
| 464 | u64 vendor_scan_cookie; |
| 465 | u64 remain_on_chan_cookie; |
| 466 | diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 467 | index 9ecc0ff..fcfa68b 100644 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 468 | --- a/src/drivers/driver_nl80211_capa.c |
| 469 | +++ b/src/drivers/driver_nl80211_capa.c |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 470 | @@ -1065,6 +1065,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 471 | case MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL: |
| 472 | drv->mtk_ibf_vendor_cmd_avail = 1; |
| 473 | break; |
| 474 | + case MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL: |
| 475 | + drv->mtk_wireless_vendor_cmd_avail = 1; |
| 476 | + break; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | -- |
developer | f10a898 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 481 | 2.18.0 |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 482 | |