developer | bdc8eab | 2022-11-21 11:36:55 +0800 | [diff] [blame] | 1 | From e177f5069ff7e8f024676cf9d0e4af135cfea95b Mon Sep 17 00:00:00 2001 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 2 | From: mtk27835 <shurong.wen@mediatek.com> |
| 3 | Date: Wed, 7 Sep 2022 14:41:51 -0700 |
developer | bdc8eab | 2022-11-21 11:36:55 +0800 | [diff] [blame] | 4 | Subject: [PATCH 99915/99917] Add hostapd iBF control |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: mtk27835 <shurong.wen@mediatek.com> |
| 7 | --- |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 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 + |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 21 | 13 files changed, 224 insertions(+), 1 deletion(-) |
| 22 | |
| 23 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
developer | bdc8eab | 2022-11-21 11:36:55 +0800 | [diff] [blame] | 24 | index 18b372a..d9d882c 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 25 | --- a/hostapd/config_file.c |
| 26 | +++ b/hostapd/config_file.c |
developer | bdc8eab | 2022-11-21 11:36:55 +0800 | [diff] [blame] | 27 | @@ -4798,6 +4798,9 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 38 | index 5f71aee..c881d37 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 39 | --- a/hostapd/ctrl_iface.c |
| 40 | +++ b/hostapd/ctrl_iface.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 41 | @@ -3498,6 +3498,30 @@ hostapd_ctrl_iface_get_hemu(struct hostapd_data *hapd, char *buf, |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 72 | @@ -4055,6 +4079,8 @@ static int hostapd_ctrl_iface_receive_process(struct hostapd_data *hapd, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 73 | reply_size); |
| 74 | } else if (os_strncmp(buf, "GET_HEMU", 8) == 0) { |
| 75 | reply_len = hostapd_ctrl_iface_get_hemu(hapd, reply, reply_size); |
| 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 | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 82 | index 0d36477..c2a123a 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 83 | --- a/hostapd/hostapd_cli.c |
| 84 | +++ b/hostapd/hostapd_cli.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 85 | @@ -1586,6 +1586,13 @@ static int hostapd_cli_cmd_driver(struct wpa_ctrl *ctrl, int argc, char *argv[]) |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 99 | @@ -1787,6 +1794,8 @@ static const struct hostapd_cli_cmd hostapd_cli_commands[] = { |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 109 | index 9249a6b..7a96cb8 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 110 | --- a/src/ap/ap_config.c |
| 111 | +++ b/src/ap/ap_config.c |
| 112 | @@ -298,6 +298,7 @@ struct hostapd_config * hostapd_config_defaults(void) |
| 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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 121 | index 71cf515..44a0e7e 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 122 | --- a/src/ap/ap_config.h |
| 123 | +++ b/src/ap/ap_config.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 124 | @@ -1158,6 +1158,7 @@ struct hostapd_config { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 125 | s8 edcca_compensation; |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 126 | int *edcca_threshold; |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 127 | u8 three_wire_enable; |
| 128 | + u8 ibf_enable; |
| 129 | }; |
| 130 | |
| 131 | enum three_wire_mode { |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 132 | @@ -1198,6 +1199,7 @@ enum mtk_vendor_attr_edcca_ctrl_mode { |
| 133 | #define EDCCA_MIN_CONFIG_THRES -126 |
| 134 | #define EDCCA_MAX_CONFIG_THRES 0 |
| 135 | |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 136 | +#define IBF_DEFAULT_ENABLE 0 |
| 137 | |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 138 | static inline enum oper_chan_width |
| 139 | hostapd_get_oper_chwidth(struct hostapd_config *conf) |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 140 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 141 | index a1d83e4..60ae825 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 142 | --- a/src/ap/ap_drv_ops.c |
| 143 | +++ b/src/ap/ap_drv_ops.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 144 | @@ -1064,3 +1064,17 @@ int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd) |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 164 | index 5ba6297..ab9aedc 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 165 | --- a/src/ap/ap_drv_ops.h |
| 166 | +++ b/src/ap/ap_drv_ops.h |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 167 | @@ -145,6 +145,8 @@ int hostapd_drv_get_edcca(struct hostapd_data *hapd, const u8 mode, u8 *value); |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 168 | int hostapd_drv_hemu_ctrl(struct hostapd_data *hapd); |
| 169 | int hostapd_drv_hemu_dump(struct hostapd_data *hapd, u8 *hemu_onoff); |
| 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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 177 | index f9dabdf..e44b73d 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 178 | --- a/src/ap/hostapd.c |
| 179 | +++ b/src/ap/hostapd.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 180 | @@ -2305,6 +2305,8 @@ dfs_offload: |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 190 | index ee5a4f4..4050cf8 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +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 { |
| 194 | MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 203 | @@ -204,6 +205,38 @@ enum mtk_vendor_attr_hemu_ctrl { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 204 | NUM_MTK_VENDOR_ATTRS_HEMU_CTRL - 1 |
| 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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 243 | index 9ca19af..71ded61 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 244 | --- a/src/drivers/driver.h |
| 245 | +++ b/src/drivers/driver.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 246 | @@ -1628,6 +1628,11 @@ struct wpa_driver_ap_params { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 247 | * hemu onoff=<val> (bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0)) |
| 248 | */ |
| 249 | u8 hemu_onoff; |
| 250 | + |
| 251 | + /** |
| 252 | + * ibf_enable=<val> |
| 253 | + */ |
| 254 | + u8 ibf_enable; |
| 255 | }; |
| 256 | |
| 257 | struct wpa_driver_mesh_bss_params { |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 258 | @@ -4701,6 +4706,20 @@ struct wpa_driver_ops { |
developer | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 259 | * |
| 260 | */ |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 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 | bdc8eab | 2022-11-21 11:36:55 +0800 | [diff] [blame] | 280 | index 2bb8cc2..e974f85 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 281 | --- a/src/drivers/driver_nl80211.c |
| 282 | +++ b/src/drivers/driver_nl80211.c |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 283 | @@ -12670,6 +12670,112 @@ static int nl80211_enable_three_wire(void *priv, const u8 three_wire_enable) |
developer | 20126ad | 2022-09-12 14:42:56 +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 | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 396 | @@ -12822,4 +12928,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 397 | .configure_edcca_threshold = nl80211_configure_edcca_threshold, |
developer | 9bc8ec1 | 2022-11-18 16:01:14 +0800 | [diff] [blame] | 398 | .get_edcca = nl80211_get_edcca, |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 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 | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 404 | index 9fe7811..607592c 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 405 | --- a/src/drivers/driver_nl80211.h |
| 406 | +++ b/src/drivers/driver_nl80211.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 407 | @@ -184,6 +184,7 @@ struct wpa_driver_nl80211_data { |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 408 | unsigned int mtk_edcca_vendor_cmd_avail:1; |
| 409 | unsigned int mtk_hemu_vendor_cmd_avail:1; |
| 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 | 29344f1 | 2022-10-17 12:01:44 +0800 | [diff] [blame] | 416 | index 04bc54e..9ecc0ff 100644 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 417 | --- a/src/drivers/driver_nl80211_capa.c |
| 418 | +++ b/src/drivers/driver_nl80211_capa.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 419 | @@ -1062,6 +1062,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) |
developer | 20126ad | 2022-09-12 14:42:56 +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 | bdc8eab | 2022-11-21 11:36:55 +0800 | [diff] [blame] | 430 | 2.36.1 |
developer | 20126ad | 2022-09-12 14:42:56 +0800 | [diff] [blame] | 431 | |