]> git.baikalelectronics.ru Git - kernel.git/commitdiff
wifi: mac80211: replace link_id with link_conf in switch/(un)assign_vif_chanctx()
authorGregory Greenman <gregory.greenman@intel.com>
Sun, 3 Jul 2022 15:04:15 +0000 (18:04 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 15 Jul 2022 09:43:20 +0000 (11:43 +0200)
Since mac80211 already has a protected pointer to link_conf,
pass it to the driver to avoid additional RCU locking.

Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
13 files changed:
drivers/net/wireless/ath/ath10k/mac.c
drivers/net/wireless/ath/ath11k/mac.c
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/silabs/wfx/sta.c
drivers/net/wireless/silabs/wfx/sta.h
drivers/net/wireless/ti/wlcore/main.c
include/net/mac80211.h
net/mac80211/chan.c
net/mac80211/driver-ops.h
net/mac80211/trace.h
net/mac80211/util.c

index ac54396418c91ff9a091bfce0752175d01056b5d..9dd3b8fba4b0e5d078d5b20637c0a3ce54451e93 100644 (file)
@@ -8920,7 +8920,7 @@ unlock:
 static int
 ath10k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
                                 struct ieee80211_vif *vif,
-                                unsigned int link_id,
+                                struct ieee80211_bss_conf *link_conf,
                                 struct ieee80211_chanctx_conf *ctx)
 {
        struct ath10k *ar = hw->priv;
@@ -9000,7 +9000,7 @@ err:
 static void
 ath10k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                   struct ieee80211_vif *vif,
-                                  unsigned int link_id,
+                                  struct ieee80211_bss_conf *link_conf,
                                   struct ieee80211_chanctx_conf *ctx)
 {
        struct ath10k *ar = hw->priv;
index ec7b3a3629f3d28a69db4e46d17a7251bb6385c1..92e17d3c634e19710e942c5b8ec8b4513a09496a 100644 (file)
@@ -7073,7 +7073,7 @@ static int ath11k_start_vdev_delay(struct ieee80211_hw *hw,
 static int
 ath11k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
                                 struct ieee80211_vif *vif,
-                                unsigned int link_id,
+                                struct ieee80211_bss_conf *link_conf,
                                 struct ieee80211_chanctx_conf *ctx)
 {
        struct ath11k *ar = hw->priv;
@@ -7163,7 +7163,7 @@ out:
 static void
 ath11k_mac_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                   struct ieee80211_vif *vif,
-                                  unsigned int link_id,
+                                  struct ieee80211_bss_conf *link_conf,
                                   struct ieee80211_chanctx_conf *ctx)
 {
        struct ath11k *ar = hw->priv;
index d2c20c332c7a33c74ceec7bfcadc517ef9aaa0e7..a4197c14f0a9202b36c073af6a00edb50f005f75 100644 (file)
@@ -2597,7 +2597,7 @@ static void ath9k_change_chanctx(struct ieee80211_hw *hw,
 
 static int ath9k_assign_vif_chanctx(struct ieee80211_hw *hw,
                                    struct ieee80211_vif *vif,
-                                   unsigned int link_id,
+                                   struct ieee80211_bss_conf *link_conf,
                                    struct ieee80211_chanctx_conf *conf)
 {
        struct ath_softc *sc = hw->priv;
@@ -2629,7 +2629,7 @@ static int ath9k_assign_vif_chanctx(struct ieee80211_hw *hw,
 
 static void ath9k_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                       struct ieee80211_vif *vif,
-                                      unsigned int link_id,
+                                      struct ieee80211_bss_conf *link_conf,
                                       struct ieee80211_chanctx_conf *conf)
 {
        struct ath_softc *sc = hw->priv;
index 126106ea62d36828545d226cd792699bdd470dcb..5eb28f8ee87e524560605a14613f2ad81551374e 100644 (file)
@@ -4264,7 +4264,7 @@ out:
 }
 static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
                                      struct ieee80211_vif *vif,
-                                     unsigned int link_id,
+                                     struct ieee80211_bss_conf *link_conf,
                                      struct ieee80211_chanctx_conf *ctx)
 {
        struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
@@ -4338,7 +4338,7 @@ out:
 
 static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                         struct ieee80211_vif *vif,
-                                        unsigned int link_id,
+                                        struct ieee80211_bss_conf *link_conf,
                                         struct ieee80211_chanctx_conf *ctx)
 {
        struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
index 5da7a097d518d9a75efd344fdf305f3293fbef35..7d573e90ad818a10e0880ecf739babb3002cdca9 100644 (file)
@@ -2794,7 +2794,7 @@ static void mac80211_hwsim_change_chanctx(struct ieee80211_hw *hw,
 
 static int mac80211_hwsim_assign_vif_chanctx(struct ieee80211_hw *hw,
                                             struct ieee80211_vif *vif,
-                                            unsigned int link_id,
+                                            struct ieee80211_bss_conf *link_conf,
                                             struct ieee80211_chanctx_conf *ctx)
 {
        hwsim_check_magic(vif);
@@ -2805,7 +2805,7 @@ static int mac80211_hwsim_assign_vif_chanctx(struct ieee80211_hw *hw,
 
 static void mac80211_hwsim_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                                struct ieee80211_vif *vif,
-                                               unsigned int link_id,
+                                               struct ieee80211_bss_conf *link_conf,
                                                struct ieee80211_chanctx_conf *ctx)
 {
        hwsim_check_magic(vif);
index 920bd1a4a1b19208aa42dad0b34d3251d99c9628..626dfb4b7a55de0bb072aaf26123be1b18913571 100644 (file)
@@ -683,7 +683,7 @@ void wfx_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *
 }
 
 int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                          unsigned int link_id,
+                          struct ieee80211_bss_conf *link_conf,
                           struct ieee80211_chanctx_conf *conf)
 {
        struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
@@ -696,7 +696,7 @@ int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 }
 
 void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                             unsigned int link_id,
+                             struct ieee80211_bss_conf *link_conf,
                              struct ieee80211_chanctx_conf *conf)
 {
        struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
index bf2e76167a6f59f9d914bb12e324b5e8069fdc0d..888db5cd3206b8a4425a89ccfc156fa1de73b5f2 100644 (file)
@@ -51,10 +51,10 @@ int wfx_add_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf
 void wfx_remove_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf);
 void wfx_change_chanctx(struct ieee80211_hw *hw, struct ieee80211_chanctx_conf *conf, u32 changed);
 int wfx_assign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                          unsigned int link_id,
+                          struct ieee80211_bss_conf *link_conf,
                           struct ieee80211_chanctx_conf *conf);
 void wfx_unassign_vif_chanctx(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-                             unsigned int link_id,
+                             struct ieee80211_bss_conf *link_conf,
                              struct ieee80211_chanctx_conf *conf);
 
 /* Hardware API Callbacks */
index 1edec9f3c0d80ea22519a44ca0197e2d86cfa901..3e3922d4c78801d6b50fd2ea538791e0cf0df398 100644 (file)
@@ -4701,7 +4701,7 @@ out:
 
 static int wlcore_op_assign_vif_chanctx(struct ieee80211_hw *hw,
                                        struct ieee80211_vif *vif,
-                                       unsigned int link_id,
+                                       struct ieee80211_bss_conf *link_conf,
                                        struct ieee80211_chanctx_conf *ctx)
 {
        struct wl1271 *wl = hw->priv;
@@ -4752,7 +4752,7 @@ out:
 
 static void wlcore_op_unassign_vif_chanctx(struct ieee80211_hw *hw,
                                           struct ieee80211_vif *vif,
-                                          unsigned int link_id,
+                                          struct ieee80211_bss_conf *link_conf,
                                           struct ieee80211_chanctx_conf *ctx)
 {
        struct wl1271 *wl = hw->priv;
index dcb8b6dac2e1c57aa37ffbeda90927752d3e4c79..e4ead73c5c436c86e9815d24cc723c4080eeb28e 100644 (file)
@@ -261,13 +261,13 @@ enum ieee80211_chanctx_switch_mode {
  * done.
  *
  * @vif: the vif that should be switched from old_ctx to new_ctx
- * @link_id: the link ID that's switching
+ * @link_conf: the link conf that's switching
  * @old_ctx: the old context to which the vif was assigned
  * @new_ctx: the new context to which the vif must be assigned
  */
 struct ieee80211_vif_chanctx_switch {
        struct ieee80211_vif *vif;
-       unsigned int link_id;
+       struct ieee80211_bss_conf *link_conf;
        struct ieee80211_chanctx_conf *old_ctx;
        struct ieee80211_chanctx_conf *new_ctx;
 };
@@ -4297,11 +4297,11 @@ struct ieee80211_ops {
                               u32 changed);
        int (*assign_vif_chanctx)(struct ieee80211_hw *hw,
                                  struct ieee80211_vif *vif,
-                                 unsigned int link_id,
+                                 struct ieee80211_bss_conf *link_conf,
                                  struct ieee80211_chanctx_conf *ctx);
        void (*unassign_vif_chanctx)(struct ieee80211_hw *hw,
                                     struct ieee80211_vif *vif,
-                                    unsigned int link_id,
+                                    struct ieee80211_bss_conf *link_conf,
                                     struct ieee80211_chanctx_conf *ctx);
        int (*switch_vif_chanctx)(struct ieee80211_hw *hw,
                                  struct ieee80211_vif_chanctx_switch *vifs,
index 2e9bc285f0a5b69d1e988c2fe0c2dcc5f26374f6..f247daa4156389dfe9ab3d723443d7ca0eec0e70 100644 (file)
@@ -835,7 +835,6 @@ static int ieee80211_assign_link_chanctx(struct ieee80211_link_data *link,
                                         struct ieee80211_chanctx *new_ctx)
 {
        struct ieee80211_sub_if_data *sdata = link->sdata;
-       unsigned int link_id = link->link_id;
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_chanctx_conf *conf;
        struct ieee80211_chanctx *curr_ctx = NULL;
@@ -850,13 +849,13 @@ static int ieee80211_assign_link_chanctx(struct ieee80211_link_data *link,
        if (conf) {
                curr_ctx = container_of(conf, struct ieee80211_chanctx, conf);
 
-               drv_unassign_vif_chanctx(local, sdata, link_id, curr_ctx);
+               drv_unassign_vif_chanctx(local, sdata, link->conf, curr_ctx);
                conf = NULL;
                list_del(&link->assigned_chanctx_list);
        }
 
        if (new_ctx) {
-               ret = drv_assign_vif_chanctx(local, sdata, link_id, new_ctx);
+               ret = drv_assign_vif_chanctx(local, sdata, link->conf, new_ctx);
                if (ret)
                        goto out;
 
@@ -1276,7 +1275,7 @@ ieee80211_link_use_reserved_reassign(struct ieee80211_link_data *link)
        vif_chsw[0].vif = &sdata->vif;
        vif_chsw[0].old_ctx = &old_ctx->conf;
        vif_chsw[0].new_ctx = &new_ctx->conf;
-       vif_chsw[0].link_id = link->link_id;
+       vif_chsw[0].link_conf = link->conf;
 
        list_del(&link->reserved_chanctx_list);
        link->reserved_chanctx = NULL;
@@ -1440,7 +1439,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
                        vif_chsw[i].vif = &link->sdata->vif;
                        vif_chsw[i].old_ctx = &old_ctx->conf;
                        vif_chsw[i].new_ctx = &ctx->conf;
-                       vif_chsw[i].link_id = link->link_id;
+                       vif_chsw[i].link_conf = link->conf;
 
                        i++;
                }
index a04a88d122b741b0df31daf39d73fb2f0068fe73..0f06081c68cac9d4b8a39cbf219cbc4b6921e40f 100644 (file)
@@ -937,22 +937,31 @@ static inline void drv_change_chanctx(struct ieee80211_local *local,
        trace_drv_return_void(local);
 }
 
+static inline void drv_verify_link_exists(struct ieee80211_sub_if_data *sdata,
+                                         struct ieee80211_bss_conf *link_conf)
+{
+       /* deflink always exists, so need to check only for other links */
+       if (sdata->deflink.conf != link_conf)
+               sdata_assert_lock(sdata);
+}
+
 static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
                                         struct ieee80211_sub_if_data *sdata,
-                                        unsigned int link_id,
+                                        struct ieee80211_bss_conf *link_conf,
                                         struct ieee80211_chanctx *ctx)
 {
        int ret = 0;
 
+       drv_verify_link_exists(sdata, link_conf);
        if (!check_sdata_in_driver(sdata))
                return -EIO;
 
-       trace_drv_assign_vif_chanctx(local, sdata, link_id, ctx);
+       trace_drv_assign_vif_chanctx(local, sdata, link_conf, ctx);
        if (local->ops->assign_vif_chanctx) {
                WARN_ON_ONCE(!ctx->driver_present);
                ret = local->ops->assign_vif_chanctx(&local->hw,
                                                     &sdata->vif,
-                                                    link_id,
+                                                    link_conf,
                                                     &ctx->conf);
        }
        trace_drv_return_int(local, ret);
@@ -962,20 +971,21 @@ static inline int drv_assign_vif_chanctx(struct ieee80211_local *local,
 
 static inline void drv_unassign_vif_chanctx(struct ieee80211_local *local,
                                            struct ieee80211_sub_if_data *sdata,
-                                           unsigned int link_id,
+                                           struct ieee80211_bss_conf *link_conf,
                                            struct ieee80211_chanctx *ctx)
 {
        might_sleep();
 
+       drv_verify_link_exists(sdata, link_conf);
        if (!check_sdata_in_driver(sdata))
                return;
 
-       trace_drv_unassign_vif_chanctx(local, sdata, link_id, ctx);
+       trace_drv_unassign_vif_chanctx(local, sdata, link_conf, ctx);
        if (local->ops->unassign_vif_chanctx) {
                WARN_ON_ONCE(!ctx->driver_present);
                local->ops->unassign_vif_chanctx(&local->hw,
                                                 &sdata->vif,
-                                                link_id,
+                                                link_conf,
                                                 &ctx->conf);
        }
        trace_drv_return_void(local);
@@ -992,7 +1002,7 @@ static inline int drv_start_ap(struct ieee80211_local *local,
        int ret = 0;
 
        /* make sure link_conf is protected */
-       sdata_assert_lock(sdata);
+       drv_verify_link_exists(sdata, link_conf);
 
        might_sleep();
 
@@ -1011,7 +1021,7 @@ static inline void drv_stop_ap(struct ieee80211_local *local,
                               struct ieee80211_bss_conf *link_conf)
 {
        /* make sure link_conf is protected */
-       sdata_assert_lock(sdata);
+       drv_verify_link_exists(sdata, link_conf);
 
        if (!check_sdata_in_driver(sdata))
                return;
index 75e5c1376351b73eaa21fb52fc08c71064e7e71a..402110f439f88b197d2bd5e8c810a7ded4742a10 100644 (file)
@@ -1669,7 +1669,7 @@ TRACE_EVENT(drv_switch_vif_chanctx,
 
                                SWITCH_ENTRY_ASSIGN(vif.vif_type, vif->type);
                                SWITCH_ENTRY_ASSIGN(vif.p2p, vif->p2p);
-                               SWITCH_ENTRY_ASSIGN(link_id, link_id);
+                               SWITCH_ENTRY_ASSIGN(link_id, link_conf->link_id);
                                strncpy(local_vifs[i].vif.vif_name,
                                        sdata->name,
                                        sizeof(local_vifs[i].vif.vif_name));
@@ -1710,10 +1710,10 @@ TRACE_EVENT(drv_switch_vif_chanctx,
 DECLARE_EVENT_CLASS(local_sdata_chanctx,
        TP_PROTO(struct ieee80211_local *local,
                 struct ieee80211_sub_if_data *sdata,
-                unsigned int link_id,
+                struct ieee80211_bss_conf *link_conf,
                 struct ieee80211_chanctx *ctx),
 
-       TP_ARGS(local, sdata, link_id, ctx),
+       TP_ARGS(local, sdata, link_conf, ctx),
 
        TP_STRUCT__entry(
                LOCAL_ENTRY
@@ -1726,7 +1726,7 @@ DECLARE_EVENT_CLASS(local_sdata_chanctx,
                LOCAL_ASSIGN;
                VIF_ASSIGN;
                CHANCTX_ASSIGN;
-               __entry->link_id = link_id;
+               __entry->link_id = link_conf->link_id;
        ),
 
        TP_printk(
@@ -1738,17 +1738,17 @@ DECLARE_EVENT_CLASS(local_sdata_chanctx,
 DEFINE_EVENT(local_sdata_chanctx, drv_assign_vif_chanctx,
        TP_PROTO(struct ieee80211_local *local,
                 struct ieee80211_sub_if_data *sdata,
-                unsigned int link_id,
+                struct ieee80211_bss_conf *link_conf,
                 struct ieee80211_chanctx *ctx),
-       TP_ARGS(local, sdata, link_id, ctx)
+       TP_ARGS(local, sdata, link_conf, ctx)
 );
 
 DEFINE_EVENT(local_sdata_chanctx, drv_unassign_vif_chanctx,
        TP_PROTO(struct ieee80211_local *local,
                 struct ieee80211_sub_if_data *sdata,
-                unsigned int link_id,
+                struct ieee80211_bss_conf *link_conf,
                 struct ieee80211_chanctx *ctx),
-       TP_ARGS(local, sdata, link_id, ctx)
+       TP_ARGS(local, sdata, link_conf, ctx)
 );
 
 TRACE_EVENT(drv_start_ap,
index 739c05fdb9bb182683b41b4b620f2137d43ae39e..8cb93d65b80eae04fc0687ac0968332a2a59ebef 100644 (file)
@@ -2270,7 +2270,7 @@ static void ieee80211_assign_chanctx(struct ieee80211_local *local,
                                         lockdep_is_held(&local->chanctx_mtx));
        if (conf) {
                ctx = container_of(conf, struct ieee80211_chanctx, conf);
-               drv_assign_vif_chanctx(local, sdata, link->link_id, ctx);
+               drv_assign_vif_chanctx(local, sdata, link->conf, ctx);
        }
        mutex_unlock(&local->chanctx_mtx);
 }