]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Allow compilation with both vendor do_acs() handlers
authorJouni Malinen <j@w1.fi>
Sat, 27 Feb 2021 15:57:08 +0000 (17:57 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 27 Feb 2021 15:57:08 +0000 (17:57 +0200)
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 <j@w1.fi>
src/drivers/driver_nl80211.c
src/drivers/driver_nl80211.h
src/drivers/driver_nl80211_capa.c

index 59052a94e95be3842d6a13910bd3ad153417d237..54adae44bc51e289361645a262ba01344d69149e 100644 (file)
@@ -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,
index 940d82c87b6a0c9b402af5dfda1bcc27fa5cc02c..0de1c5f7ca4c4c774a02ad982d1bc450dc900490 100644 (file)
@@ -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;
index 7dac62b4e990273ab2d9ab57000ffc2224d1d0d7..d3d43d48a7cb562f03fbaf8ed41d315e7a1d0115 100644 (file)
@@ -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 */
                        }