lkml.org 
[lkml]   [2020]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 64/89] cfg80211: Fix radar event during another phy CAC
    Date
    From: Orr Mazor <orr.mazor@tandemg.com>

    [ Upstream commit 26ec17a1dc5ecdd8d91aba63ead6f8b5ad5dea0d ]

    In case a radar event of CAC_FINISHED or RADAR_DETECTED
    happens during another phy is during CAC we might need
    to cancel that CAC.

    If we got a radar in a channel that another phy is now
    doing CAC on then the CAC should be canceled there.

    If, for example, 2 phys doing CAC on the same channels,
    or on comptable channels, once on of them will finish his
    CAC the other might need to cancel his CAC, since it is no
    longer relevant.

    To fix that the commit adds an callback and implement it in
    mac80211 to end CAC.
    This commit also adds a call to said callback if after a radar
    event we see the CAC is no longer relevant

    Signed-off-by: Orr Mazor <Orr.Mazor@tandemg.com>
    Reviewed-by: Sergey Matyukevich <sergey.matyukevich.os@quantenna.com>
    Link: https://lore.kernel.org/r/20191222145449.15792-1-Orr.Mazor@tandemg.com
    [slightly reformat/reword commit message]
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    include/net/cfg80211.h | 5 +++++
    net/mac80211/cfg.c | 23 +++++++++++++++++++++++
    net/wireless/rdev-ops.h | 10 ++++++++++
    net/wireless/reg.c | 23 ++++++++++++++++++++++-
    net/wireless/trace.h | 5 +++++
    5 files changed, 65 insertions(+), 1 deletion(-)

    diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
    index a4c8e9d7dd063..030eea38f2581 100644
    --- a/include/net/cfg80211.h
    +++ b/include/net/cfg80211.h
    @@ -2843,6 +2843,9 @@ struct cfg80211_pmk_conf {
    *
    * @start_radar_detection: Start radar detection in the driver.
    *
    + * @end_cac: End running CAC, probably because a related CAC
    + * was finished on another phy.
    + *
    * @update_ft_ies: Provide updated Fast BSS Transition information to the
    * driver. If the SME is in the driver/firmware, this information can be
    * used in building Authentication and Reassociation Request frames.
    @@ -3148,6 +3151,8 @@ struct cfg80211_ops {
    struct net_device *dev,
    struct cfg80211_chan_def *chandef,
    u32 cac_time_ms);
    + void (*end_cac)(struct wiphy *wiphy,
    + struct net_device *dev);
    int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
    struct cfg80211_update_ft_ies_params *ftie);
    int (*crit_proto_start)(struct wiphy *wiphy,
    diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
    index d437007b15bb2..b1484b8316e87 100644
    --- a/net/mac80211/cfg.c
    +++ b/net/mac80211/cfg.c
    @@ -2800,6 +2800,28 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy,
    return err;
    }

    +static void ieee80211_end_cac(struct wiphy *wiphy,
    + struct net_device *dev)
    +{
    + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
    + struct ieee80211_local *local = sdata->local;
    +
    + mutex_lock(&local->mtx);
    + list_for_each_entry(sdata, &local->interfaces, list) {
    + /* it might be waiting for the local->mtx, but then
    + * by the time it gets it, sdata->wdev.cac_started
    + * will no longer be true
    + */
    + cancel_delayed_work(&sdata->dfs_cac_timer_work);
    +
    + if (sdata->wdev.cac_started) {
    + ieee80211_vif_release_channel(sdata);
    + sdata->wdev.cac_started = false;
    + }
    + }
    + mutex_unlock(&local->mtx);
    +}
    +
    static struct cfg80211_beacon_data *
    cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
    {
    @@ -3730,6 +3752,7 @@ const struct cfg80211_ops mac80211_config_ops = {
    #endif
    .get_channel = ieee80211_cfg_get_channel,
    .start_radar_detection = ieee80211_start_radar_detection,
    + .end_cac = ieee80211_end_cac,
    .channel_switch = ieee80211_channel_switch,
    .set_qos_map = ieee80211_set_qos_map,
    .set_ap_chanwidth = ieee80211_set_ap_chanwidth,
    diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
    index 249919bdfc64e..4077bb3af440c 100644
    --- a/net/wireless/rdev-ops.h
    +++ b/net/wireless/rdev-ops.h
    @@ -1143,6 +1143,16 @@ rdev_start_radar_detection(struct cfg80211_registered_device *rdev,
    return ret;
    }

    +static inline void
    +rdev_end_cac(struct cfg80211_registered_device *rdev,
    + struct net_device *dev)
    +{
    + trace_rdev_end_cac(&rdev->wiphy, dev);
    + if (rdev->ops->end_cac)
    + rdev->ops->end_cac(&rdev->wiphy, dev);
    + trace_rdev_return_void(&rdev->wiphy);
    +}
    +
    static inline int
    rdev_set_mcast_rate(struct cfg80211_registered_device *rdev,
    struct net_device *dev,
    diff --git a/net/wireless/reg.c b/net/wireless/reg.c
    index e60a7dedfbf1b..a520f433d4765 100644
    --- a/net/wireless/reg.c
    +++ b/net/wireless/reg.c
    @@ -3303,6 +3303,25 @@ bool regulatory_pre_cac_allowed(struct wiphy *wiphy)
    return pre_cac_allowed;
    }

    +static void cfg80211_check_and_end_cac(struct cfg80211_registered_device *rdev)
    +{
    + struct wireless_dev *wdev;
    + /* If we finished CAC or received radar, we should end any
    + * CAC running on the same channels.
    + * the check !cfg80211_chandef_dfs_usable contain 2 options:
    + * either all channels are available - those the CAC_FINISHED
    + * event has effected another wdev state, or there is a channel
    + * in unavailable state in wdev chandef - those the RADAR_DETECTED
    + * event has effected another wdev state.
    + * In both cases we should end the CAC on the wdev.
    + */
    + list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
    + if (wdev->cac_started &&
    + !cfg80211_chandef_dfs_usable(&rdev->wiphy, &wdev->chandef))
    + rdev_end_cac(rdev, wdev->netdev);
    + }
    +}
    +
    void regulatory_propagate_dfs_state(struct wiphy *wiphy,
    struct cfg80211_chan_def *chandef,
    enum nl80211_dfs_state dfs_state,
    @@ -3329,8 +3348,10 @@ void regulatory_propagate_dfs_state(struct wiphy *wiphy,
    cfg80211_set_dfs_state(&rdev->wiphy, chandef, dfs_state);

    if (event == NL80211_RADAR_DETECTED ||
    - event == NL80211_RADAR_CAC_FINISHED)
    + event == NL80211_RADAR_CAC_FINISHED) {
    cfg80211_sched_dfs_chan_update(rdev);
    + cfg80211_check_and_end_cac(rdev);
    + }

    nl80211_radar_notify(rdev, chandef, event, NULL, GFP_KERNEL);
    }
    diff --git a/net/wireless/trace.h b/net/wireless/trace.h
    index f3353fe5b35b8..cd0a1c7c185d4 100644
    --- a/net/wireless/trace.h
    +++ b/net/wireless/trace.h
    @@ -607,6 +607,11 @@ DEFINE_EVENT(wiphy_netdev_evt, rdev_flush_pmksa,
    TP_ARGS(wiphy, netdev)
    );

    +DEFINE_EVENT(wiphy_netdev_evt, rdev_end_cac,
    + TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
    + TP_ARGS(wiphy, netdev)
    +);
    +
    DECLARE_EVENT_CLASS(station_add_change,
    TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac,
    struct station_parameters *params),
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-02-03 17:46    [W:2.531 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site