developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 1 | From 390f9431f5a6f8001f6822a3aea4c5e08743806d Mon Sep 17 00:00:00 2001 |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 2 | From: TomLiu <tomml.liu@mediatek.com> |
| 3 | Date: Thu, 14 Jul 2022 13:43:06 -0700 |
| 4 | Subject: [PATCH-920]Add hemu hostapd vendor command |
| 5 | |
| 6 | --- |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 7 | hostapd/config_file.c | 9 ++++++++ |
| 8 | src/ap/ap_config.h | 1 + |
| 9 | src/ap/ap_drv_ops.c | 7 ++++++ |
| 10 | src/ap/beacon.c | 2 ++ |
| 11 | src/common/mtk_vendor.h | 13 +++++++++++ |
| 12 | src/drivers/driver.h | 12 +++++++++++ |
| 13 | src/drivers/driver_nl80211.c | 36 ++++++++++++++++++++++++++++++- |
| 14 | src/drivers/driver_nl80211.h | 1 + |
| 15 | src/drivers/driver_nl80211_capa.c | 3 +++ |
| 16 | 9 files changed, 83 insertions(+), 1 deletion(-) |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 17 | |
| 18 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
| 19 | index 19a2fd5..85d58cd 100644 |
| 20 | --- a/hostapd/config_file.c |
| 21 | +++ b/hostapd/config_file.c |
| 22 | @@ -3655,6 +3655,15 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
| 23 | return 1; |
| 24 | } |
| 25 | bss->unsol_bcast_probe_resp_interval = val; |
| 26 | + } else if (os_strcmp(buf, "hemu_onoff") == 0) { |
| 27 | + int val = atoi(pos); |
| 28 | + if (val < 0 || val > 15) { |
| 29 | + wpa_printf(MSG_ERROR, |
| 30 | + "Line %d: invalid hemu_onoff value", |
| 31 | + line); |
| 32 | + return 1; |
| 33 | + } |
| 34 | + conf->hemu_onoff = val; |
| 35 | #endif /* CONFIG_IEEE80211AX */ |
| 36 | } else if (os_strcmp(buf, "max_listen_interval") == 0) { |
| 37 | bss->max_listen_interval = atoi(pos); |
| 38 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
| 39 | index 9bbe7eb..737cc2f 100644 |
| 40 | --- a/src/ap/ap_config.h |
| 41 | +++ b/src/ap/ap_config.h |
| 42 | @@ -1111,6 +1111,7 @@ struct hostapd_config { |
| 43 | u8 he_6ghz_rx_ant_pat; |
| 44 | u8 he_6ghz_tx_ant_pat; |
| 45 | u8 he_6ghz_reg_pwr_type; |
| 46 | + u8 hemu_onoff; |
| 47 | #endif /* CONFIG_IEEE80211AX */ |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 48 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 49 | /* VHT enable/disable config from CHAN_SWITCH */ |
| 50 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
| 51 | index b8b98e4..517d2a5 100644 |
| 52 | --- a/src/ap/ap_drv_ops.c |
| 53 | +++ b/src/ap/ap_drv_ops.c |
| 54 | @@ -1021,3 +1021,10 @@ int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd) |
| 55 | hapd->iconf->edcca_enable, |
| 56 | hapd->iconf->edcca_compensation); |
| 57 | } |
| 58 | + |
| 59 | +int hostapd_drv_hemu_ctrl(struct hostapd_data *hapd) |
| 60 | +{ |
| 61 | + if (!hapd->driver || !hapd->driver->hemu_ctrl) |
| 62 | + return 0; |
| 63 | + return hapd->driver->hemu_ctrl(hapd->drv_priv, hapd->iconf->hemu_onoff); |
| 64 | +} |
| 65 | diff --git a/src/ap/beacon.c b/src/ap/beacon.c |
| 66 | index 575c92f..7170711 100644 |
| 67 | --- a/src/ap/beacon.c |
| 68 | +++ b/src/ap/beacon.c |
| 69 | @@ -1976,6 +1976,8 @@ static int __ieee802_11_set_beacon(struct hostapd_data *hapd) |
| 70 | params.freq = &freq; |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 71 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 72 | res = hostapd_drv_set_ap(hapd, ¶ms); |
| 73 | + if (hostapd_drv_hemu_ctrl(hapd) < 0) |
| 74 | + goto fail; |
| 75 | hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); |
| 76 | if (res) |
| 77 | wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); |
| 78 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
| 79 | index 528387f..6a0e60a 100644 |
| 80 | --- a/src/common/mtk_vendor.h |
| 81 | +++ b/src/common/mtk_vendor.h |
| 82 | @@ -10,6 +10,8 @@ enum mtk_nl80211_vendor_subcmds { |
| 83 | MTK_NL80211_VENDOR_SUBCMD_CSI_CTRL = 0xc2, |
| 84 | MTK_NL80211_VENDOR_SUBCMD_RFEATURE_CTRL = 0xc3, |
| 85 | MTK_NL80211_VENDOR_SUBCMD_WIRELESS_CTRL = 0xc4, |
| 86 | + MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 87 | + MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL= 0xc6, |
| 88 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 89 | }; |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 90 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 91 | @@ -167,6 +169,17 @@ enum mtk_vendor_attr_rfeature_ctrl { |
| 92 | NUM_MTK_VENDOR_ATTRS_RFEATURE_CTRL - 1 |
| 93 | }; |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 94 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 95 | +enum mtk_vendor_attr_hemu_ctrl { |
| 96 | + MTK_VENDOR_ATTR_HEMU_CTRL_UNSPEC, |
| 97 | + |
| 98 | + MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF, |
| 99 | + |
| 100 | + /* keep last */ |
| 101 | + NUM_MTK_VENDOR_ATTRS_HEMU_CTRL, |
| 102 | + MTK_VENDOR_ATTR_HEMU_CTRL_MAX = |
| 103 | + NUM_MTK_VENDOR_ATTRS_HEMU_CTRL - 1 |
| 104 | +}; |
| 105 | + |
| 106 | #define CSI_MAX_COUNT 256 |
| 107 | #define ETH_ALEN 6 |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 108 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 109 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
| 110 | index fc96fef..298dbf3 100644 |
| 111 | --- a/src/drivers/driver.h |
| 112 | +++ b/src/drivers/driver.h |
| 113 | @@ -1622,6 +1622,11 @@ struct wpa_driver_ap_params { |
| 114 | * Unsolicited broadcast Probe Response template length |
| 115 | */ |
| 116 | size_t unsol_bcast_probe_resp_tmpl_len; |
| 117 | + |
| 118 | + /** |
| 119 | + * hemu onoff=<val> (bitmap- UL MU-MIMO(bit3), DL MU-MIMO(bit2), UL OFDMA(bit1), DL OFDMA(bit0)) |
| 120 | + */ |
| 121 | + u8 hemu_onoff; |
| 122 | }; |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 123 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 124 | struct wpa_driver_mesh_bss_params { |
| 125 | @@ -4675,6 +4680,13 @@ struct wpa_driver_ops { |
| 126 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 127 | int (*configure_edcca_threshold)(void *priv, const u8 edcca_enable, |
| 128 | const s8 edcca_compensation); |
| 129 | + |
| 130 | + /** |
| 131 | + * hemu_ctrl - ctrl on off for UL/DL MURU |
| 132 | + * @priv: Private driver interface data |
| 133 | + * |
| 134 | + */ |
| 135 | + int (*hemu_ctrl)(void *priv, u8 hemu_onoff); |
| 136 | }; |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 137 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 138 | /** |
| 139 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 140 | index b1e7b16..089c24a 100644 |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 141 | --- a/src/drivers/driver_nl80211.c |
| 142 | +++ b/src/drivers/driver_nl80211.c |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 143 | @@ -12287,6 +12287,39 @@ fail: |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 144 | } |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 145 | |
| 146 | |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 147 | +#ifdef CONFIG_IEEE80211AX |
| 148 | +static int nl80211_hemu_muruonoff(void *priv, u8 hemu_onoff) |
| 149 | +{ |
| 150 | + struct i802_bss *bss = priv; |
| 151 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 152 | + struct nl_msg *msg; |
| 153 | + struct nlattr *data; |
| 154 | + int ret; |
| 155 | + |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 156 | + if (!drv->mtk_hemu_vendor_cmd_avail) { |
| 157 | + wpa_printf(MSG_INFO, |
| 158 | + "nl80211: Driver does not support setting hemu control"); |
| 159 | + return 0; |
| 160 | + } |
| 161 | + |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 162 | + if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || |
| 163 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 164 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL) || |
| 165 | + !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) || |
| 166 | + nla_put_u8(msg, MTK_VENDOR_ATTR_HEMU_CTRL_ONOFF, hemu_onoff)) { |
| 167 | + nlmsg_free(msg); |
| 168 | + return -ENOBUFS; |
| 169 | + } |
| 170 | + nla_nest_end(msg, data); |
| 171 | + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 172 | + if(ret){ |
| 173 | + wpa_printf(MSG_ERROR, "Failed to set hemu_onoff. ret=%d (%s)", ret, strerror(-ret)); |
| 174 | + } |
| 175 | + return ret; |
| 176 | +} |
| 177 | +#endif /* CONFIG_IEEE80211AX */ |
| 178 | + |
| 179 | + |
| 180 | #ifdef CONFIG_DPP |
| 181 | static int nl80211_dpp_listen(void *priv, bool enable) |
| 182 | { |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 183 | @@ -12531,6 +12564,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 184 | .update_connect_params = nl80211_update_connection_params, |
| 185 | .send_external_auth_status = nl80211_send_external_auth_status, |
| 186 | .set_4addr_mode = nl80211_set_4addr_mode, |
| 187 | + .hemu_ctrl = nl80211_hemu_muruonoff, |
| 188 | #ifdef CONFIG_DPP |
| 189 | .dpp_listen = nl80211_dpp_listen, |
| 190 | #endif /* CONFIG_DPP */ |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 191 | diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h |
| 192 | index b677907..62d9696 100644 |
| 193 | --- a/src/drivers/driver_nl80211.h |
| 194 | +++ b/src/drivers/driver_nl80211.h |
| 195 | @@ -181,6 +181,7 @@ struct wpa_driver_nl80211_data { |
| 196 | unsigned int qca_do_acs:1; |
| 197 | unsigned int brcm_do_acs:1; |
| 198 | unsigned int mtk_edcca_vendor_cmd_avail:1; |
| 199 | + unsigned int mtk_hemu_vendor_cmd_avail:1; |
developer | 4d30ebf | 2022-07-07 10:33:21 -0700 | [diff] [blame] | 200 | |
developer | c823951 | 2022-07-21 17:43:53 -0700 | [diff] [blame] | 201 | u64 vendor_scan_cookie; |
| 202 | u64 remain_on_chan_cookie; |
| 203 | diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c |
| 204 | index 6c743bf..b5cd2c5 100644 |
| 205 | --- a/src/drivers/driver_nl80211_capa.c |
| 206 | +++ b/src/drivers/driver_nl80211_capa.c |
| 207 | @@ -1050,6 +1050,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) |
| 208 | case MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL : |
| 209 | drv->mtk_edcca_vendor_cmd_avail = 1; |
| 210 | break; |
| 211 | + case MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL : |
| 212 | + drv->mtk_hemu_vendor_cmd_avail = 1; |
| 213 | + break; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | -- |
| 218 | 2.32.0 |