developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 1 | From 59a1d486171bd4976b39bcf076d7a5b50237de58 Mon Sep 17 00:00:00 2001 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 2 | From: mtk27835 <shurong.wen@mediatek.com> |
| 3 | Date: Wed, 7 Sep 2022 14:41:51 -0700 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 4 | Subject: [PATCH 08/38] hostapd: mtk: Add hostapd iBF control |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: mtk27835 <shurong.wen@mediatek.com> |
| 7 | --- |
| 8 | hostapd/config_file.c | 3 + |
| 9 | hostapd/ctrl_iface.c | 26 +++++++ |
| 10 | hostapd/hostapd_cli.c | 9 +++ |
| 11 | src/ap/ap_config.c | 1 + |
| 12 | src/ap/ap_config.h | 2 + |
| 13 | src/ap/ap_drv_ops.c | 14 ++++ |
| 14 | src/ap/ap_drv_ops.h | 2 + |
| 15 | src/ap/hostapd.c | 2 + |
| 16 | src/common/mtk_vendor.h | 35 +++++++++- |
| 17 | src/drivers/driver.h | 19 ++++++ |
| 18 | src/drivers/driver_nl80211.c | 108 ++++++++++++++++++++++++++++++ |
| 19 | src/drivers/driver_nl80211.h | 1 + |
| 20 | src/drivers/driver_nl80211_capa.c | 3 + |
| 21 | 13 files changed, 224 insertions(+), 1 deletion(-) |
| 22 | |
| 23 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 24 | index d515b6e..f8560a7 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 25 | --- a/hostapd/config_file.c |
| 26 | +++ b/hostapd/config_file.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 27 | @@ -4856,6 +4856,9 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 28 | u8 en = atoi(pos); |
| 29 | |
| 30 | conf->three_wire_enable = en; |
| 31 | + } else if (os_strcmp(buf, "ibf_enable") == 0) { /*ibf setting is per device*/ |
| 32 | + int val = atoi(pos); |
| 33 | + conf->ibf_enable = !!val; |
| 34 | } else { |
| 35 | wpa_printf(MSG_ERROR, |
| 36 | "Line %d: unknown configuration item '%s'", |
| 37 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 38 | index c5d92b0..7d7ebe3 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 39 | --- a/hostapd/ctrl_iface.c |
| 40 | +++ b/hostapd/ctrl_iface.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 41 | @@ -3545,6 +3545,30 @@ hostapd_ctrl_iface_get_mu(struct hostapd_data *hapd, char *buf, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | |
| 45 | +static int |
| 46 | +hostapd_ctrl_iface_get_ibf(struct hostapd_data *hapd, char *buf, |
| 47 | + size_t buflen) |
| 48 | +{ |
| 49 | + u8 ibf_enable; |
| 50 | + int ret; |
| 51 | + char *pos, *end; |
| 52 | + |
| 53 | + pos = buf; |
| 54 | + end = buf + buflen; |
| 55 | + |
| 56 | + if (hostapd_drv_ibf_dump(hapd, &ibf_enable) == 0) { |
| 57 | + hapd->iconf->ibf_enable = ibf_enable; |
| 58 | + ret = os_snprintf(pos, end - pos, "ibf_enable: %u\n", |
| 59 | + ibf_enable); |
| 60 | + } |
| 61 | + |
| 62 | + if (os_snprintf_error(end - pos, ret)) |
| 63 | + return 0; |
| 64 | + |
| 65 | + return ret; |
| 66 | +} |
| 67 | + |
| 68 | + |
| 69 | static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
| 70 | char *buf, char *reply, |
| 71 | int reply_size, |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 72 | @@ -4109,6 +4133,8 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 73 | reply_size); |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 74 | } else if (os_strncmp(buf, "GET_MU", 6) == 0) { |
| 75 | reply_len = hostapd_ctrl_iface_get_mu(hapd, reply, reply_size); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 76 | + } else if (os_strncmp(buf, "GET_IBF", 7) == 0) { |
| 77 | + reply_len = hostapd_ctrl_iface_get_ibf(hapd, reply, reply_size); |
| 78 | } else { |
| 79 | os_memcpy(reply, "UNKNOWN COMMAND\n", 16); |
| 80 | reply_len = 16; |
| 81 | diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 82 | index 98892ee..4fa2d32 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 83 | --- a/hostapd/hostapd_cli.c |
| 84 | +++ b/hostapd/hostapd_cli.c |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 85 | @@ -1606,6 +1606,13 @@ static int hostapd_cli_cmd_driver(struct wpa_ctrl *ctrl, int argc, char *argv[]) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 86 | #endif /* ANDROID */ |
| 87 | |
| 88 | |
| 89 | +static int hostapd_cli_cmd_get_ibf(struct wpa_ctrl *ctrl, int argc, |
| 90 | + char *argv[]) |
| 91 | +{ |
| 92 | + return hostapd_cli_cmd(ctrl, "GET_IBF", 0, NULL, NULL); |
| 93 | +} |
| 94 | + |
| 95 | + |
| 96 | struct hostapd_cli_cmd { |
| 97 | const char *cmd; |
| 98 | int (*handler)(struct wpa_ctrl *ctrl, int argc, char *argv[]); |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 99 | @@ -1811,6 +1818,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 100 | #endif /* ANDROID */ |
| 101 | { "inband_discovery", hostapd_cli_cmd_inband_discovery, NULL, |
| 102 | "<tx type(0/1/2)> <interval> = runtime set inband discovery" }, |
| 103 | + { "get_ibf", hostapd_cli_cmd_get_ibf, NULL, |
| 104 | + " = show iBF state (enabled/disabled)"}, |
| 105 | { NULL, NULL, NULL, NULL } |
| 106 | }; |
| 107 | |
| 108 | diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 109 | index 8b11545..c9b9683 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 110 | --- a/src/ap/ap_config.c |
| 111 | +++ b/src/ap/ap_config.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 112 | @@ -299,6 +299,7 @@ struct hostapd_config * hostapd_config_defaults(void) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 113 | conf->edcca_enable = EDCCA_MODE_AUTO; |
| 114 | conf->edcca_compensation = EDCCA_DEFAULT_COMPENSATION; |
| 115 | conf->three_wire_enable = THREE_WIRE_MODE_DISABLE; |
| 116 | + conf->ibf_enable = IBF_DEFAULT_ENABLE; |
| 117 | |
| 118 | return conf; |
| 119 | } |
| 120 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 121 | index 52df2e0..ffbc4fb 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 122 | --- a/src/ap/ap_config.h |
| 123 | +++ b/src/ap/ap_config.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 124 | @@ -1199,6 +1199,7 @@ struct hostapd_config { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 125 | s8 edcca_compensation; |
| 126 | int *edcca_threshold; |
| 127 | u8 three_wire_enable; |
| 128 | + u8 ibf_enable; |
| 129 | }; |
| 130 | |
| 131 | enum three_wire_mode { |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 132 | @@ -1324,6 +1325,7 @@ hostapd_set_oper_centr_freq_seg1_idx(struct hostapd_config *conf, |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 133 | conf->vht_oper_centr_freq_seg1_idx = oper_centr_freq_seg1_idx; |
| 134 | } |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 135 | |
| 136 | +#define IBF_DEFAULT_ENABLE 0 |
| 137 | |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 138 | int hostapd_mac_comp(const void *a, const void *b); |
| 139 | struct hostapd_config * hostapd_config_defaults(void); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 140 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 141 | index 2f15f99..41e76aa 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 142 | --- a/src/ap/ap_drv_ops.c |
| 143 | +++ b/src/ap/ap_drv_ops.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 144 | @@ -1186,3 +1186,17 @@ int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 145 | } |
| 146 | return hapd->driver->three_wire_ctrl(hapd->drv_priv, hapd->iconf->three_wire_enable); |
| 147 | } |
| 148 | + |
| 149 | +int hostapd_drv_ibf_ctrl(struct hostapd_data *hapd) |
| 150 | +{ |
| 151 | + if (!hapd->driver || !hapd->driver->ibf_ctrl) |
| 152 | + return 0; |
| 153 | + return hapd->driver->ibf_ctrl(hapd->drv_priv, hapd->iconf->ibf_enable); |
| 154 | +} |
| 155 | + |
| 156 | +int hostapd_drv_ibf_dump(struct hostapd_data *hapd, u8 *ibf_enable) |
| 157 | +{ |
| 158 | + if (!hapd->driver || !hapd->driver->ibf_dump) |
| 159 | + return 0; |
| 160 | + return hapd->driver->ibf_dump(hapd->drv_priv, ibf_enable); |
| 161 | +} |
| 162 | \ No newline at end of file |
| 163 | diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 164 | index ed3b4cf..2958661 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 165 | --- a/src/ap/ap_drv_ops.h |
| 166 | +++ b/src/ap/ap_drv_ops.h |
developer | 5e0a8d7 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 167 | @@ -151,6 +151,8 @@ 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] | 168 | int hostapd_drv_mu_ctrl(struct hostapd_data *hapd); |
| 169 | int hostapd_drv_mu_dump(struct hostapd_data *hapd, u8 *mu_onoff); |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 170 | int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd); |
| 171 | +int hostapd_drv_ibf_ctrl(struct hostapd_data *hapd); |
| 172 | +int hostapd_drv_ibf_dump(struct hostapd_data *hapd, u8 *ibf_enable); |
| 173 | |
| 174 | #include "drivers/driver.h" |
| 175 | |
| 176 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 177 | index cad5d67..227580e 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 178 | --- a/src/ap/hostapd.c |
| 179 | +++ b/src/ap/hostapd.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 180 | @@ -2521,6 +2521,8 @@ dfs_offload: |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 181 | goto fail; |
| 182 | if (hostapd_drv_three_wire_ctrl(hapd) < 0) |
| 183 | goto fail; |
| 184 | + if (hostapd_drv_ibf_ctrl(hapd) < 0) |
| 185 | + goto fail; |
| 186 | |
| 187 | wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", |
| 188 | iface->bss[0]->conf->iface); |
| 189 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 190 | index 99ecbaf..9811f26 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 191 | --- a/src/common/mtk_vendor.h |
| 192 | +++ b/src/common/mtk_vendor.h |
| 193 | @@ -13,7 +13,8 @@ enum mtk_nl80211_vendor_subcmds { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 194 | MTK_NL80211_VENDOR_SUBCMD_MU_CTRL = 0xc5, |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 195 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL= 0xc6, |
| 196 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 197 | - MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8 |
| 198 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8, |
| 199 | + MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL = 0xc9, |
| 200 | }; |
| 201 | |
| 202 | enum mtk_vendor_attr_edcca_ctrl { |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 203 | @@ -207,6 +208,38 @@ enum mtk_vendor_attr_mu_ctrl { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 204 | NUM_MTK_VENDOR_ATTRS_MU_CTRL - 1 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 205 | }; |
| 206 | |
| 207 | +enum mtk_vendor_attr_ibf_ctrl { |
| 208 | + MTK_VENDOR_ATTR_IBF_CTRL_UNSPEC, |
| 209 | + |
| 210 | + MTK_VENDOR_ATTR_IBF_CTRL_ENABLE, |
| 211 | + |
| 212 | + /* keep last */ |
| 213 | + NUM_MTK_VENDOR_ATTRS_IBF_CTRL, |
| 214 | + MTK_VENDOR_ATTR_IBF_CTRL_MAX = |
| 215 | + NUM_MTK_VENDOR_ATTRS_IBF_CTRL - 1 |
| 216 | +}; |
| 217 | + |
| 218 | +enum mtk_vendor_attr_ibf_dump { |
| 219 | + MTK_VENDOR_ATTR_IBF_DUMP_UNSPEC, |
| 220 | + |
| 221 | + MTK_VENDOR_ATTR_IBF_DUMP_ENABLE, |
| 222 | + |
| 223 | + /* keep last */ |
| 224 | + NUM_MTK_VENDOR_ATTRS_IBF_DUMP, |
| 225 | + MTK_VENDOR_ATTR_IBF_DUMP_MAX = |
| 226 | + NUM_MTK_VENDOR_ATTRS_IBF_DUMP - 1 |
| 227 | +}; |
| 228 | + |
| 229 | +static struct nla_policy |
| 230 | +ibf_ctrl_policy[NUM_MTK_VENDOR_ATTRS_IBF_CTRL] = { |
| 231 | + [MTK_VENDOR_ATTR_IBF_CTRL_ENABLE] = { .type = NLA_U8 }, |
| 232 | +}; |
| 233 | + |
| 234 | +static struct nla_policy |
| 235 | +ibf_dump_policy[NUM_MTK_VENDOR_ATTRS_IBF_DUMP] = { |
| 236 | + [MTK_VENDOR_ATTR_IBF_DUMP_ENABLE] = { .type = NLA_U8 }, |
| 237 | +}; |
| 238 | + |
| 239 | |
| 240 | #define CSI_MAX_COUNT 256 |
| 241 | #define ETH_ALEN 6 |
| 242 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 243 | index 07af191..0a99078 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 244 | --- a/src/drivers/driver.h |
| 245 | +++ b/src/drivers/driver.h |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 246 | @@ -181,6 +181,11 @@ struct hostapd_channel_data { |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 247 | * 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] | 248 | */ |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 249 | u8 mu_onoff; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 250 | + |
| 251 | + /** |
| 252 | + * ibf_enable=<val> |
| 253 | + */ |
| 254 | + u8 ibf_enable; |
| 255 | }; |
| 256 | |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 257 | #define HE_MAC_CAPAB_0 0 |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 258 | @@ -5127,6 +5132,20 @@ struct wpa_driver_ops { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 259 | * |
| 260 | */ |
| 261 | int (*three_wire_ctrl)(void *priv, u8 three_wire_enable); |
| 262 | + |
| 263 | + /** |
| 264 | + * ibf_ctrl - ctrl disable/enable for ibf |
| 265 | + * @priv: Private driver interface data |
| 266 | + * |
| 267 | + */ |
| 268 | + int (*ibf_ctrl)(void *priv, u8 ibf_enable); |
| 269 | + |
| 270 | + /** |
| 271 | + * ibf_dump - dump ibf |
| 272 | + * @priv: Private driver interface data |
| 273 | + * |
| 274 | + */ |
| 275 | + int (*ibf_dump)(void *priv, u8 *ibf_enable); |
| 276 | }; |
| 277 | |
| 278 | /** |
| 279 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 280 | index cf1f2d0..a05e047 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 281 | --- a/src/drivers/driver_nl80211.c |
| 282 | +++ b/src/drivers/driver_nl80211.c |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 283 | @@ -14059,6 +14059,112 @@ static int nl80211_enable_three_wire(void *priv, const u8 three_wire_enable) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 284 | return ret; |
| 285 | } |
| 286 | |
| 287 | +static int nl80211_ibf_enable(void *priv, u8 ibf_enable) |
| 288 | +{ |
| 289 | + struct i802_bss *bss = priv; |
| 290 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 291 | + struct nl_msg *msg; |
| 292 | + struct nlattr *data; |
| 293 | + int ret; |
| 294 | + |
| 295 | + if (!drv->mtk_ibf_vendor_cmd_avail) { |
| 296 | + wpa_printf(MSG_INFO, |
| 297 | + "nl80211: Driver does not support setting ibf control"); |
| 298 | + return 0; |
| 299 | + } |
| 300 | + |
| 301 | + msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR); |
| 302 | + if (!msg) |
| 303 | + goto fail; |
| 304 | + |
| 305 | + if (nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 306 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL)) |
| 307 | + goto fail; |
| 308 | + |
| 309 | + data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA); |
| 310 | + if (!data) |
| 311 | + goto fail; |
| 312 | + |
| 313 | + nla_put_u8(msg, MTK_VENDOR_ATTR_IBF_CTRL_ENABLE, ibf_enable); |
| 314 | + |
| 315 | + nla_nest_end(msg, data); |
| 316 | + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 317 | + if (ret) { |
| 318 | + wpa_printf(MSG_ERROR, "Failed to set ibf_enable. ret=%d (%s)", ret, strerror(-ret)); |
| 319 | + } |
| 320 | + |
| 321 | + return ret; |
| 322 | + |
| 323 | +fail: |
| 324 | + nlmsg_free(msg); |
| 325 | + return -ENOBUFS; |
| 326 | +} |
| 327 | + |
| 328 | +static int ibf_dump_handler(struct nl_msg *msg, void *arg) |
| 329 | +{ |
| 330 | + u8 *ibf_enable = (u8 *) arg; |
| 331 | + struct nlattr *tb[NL80211_ATTR_MAX + 1]; |
| 332 | + struct nlattr *tb_vendor[MTK_VENDOR_ATTR_IBF_DUMP_MAX + 1]; |
| 333 | + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); |
| 334 | + struct nlattr *nl_vend, *attr; |
| 335 | + |
| 336 | + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), |
| 337 | + genlmsg_attrlen(gnlh, 0), NULL); |
| 338 | + |
| 339 | + nl_vend = tb[NL80211_ATTR_VENDOR_DATA]; |
| 340 | + if (!nl_vend) |
| 341 | + return NL_SKIP; |
| 342 | + |
| 343 | + nla_parse(tb_vendor, MTK_VENDOR_ATTR_IBF_DUMP_MAX, |
| 344 | + nla_data(nl_vend), nla_len(nl_vend), NULL); |
| 345 | + |
| 346 | + attr = tb_vendor[MTK_VENDOR_ATTR_IBF_DUMP_ENABLE]; |
| 347 | + if (!attr) { |
| 348 | + wpa_printf(MSG_ERROR, "nl80211: cannot find MTK_VENDOR_ATTR_IBF_DUMP_ENABLE"); |
| 349 | + return NL_SKIP; |
| 350 | + } |
| 351 | + |
| 352 | + *ibf_enable = nla_get_u8(attr); |
| 353 | + |
| 354 | + return NL_SKIP; |
| 355 | +} |
| 356 | + |
| 357 | +static int |
| 358 | +nl80211_ibf_dump(void *priv, u8 *ibf_enable) |
| 359 | +{ |
| 360 | + struct i802_bss *bss = priv; |
| 361 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 362 | + struct nl_msg *msg; |
| 363 | + struct nlattr *data; |
| 364 | + int ret; |
| 365 | + |
| 366 | + msg = nl80211_drv_msg(drv, NLM_F_DUMP, NL80211_CMD_VENDOR); |
| 367 | + if (!msg) |
| 368 | + goto fail; |
| 369 | + |
| 370 | + if (nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 371 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL)) |
| 372 | + goto fail; |
| 373 | + |
| 374 | + data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA | NLA_F_NESTED); |
| 375 | + if (!data) |
| 376 | + goto fail; |
| 377 | + |
| 378 | + nla_nest_end(msg, data); |
| 379 | + |
| 380 | + ret = send_and_recv_msgs(drv, msg, ibf_dump_handler, ibf_enable, NULL, NULL); |
| 381 | + |
| 382 | + if (ret) { |
| 383 | + wpa_printf(MSG_ERROR, "Failed to dump ibf_enable. ret=%d (%s)", ret, strerror(-ret)); |
| 384 | + } |
| 385 | + |
| 386 | + return ret; |
| 387 | + |
| 388 | +fail: |
| 389 | + nlmsg_free(msg); |
| 390 | + return -ENOBUFS; |
| 391 | +} |
| 392 | + |
| 393 | const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 394 | .name = "nl80211", |
| 395 | .desc = "Linux nl80211/cfg80211", |
developer | bd9fa1e | 2023-10-16 11:04:00 +0800 | [diff] [blame] | 396 | @@ -14221,4 +14327,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 397 | .configure_edcca_threshold = nl80211_configure_edcca_threshold, |
| 398 | .get_edcca = nl80211_get_edcca, |
| 399 | .three_wire_ctrl = nl80211_enable_three_wire, |
| 400 | + .ibf_ctrl = nl80211_ibf_enable, |
| 401 | + .ibf_dump = nl80211_ibf_dump, |
| 402 | }; |
| 403 | diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 404 | index 99af8b0..4e64e7d 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 405 | --- a/src/drivers/driver_nl80211.h |
| 406 | +++ b/src/drivers/driver_nl80211.h |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 407 | @@ -205,6 +205,7 @@ struct wpa_driver_nl80211_data { |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 408 | unsigned int mtk_edcca_vendor_cmd_avail:1; |
developer | 2c78ce7 | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 409 | unsigned int mtk_mu_vendor_cmd_avail:1; |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 410 | unsigned int mtk_3wire_vendor_cmd_avail:1; |
| 411 | + unsigned int mtk_ibf_vendor_cmd_avail:1; |
| 412 | |
| 413 | u64 vendor_scan_cookie; |
| 414 | u64 remain_on_chan_cookie; |
| 415 | diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 416 | index 3ff47f3..7ad15ba 100644 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 417 | --- a/src/drivers/driver_nl80211_capa.c |
| 418 | +++ b/src/drivers/driver_nl80211_capa.c |
developer | 9a58788 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 419 | @@ -1119,6 +1119,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 420 | case MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL : |
| 421 | drv->mtk_3wire_vendor_cmd_avail = 1; |
| 422 | break; |
| 423 | + case MTK_NL80211_VENDOR_SUBCMD_IBF_CTRL: |
| 424 | + drv->mtk_ibf_vendor_cmd_avail = 1; |
| 425 | + break; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | -- |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 430 | 2.18.0 |
developer | 092b55c | 2023-01-18 18:20:58 +0800 | [diff] [blame] | 431 | |