aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSimon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>2013-02-08 12:16:19 -0500
committerJohannes Berg <johannes.berg@intel.com>2013-02-15 03:40:18 -0500
commit04f39047af2a6df64b763ea5a271db24879d0391 (patch)
tree883a946e25f18e27abad2ed487a4ed4c88ff349c /include
parent2a0e047ed62f20664005881b8e7f9328f910316a (diff)
nl80211/cfg80211: add radar detection command/event
Add new NL80211_CMD_RADAR_DETECT, which starts the Channel Availability Check (CAC). This command will also notify the usermode about events (CAC finished, CAC aborted, radar detected, NOP finished). Once radar detection has started it should continuously monitor for radars as long as the channel is active. This patch enables DFS for AP mode in nl80211/cfg80211. Based on original patch by Victor Goldenshtein <victorg@ti.com> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> [remove WIPHY_FLAG_HAS_RADAR_DETECT again -- my mistake] Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/net/cfg80211.h46
-rw-r--r--include/uapi/linux/nl80211.h61
2 files changed, 107 insertions, 0 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7e6569e1f16f..ee11a3db730b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -114,6 +114,9 @@ enum ieee80211_channel_flags {
114#define IEEE80211_CHAN_NO_HT40 \ 114#define IEEE80211_CHAN_NO_HT40 \
115 (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) 115 (IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
116 116
117#define IEEE80211_DFS_MIN_CAC_TIME_MS 60000
118#define IEEE80211_DFS_MIN_NOP_TIME_MS (30 * 60 * 1000)
119
117/** 120/**
118 * struct ieee80211_channel - channel definition 121 * struct ieee80211_channel - channel definition
119 * 122 *
@@ -134,6 +137,9 @@ enum ieee80211_channel_flags {
134 * to enable this, this is useful only on 5 GHz band. 137 * to enable this, this is useful only on 5 GHz band.
135 * @orig_mag: internal use 138 * @orig_mag: internal use
136 * @orig_mpwr: internal use 139 * @orig_mpwr: internal use
140 * @dfs_state: current state of this channel. Only relevant if radar is required
141 * on this channel.
142 * @dfs_state_entered: timestamp (jiffies) when the dfs state was entered.
137 */ 143 */
138struct ieee80211_channel { 144struct ieee80211_channel {
139 enum ieee80211_band band; 145 enum ieee80211_band band;
@@ -146,6 +152,8 @@ struct ieee80211_channel {
146 bool beacon_found; 152 bool beacon_found;
147 u32 orig_flags; 153 u32 orig_flags;
148 int orig_mag, orig_mpwr; 154 int orig_mag, orig_mpwr;
155 enum nl80211_dfs_state dfs_state;
156 unsigned long dfs_state_entered;
149}; 157};
150 158
151/** 159/**
@@ -569,6 +577,7 @@ struct cfg80211_acl_data {
569 * @p2p_opp_ps: P2P opportunistic PS 577 * @p2p_opp_ps: P2P opportunistic PS
570 * @acl: ACL configuration used by the drivers which has support for 578 * @acl: ACL configuration used by the drivers which has support for
571 * MAC address based access control 579 * MAC address based access control
580 * @radar_required: set if radar detection is required
572 */ 581 */
573struct cfg80211_ap_settings { 582struct cfg80211_ap_settings {
574 struct cfg80211_chan_def chandef; 583 struct cfg80211_chan_def chandef;
@@ -586,6 +595,7 @@ struct cfg80211_ap_settings {
586 u8 p2p_ctwindow; 595 u8 p2p_ctwindow;
587 bool p2p_opp_ps; 596 bool p2p_opp_ps;
588 const struct cfg80211_acl_data *acl; 597 const struct cfg80211_acl_data *acl;
598 bool radar_required;
589}; 599};
590 600
591/** 601/**
@@ -1909,6 +1919,8 @@ struct cfg80211_gtk_rekey_data {
1909 * this new list replaces the existing one. Driver has to clear its ACL 1919 * this new list replaces the existing one. Driver has to clear its ACL
1910 * when number of MAC addresses entries is passed as 0. Drivers which 1920 * when number of MAC addresses entries is passed as 0. Drivers which
1911 * advertise the support for MAC based ACL have to implement this callback. 1921 * advertise the support for MAC based ACL have to implement this callback.
1922 *
1923 * @start_radar_detection: Start radar detection in the driver.
1912 */ 1924 */
1913struct cfg80211_ops { 1925struct cfg80211_ops {
1914 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); 1926 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -2132,6 +2144,10 @@ struct cfg80211_ops {
2132 2144
2133 int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev, 2145 int (*set_mac_acl)(struct wiphy *wiphy, struct net_device *dev,
2134 const struct cfg80211_acl_data *params); 2146 const struct cfg80211_acl_data *params);
2147
2148 int (*start_radar_detection)(struct wiphy *wiphy,
2149 struct net_device *dev,
2150 struct cfg80211_chan_def *chandef);
2135}; 2151};
2136 2152
2137/* 2153/*
@@ -2715,6 +2731,8 @@ struct cfg80211_cached_keys;
2715 * beacons, 0 when not valid 2731 * beacons, 0 when not valid
2716 * @address: The address for this device, valid only if @netdev is %NULL 2732 * @address: The address for this device, valid only if @netdev is %NULL
2717 * @p2p_started: true if this is a P2P Device that has been started 2733 * @p2p_started: true if this is a P2P Device that has been started
2734 * @cac_started: true if DFS channel availability check has been started
2735 * @cac_start_time: timestamp (jiffies) when the dfs state was entered.
2718 */ 2736 */
2719struct wireless_dev { 2737struct wireless_dev {
2720 struct wiphy *wiphy; 2738 struct wiphy *wiphy;
@@ -2766,6 +2784,9 @@ struct wireless_dev {
2766 2784
2767 u32 ap_unexpected_nlportid; 2785 u32 ap_unexpected_nlportid;
2768 2786
2787 bool cac_started;
2788 unsigned long cac_start_time;
2789
2769#ifdef CONFIG_CFG80211_WEXT 2790#ifdef CONFIG_CFG80211_WEXT
2770 /* wext data */ 2791 /* wext data */
2771 struct { 2792 struct {
@@ -3755,6 +3776,31 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev,
3755 gfp_t gfp); 3776 gfp_t gfp);
3756 3777
3757/** 3778/**
3779 * cfg80211_radar_event - radar detection event
3780 * @wiphy: the wiphy
3781 * @chandef: chandef for the current channel
3782 * @gfp: context flags
3783 *
3784 * This function is called when a radar is detected on the current chanenl.
3785 */
3786void cfg80211_radar_event(struct wiphy *wiphy,
3787 struct cfg80211_chan_def *chandef, gfp_t gfp);
3788
3789/**
3790 * cfg80211_cac_event - Channel availability check (CAC) event
3791 * @netdev: network device
3792 * @event: type of event
3793 * @gfp: context flags
3794 *
3795 * This function is called when a Channel availability check (CAC) is finished
3796 * or aborted. This must be called to notify the completion of a CAC process,
3797 * also by full-MAC drivers.
3798 */
3799void cfg80211_cac_event(struct net_device *netdev,
3800 enum nl80211_radar_event event, gfp_t gfp);
3801
3802
3803/**
3758 * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer 3804 * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer
3759 * @dev: network device 3805 * @dev: network device
3760 * @peer: peer's MAC address 3806 * @peer: peer's MAC address
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 5309b34930ea..90b7af86f392 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -603,6 +603,14 @@
603 * command is used in AP/P2P GO mode. Driver has to make sure to clear its 603 * command is used in AP/P2P GO mode. Driver has to make sure to clear its
604 * ACL list during %NL80211_CMD_STOP_AP. 604 * ACL list during %NL80211_CMD_STOP_AP.
605 * 605 *
606 * @NL80211_CMD_RADAR_DETECT: Start a Channel availability check (CAC). Once
607 * a radar is detected or the channel availability scan (CAC) has finished
608 * or was aborted, or a radar was detected, usermode will be notified with
609 * this event. This command is also used to notify userspace about radars
610 * while operating on this channel.
611 * %NL80211_ATTR_RADAR_EVENT is used to inform about the type of the
612 * event.
613 *
606 * @NL80211_CMD_MAX: highest used command number 614 * @NL80211_CMD_MAX: highest used command number
607 * @__NL80211_CMD_AFTER_LAST: internal use 615 * @__NL80211_CMD_AFTER_LAST: internal use
608 */ 616 */
@@ -755,6 +763,8 @@ enum nl80211_commands {
755 763
756 NL80211_CMD_SET_MAC_ACL, 764 NL80211_CMD_SET_MAC_ACL,
757 765
766 NL80211_CMD_RADAR_DETECT,
767
758 /* add new commands above here */ 768 /* add new commands above here */
759 769
760 /* used to define NL80211_CMD_MAX below */ 770 /* used to define NL80211_CMD_MAX below */
@@ -1342,6 +1352,9 @@ enum nl80211_commands {
1342 * number of MAC addresses that a device can support for MAC 1352 * number of MAC addresses that a device can support for MAC
1343 * ACL. 1353 * ACL.
1344 * 1354 *
1355 * @NL80211_ATTR_RADAR_EVENT: Type of radar event for notification to userspace,
1356 * contains a value of enum nl80211_radar_event (u32).
1357 *
1345 * @NL80211_ATTR_MAX: highest attribute number currently defined 1358 * @NL80211_ATTR_MAX: highest attribute number currently defined
1346 * @__NL80211_ATTR_AFTER_LAST: internal use 1359 * @__NL80211_ATTR_AFTER_LAST: internal use
1347 */ 1360 */
@@ -1620,6 +1633,8 @@ enum nl80211_attrs {
1620 1633
1621 NL80211_ATTR_MAC_ACL_MAX, 1634 NL80211_ATTR_MAC_ACL_MAX,
1622 1635
1636 NL80211_ATTR_RADAR_EVENT,
1637
1623 /* add attributes here, update the policy in nl80211.c */ 1638 /* add attributes here, update the policy in nl80211.c */
1624 1639
1625 __NL80211_ATTR_AFTER_LAST, 1640 __NL80211_ATTR_AFTER_LAST,
@@ -2022,6 +2037,10 @@ enum nl80211_band_attr {
2022 * on this channel in current regulatory domain. 2037 * on this channel in current regulatory domain.
2023 * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm 2038 * @NL80211_FREQUENCY_ATTR_MAX_TX_POWER: Maximum transmission power in mBm
2024 * (100 * dBm). 2039 * (100 * dBm).
2040 * @NL80211_FREQUENCY_ATTR_DFS_STATE: current state for DFS
2041 * (enum nl80211_dfs_state)
2042 * @NL80211_FREQUENCY_ATTR_DFS_TIME: time in miliseconds for how long
2043 * this channel is in this DFS state.
2025 * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number 2044 * @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
2026 * currently defined 2045 * currently defined
2027 * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use 2046 * @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -2034,6 +2053,8 @@ enum nl80211_frequency_attr {
2034 NL80211_FREQUENCY_ATTR_NO_IBSS, 2053 NL80211_FREQUENCY_ATTR_NO_IBSS,
2035 NL80211_FREQUENCY_ATTR_RADAR, 2054 NL80211_FREQUENCY_ATTR_RADAR,
2036 NL80211_FREQUENCY_ATTR_MAX_TX_POWER, 2055 NL80211_FREQUENCY_ATTR_MAX_TX_POWER,
2056 NL80211_FREQUENCY_ATTR_DFS_STATE,
2057 NL80211_FREQUENCY_ATTR_DFS_TIME,
2037 2058
2038 /* keep last */ 2059 /* keep last */
2039 __NL80211_FREQUENCY_ATTR_AFTER_LAST, 2060 __NL80211_FREQUENCY_ATTR_AFTER_LAST,
@@ -3489,4 +3510,44 @@ enum nl80211_acl_policy {
3489 NL80211_ACL_POLICY_DENY_UNLESS_LISTED, 3510 NL80211_ACL_POLICY_DENY_UNLESS_LISTED,
3490}; 3511};
3491 3512
3513/**
3514 * enum nl80211_radar_event - type of radar event for DFS operation
3515 *
3516 * Type of event to be used with NL80211_ATTR_RADAR_EVENT to inform userspace
3517 * about detected radars or success of the channel available check (CAC)
3518 *
3519 * @NL80211_RADAR_DETECTED: A radar pattern has been detected. The channel is
3520 * now unusable.
3521 * @NL80211_RADAR_CAC_FINISHED: Channel Availability Check has been finished,
3522 * the channel is now available.
3523 * @NL80211_RADAR_CAC_ABORTED: Channel Availability Check has been aborted, no
3524 * change to the channel status.
3525 * @NL80211_RADAR_NOP_FINISHED: The Non-Occupancy Period for this channel is
3526 * over, channel becomes usable.
3527 */
3528enum nl80211_radar_event {
3529 NL80211_RADAR_DETECTED,
3530 NL80211_RADAR_CAC_FINISHED,
3531 NL80211_RADAR_CAC_ABORTED,
3532 NL80211_RADAR_NOP_FINISHED,
3533};
3534
3535/**
3536 * enum nl80211_dfs_state - DFS states for channels
3537 *
3538 * Channel states used by the DFS code.
3539 *
3540 * @IEEE80211_DFS_USABLE: The channel can be used, but channel availability
3541 * check (CAC) must be performed before using it for AP or IBSS.
3542 * @IEEE80211_DFS_UNAVAILABLE: A radar has been detected on this channel, it
3543 * is therefore marked as not available.
3544 * @IEEE80211_DFS_AVAILABLE: The channel has been CAC checked and is available.
3545 */
3546
3547enum nl80211_dfs_state {
3548 NL80211_DFS_USABLE,
3549 NL80211_DFS_UNAVAILABLE,
3550 NL80211_DFS_AVAILABLE,
3551};
3552
3492#endif /* __LINUX_NL80211_H */ 3553#endif /* __LINUX_NL80211_H */