From 205c35ceff734cbce7d9e8da4bc8b33baec0ffa1 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 27 Feb 2021 17:57:08 +0200 Subject: [PATCH] nl80211: Allow compilation with both vendor do_acs() handlers Use a helper function as the do_acs() callback to allow builds to pull in all the vendor specific operations into a single binary. Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211.c | 36 ++++++++++++++++++++++--------- src/drivers/driver_nl80211.h | 2 ++ src/drivers/driver_nl80211_capa.c | 3 +++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 59052a94e..54adae44b 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -10926,10 +10926,9 @@ static int add_acs_freq_list(struct nl_msg *msg, const int *freq_list) } -static int wpa_driver_do_acs(void *priv, struct drv_acs_params *params) +static int nl80211_qca_do_acs(struct wpa_driver_nl80211_data *drv, + struct drv_acs_params *params) { - struct i802_bss *bss = priv; - struct wpa_driver_nl80211_data *drv = bss->drv; struct nl_msg *msg; struct nlattr *data; int ret; @@ -11607,10 +11606,9 @@ fail: #ifdef CONFIG_DRIVER_NL80211_BRCM -static int wpa_driver_do_broadcom_acs(void *priv, struct drv_acs_params *params) +static int wpa_driver_do_broadcom_acs(struct wpa_driver_nl80211_data *drv, + struct drv_acs_params *params) { - struct i802_bss *bss = priv; - struct wpa_driver_nl80211_data *drv = bss->drv; struct nl_msg *msg; struct nlattr *data; int freq_list_len; @@ -11660,6 +11658,27 @@ fail: #endif /* CONFIG_DRIVER_NL80211_BRCM */ +static int nl80211_do_acs(void *priv, struct drv_acs_params *params) +{ +#if defined(CONFIG_DRIVER_NL80211_QCA) || defined(CONFIG_DRIVER_NL80211_BRCM) + struct i802_bss *bss = priv; + struct wpa_driver_nl80211_data *drv = bss->drv; +#endif /* CONFIG_DRIVER_NL80211_QCA || CONFIG_DRIVER_NL80211_BRCM */ + +#ifdef CONFIG_DRIVER_NL80211_QCA + if (drv->qca_do_acs) + return nl80211_qca_do_acs(drv, params); +#endif /* CONFIG_DRIVER_NL80211_QCA */ + +#ifdef CONFIG_DRIVER_NL80211_BRCM + if (drv->brcm_do_acs) + return wpa_driver_do_broadcom_acs(drv, params); +#endif /* CONFIG_DRIVER_NL80211_BRCM */ + + return -1; +} + + static int nl80211_write_to_file(const char *name, unsigned int val) { int fd, len; @@ -12090,7 +12109,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { #ifdef CONFIG_DRIVER_NL80211_QCA .roaming = nl80211_roaming, .disable_fils = nl80211_disable_fils, - .do_acs = wpa_driver_do_acs, .set_band = nl80211_set_band, .get_pref_freq_list = nl80211_get_pref_freq_list, .set_prob_oper_freq = nl80211_set_prob_oper_freq, @@ -12105,9 +12123,7 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = { .set_bssid_tmp_disallow = nl80211_set_bssid_tmp_disallow, .add_sta_node = nl80211_add_sta_node, #endif /* CONFIG_DRIVER_NL80211_QCA */ -#ifdef CONFIG_DRIVER_NL80211_BRCM - .do_acs = wpa_driver_do_broadcom_acs, -#endif /* CONFIG_DRIVER_NL80211_BRCM */ + .do_acs = nl80211_do_acs, .configure_data_frame_filters = nl80211_configure_data_frame_filters, .get_ext_capab = nl80211_get_ext_capab, .update_connect_params = nl80211_update_connection_params, diff --git a/src/drivers/driver_nl80211.h b/src/drivers/driver_nl80211.h index 940d82c87..0de1c5f7c 100644 --- a/src/drivers/driver_nl80211.h +++ b/src/drivers/driver_nl80211.h @@ -177,6 +177,8 @@ struct wpa_driver_nl80211_data { unsigned int get_sta_info_vendor_cmd_avail:1; unsigned int fils_discovery:1; unsigned int unsol_bcast_probe_resp:1; + unsigned int qca_do_acs:1; + unsigned int brcm_do_acs:1; u64 vendor_scan_cookie; u64 remain_on_chan_cookie; diff --git a/src/drivers/driver_nl80211_capa.c b/src/drivers/driver_nl80211_capa.c index 7dac62b4e..d3d43d48a 100644 --- a/src/drivers/driver_nl80211_capa.c +++ b/src/drivers/driver_nl80211_capa.c @@ -996,6 +996,7 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) case QCA_NL80211_VENDOR_SUBCMD_DO_ACS: drv->capa.flags |= WPA_DRIVER_FLAGS_ACS_OFFLOAD; + drv->qca_do_acs = 1; break; case QCA_NL80211_VENDOR_SUBCMD_SETBAND: drv->setband_vendor_cmd_avail = 1; @@ -1028,6 +1029,8 @@ static int wiphy_info_handler(struct nl_msg *msg, void *arg) WPA_DRIVER_FLAGS_ACS_OFFLOAD; wpa_printf(MSG_DEBUG, "Enabled BRCM ACS"); + drv->brcm_do_acs = 1; + break; } #endif /* CONFIG_DRIVER_NL80211_BRCM */ }