developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 1 | From 476f2fe6698c32ddaca8e5f8c564b499f5dc4772 Mon Sep 17 00:00:00 2001 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 2 | From: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 3 | Date: Fri, 2 Sep 2022 01:03:23 +0800 |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 4 | Subject: [PATCH 99915/99916] Add three wire PTA ctrl hostapd vendor command |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 5 | |
| 6 | Signed-off-by: StanleyYP Wang <StanleyYP.Wang@mediatek.com> |
| 7 | --- |
| 8 | hostapd/config_file.c | 4 ++++ |
| 9 | src/ap/ap_config.c | 1 + |
| 10 | src/ap/ap_config.h | 13 ++++++++++++ |
| 11 | src/ap/ap_drv_ops.c | 11 +++++++++++ |
| 12 | src/ap/ap_drv_ops.h | 1 + |
| 13 | src/ap/hostapd.c | 2 ++ |
| 14 | src/common/mtk_vendor.h | 16 +++++++++++++++ |
| 15 | src/drivers/driver.h | 1 + |
| 16 | src/drivers/driver_nl80211.c | 33 +++++++++++++++++++++++++++++++ |
| 17 | src/drivers/driver_nl80211.h | 1 + |
| 18 | src/drivers/driver_nl80211_capa.c | 3 +++ |
| 19 | 11 files changed, 86 insertions(+) |
| 20 | |
| 21 | diff --git a/hostapd/config_file.c b/hostapd/config_file.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 22 | index 0be53044a..0bf8b6c72 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 23 | --- a/hostapd/config_file.c |
| 24 | +++ b/hostapd/config_file.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 25 | @@ -4782,6 +4782,10 @@ static int hostapd_config_fill(struct hostapd_config *conf, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 26 | return 1; |
| 27 | } |
| 28 | conf->edcca_compensation = (s8) val; |
| 29 | + } else if (os_strcmp(buf, "three_wire_enable") == 0) { |
| 30 | + u8 en = atoi(pos); |
| 31 | + |
| 32 | + conf->three_wire_enable = en; |
| 33 | } else { |
| 34 | wpa_printf(MSG_ERROR, |
| 35 | "Line %d: unknown configuration item '%s'", |
| 36 | diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 37 | index 8ce4d9a16..2d720095a 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 38 | --- a/src/ap/ap_config.c |
| 39 | +++ b/src/ap/ap_config.c |
| 40 | @@ -297,6 +297,7 @@ struct hostapd_config * hostapd_config_defaults(void) |
| 41 | |
| 42 | conf->edcca_enable = EDCCA_MODE_AUTO; |
| 43 | conf->edcca_compensation = EDCCA_DEFAULT_COMPENSATION; |
| 44 | + conf->three_wire_enable = THREE_WIRE_MODE_DISABLE; |
| 45 | |
| 46 | return conf; |
| 47 | } |
| 48 | diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 49 | index 4462f29b7..8b9e8873d 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 50 | --- a/src/ap/ap_config.h |
| 51 | +++ b/src/ap/ap_config.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 52 | @@ -1156,6 +1156,19 @@ struct hostapd_config { |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 53 | unsigned int ch_switch_eht_config; |
| 54 | u8 edcca_enable; |
| 55 | s8 edcca_compensation; |
| 56 | + u8 three_wire_enable; |
| 57 | +}; |
| 58 | + |
| 59 | +enum three_wire_mode { |
| 60 | + THREE_WIRE_MODE_DISABLE, |
| 61 | + THREE_WIRE_MODE_EXT0_ENABLE, |
| 62 | + THREE_WIRE_MODE_EXT1_ENABLE, |
| 63 | + THREE_WIRE_MODE_ALL_ENABLE, |
| 64 | + |
| 65 | + /* keep last */ |
| 66 | + NUM_THREE_WIRE_MODE, |
| 67 | + THREE_WIRE_MODE_MAX = |
| 68 | + NUM_THREE_WIRE_MODE - 1 |
| 69 | }; |
| 70 | |
| 71 | enum edcca_mode { |
| 72 | diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 73 | index 55452323d..77d5f8990 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 74 | --- a/src/ap/ap_drv_ops.c |
| 75 | +++ b/src/ap/ap_drv_ops.c |
| 76 | @@ -1038,3 +1038,14 @@ int hostapd_drv_hemu_dump(struct hostapd_data *hapd, u8 *hemu_onoff) |
| 77 | return 0; |
| 78 | return hapd->driver->hemu_dump(hapd->drv_priv, hemu_onoff); |
| 79 | } |
| 80 | + |
| 81 | +int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd) |
| 82 | +{ |
| 83 | + if (!hapd->driver || !hapd->driver->three_wire_ctrl) |
| 84 | + return 0; |
| 85 | + if (hapd->iconf->three_wire_enable > THREE_WIRE_MODE_MAX) { |
| 86 | + wpa_printf(MSG_INFO, "Invalid value for three wire enable\n"); |
| 87 | + return 0; |
| 88 | + } |
| 89 | + return hapd->driver->three_wire_ctrl(hapd->drv_priv, hapd->iconf->three_wire_enable); |
| 90 | +} |
| 91 | diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 92 | index 5bcb2251a..0a8bf0c7e 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 93 | --- a/src/ap/ap_drv_ops.h |
| 94 | +++ b/src/ap/ap_drv_ops.h |
| 95 | @@ -141,6 +141,7 @@ int hostapd_drv_dpp_listen(struct hostapd_data *hapd, bool enable); |
| 96 | int hostapd_drv_configure_edcca_threshold(struct hostapd_data *hapd); |
| 97 | int hostapd_drv_hemu_ctrl(struct hostapd_data *hapd); |
| 98 | int hostapd_drv_hemu_dump(struct hostapd_data *hapd, u8 *hemu_onoff); |
| 99 | +int hostapd_drv_three_wire_ctrl(struct hostapd_data *hapd); |
| 100 | |
| 101 | #include "drivers/driver.h" |
| 102 | |
| 103 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 104 | index 0f3691ba3..32b75dca7 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 105 | --- a/src/ap/hostapd.c |
| 106 | +++ b/src/ap/hostapd.c |
| 107 | @@ -2299,6 +2299,8 @@ dfs_offload: |
| 108 | goto fail; |
| 109 | if (hostapd_drv_hemu_ctrl(hapd) < 0) |
| 110 | goto fail; |
| 111 | + if (hostapd_drv_three_wire_ctrl(hapd) < 0) |
| 112 | + goto fail; |
| 113 | |
| 114 | wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", |
| 115 | iface->bss[0]->conf->iface); |
| 116 | diff --git a/src/common/mtk_vendor.h b/src/common/mtk_vendor.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 117 | index 5c8f1792e..99a4d7f94 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 118 | --- a/src/common/mtk_vendor.h |
| 119 | +++ b/src/common/mtk_vendor.h |
| 120 | @@ -13,6 +13,7 @@ enum mtk_nl80211_vendor_subcmds { |
| 121 | MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL = 0xc5, |
| 122 | MTK_NL80211_VENDOR_SUBCMD_PHY_CAPA_CTRL= 0xc6, |
| 123 | MTK_NL80211_VENDOR_SUBCMD_EDCCA_CTRL = 0xc7, |
| 124 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL = 0xc8 |
| 125 | }; |
| 126 | |
| 127 | enum mtk_vendor_attr_edcca_ctrl { |
| 128 | @@ -48,6 +49,21 @@ static struct nla_policy edcca_ctrl_policy[NUM_MTK_VENDOR_ATTRS_EDCCA_CTRL] = { |
| 129 | [MTK_VENDOR_ATTR_EDCCA_CTRL_COMPENSATE] = { .type = NLA_U8 }, |
| 130 | }; |
| 131 | |
| 132 | +enum mtk_vendor_attr_3wire_ctrl { |
| 133 | + MTK_VENDOR_ATTR_3WIRE_CTRL_UNSPEC, |
| 134 | + |
| 135 | + MTK_VENDOR_ATTR_3WIRE_CTRL_MODE, |
| 136 | + |
| 137 | + /* keep last */ |
| 138 | + NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL, |
| 139 | + MTK_VENDOR_ATTR_3WIRE_CTRL_MAX = |
| 140 | + NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL - 1 |
| 141 | +}; |
| 142 | + |
| 143 | +static struct nla_policy three_wire_ctrl_policy[NUM_MTK_VENDOR_ATTRS_3WIRE_CTRL] = { |
| 144 | + [MTK_VENDOR_ATTR_3WIRE_CTRL_MODE] = {.type = NLA_U8 }, |
| 145 | +}; |
| 146 | + |
| 147 | enum mtk_vendor_attr_csi_ctrl { |
| 148 | MTK_VENDOR_ATTR_CSI_CTRL_UNSPEC, |
| 149 | |
| 150 | diff --git a/src/drivers/driver.h b/src/drivers/driver.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 151 | index 88b371d61..a137ffc14 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 152 | --- a/src/drivers/driver.h |
| 153 | +++ b/src/drivers/driver.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 154 | @@ -4691,6 +4691,7 @@ struct wpa_driver_ops { |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 155 | */ |
| 156 | int (*hemu_ctrl)(void *priv, u8 hemu_onoff); |
| 157 | int (*hemu_dump)(void *priv, u8 *hemu_onoff); |
| 158 | + int (*three_wire_ctrl)(void *priv, u8 three_wire_enable); |
| 159 | }; |
| 160 | |
| 161 | /** |
| 162 | diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 163 | index b06de0687..03babd8a2 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 164 | --- a/src/drivers/driver_nl80211.c |
| 165 | +++ b/src/drivers/driver_nl80211.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 166 | @@ -12516,6 +12516,38 @@ static int nl80211_configure_edcca_threshold(void *priv, |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 167 | return ret; |
| 168 | } |
| 169 | |
| 170 | +static int nl80211_enable_three_wire(void *priv, const u8 three_wire_enable) |
| 171 | +{ |
| 172 | + struct i802_bss *bss = priv; |
| 173 | + struct wpa_driver_nl80211_data *drv = bss->drv; |
| 174 | + /* Prepare nl80211 cmd */ |
| 175 | + struct nl_msg *msg; |
| 176 | + struct nlattr *data; |
| 177 | + int ret; |
| 178 | + |
| 179 | + if (!drv->mtk_3wire_vendor_cmd_avail) { |
| 180 | + wpa_printf(MSG_INFO, |
| 181 | + "nl80211: Driver does not support setting three wire control"); |
| 182 | + return 0; |
| 183 | + } |
| 184 | + |
| 185 | + if (!(msg = nl80211_drv_msg(drv, 0, NL80211_CMD_VENDOR)) || |
| 186 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_ID, OUI_MTK) || |
| 187 | + nla_put_u32(msg, NL80211_ATTR_VENDOR_SUBCMD, |
| 188 | + MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL) || |
| 189 | + !(data = nla_nest_start(msg, NL80211_ATTR_VENDOR_DATA)) || |
| 190 | + nla_put_u8(msg, MTK_VENDOR_ATTR_3WIRE_CTRL_MODE, three_wire_enable)) { |
| 191 | + nlmsg_free(msg); |
| 192 | + return -ENOBUFS; |
| 193 | + } |
| 194 | + nla_nest_end(msg, data); |
| 195 | + ret = send_and_recv_msgs(drv, msg, NULL, NULL, NULL, NULL); |
| 196 | + if (ret) { |
| 197 | + wpa_printf(MSG_ERROR, "Failed to enable three wire. ret=%d (%s) ", |
| 198 | + ret, strerror(-ret)); |
| 199 | + } |
| 200 | + return ret; |
| 201 | +} |
| 202 | |
| 203 | const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
| 204 | .name = "nl80211", |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 205 | @@ -12666,4 +12698,5 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 206 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 207 | /* Need ifdef CONFIG_DRIVER_NL80211_MTK */ |
| 208 | .configure_edcca_threshold = nl80211_configure_edcca_threshold, |
| 209 | + .three_wire_ctrl = nl80211_enable_three_wire, |
| 210 | }; |
| 211 | diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 212 | index 57f02497e..9fe7811b9 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 213 | --- a/src/drivers/driver_nl80211.h |
| 214 | +++ b/src/drivers/driver_nl80211.h |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 215 | @@ -183,6 +183,7 @@ struct wpa_driver_nl80211_data { |
| 216 | unsigned int uses_6ghz:1; |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 217 | unsigned int mtk_edcca_vendor_cmd_avail:1; |
| 218 | unsigned int mtk_hemu_vendor_cmd_avail:1; |
| 219 | + unsigned int mtk_3wire_vendor_cmd_avail:1; |
| 220 | |
| 221 | u64 vendor_scan_cookie; |
| 222 | u64 remain_on_chan_cookie; |
| 223 | diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 224 | index cc146d9fc..04bc54e77 100644 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 225 | --- a/src/drivers/driver_nl80211_capa.c |
| 226 | +++ b/src/drivers/driver_nl80211_capa.c |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 227 | @@ -1059,6 +1059,9 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 228 | case MTK_NL80211_VENDOR_SUBCMD_HEMU_CTRL : |
| 229 | drv->mtk_hemu_vendor_cmd_avail = 1; |
| 230 | break; |
| 231 | + case MTK_NL80211_VENDOR_SUBCMD_3WIRE_CTRL : |
| 232 | + drv->mtk_3wire_vendor_cmd_avail = 1; |
| 233 | + break; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | -- |
developer | 198585d | 2022-09-22 17:12:54 +0800 | [diff] [blame] | 238 | 2.25.1 |
developer | 27b5525 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 239 | |