Commit 11c4a075 authored by Simon Wunderlich's avatar Simon Wunderlich Committed by Johannes Berg

cfg80211: check radar interface combinations

To ease further DFS development regarding interface combinations, use
the interface combinations structure to test for radar capabilities.
Drivers can specify which channel widths they support, and in which
modes. Right now only a single AP interface is allowed, but as the
DFS code evolves other combinations can be enabled.
Signed-off-by: default avatarSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent cee00a95
...@@ -2125,6 +2125,7 @@ struct ieee80211_iface_limit { ...@@ -2125,6 +2125,7 @@ struct ieee80211_iface_limit {
* @beacon_int_infra_match: In this combination, the beacon intervals * @beacon_int_infra_match: In this combination, the beacon intervals
* between infrastructure and AP types must match. This is required * between infrastructure and AP types must match. This is required
* only in special cases. * only in special cases.
* @radar_detect_widths: bitmap of channel widths supported for radar detection
* *
* These examples can be expressed as follows: * These examples can be expressed as follows:
* *
...@@ -2177,6 +2178,7 @@ struct ieee80211_iface_combination { ...@@ -2177,6 +2178,7 @@ struct ieee80211_iface_combination {
u16 max_interfaces; u16 max_interfaces;
u8 n_limits; u8 n_limits;
bool beacon_int_infra_match; bool beacon_int_infra_match;
u8 radar_detect_widths;
}; };
struct mac_address { struct mac_address {
......
...@@ -2984,6 +2984,8 @@ enum nl80211_iface_limit_attrs { ...@@ -2984,6 +2984,8 @@ enum nl80211_iface_limit_attrs {
* the infrastructure network's beacon interval. * the infrastructure network's beacon interval.
* @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many * @NL80211_IFACE_COMB_NUM_CHANNELS: u32 attribute specifying how many
* different channels may be used within this group. * different channels may be used within this group.
* @NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS: u32 attribute containing the bitmap
* of supported channel widths for radar detection.
* @NUM_NL80211_IFACE_COMB: number of attributes * @NUM_NL80211_IFACE_COMB: number of attributes
* @MAX_NL80211_IFACE_COMB: highest attribute number * @MAX_NL80211_IFACE_COMB: highest attribute number
* *
...@@ -3016,6 +3018,7 @@ enum nl80211_if_combination_attrs { ...@@ -3016,6 +3018,7 @@ enum nl80211_if_combination_attrs {
NL80211_IFACE_COMB_MAXNUM, NL80211_IFACE_COMB_MAXNUM,
NL80211_IFACE_COMB_STA_AP_BI_MATCH, NL80211_IFACE_COMB_STA_AP_BI_MATCH,
NL80211_IFACE_COMB_NUM_CHANNELS, NL80211_IFACE_COMB_NUM_CHANNELS,
NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
/* keep last */ /* keep last */
NUM_NL80211_IFACE_COMB, NUM_NL80211_IFACE_COMB,
......
...@@ -382,8 +382,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) ...@@ -382,8 +382,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
c = &wiphy->iface_combinations[i]; c = &wiphy->iface_combinations[i];
/* Combinations with just one interface aren't real */ /*
if (WARN_ON(c->max_interfaces < 2)) * Combinations with just one interface aren't real,
* however we make an exception for DFS.
*/
if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
return -EINVAL; return -EINVAL;
/* Need at least one channel */ /* Need at least one channel */
...@@ -398,6 +401,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy) ...@@ -398,6 +401,11 @@ static int wiphy_verify_combinations(struct wiphy *wiphy)
CFG80211_MAX_NUM_DIFFERENT_CHANNELS)) CFG80211_MAX_NUM_DIFFERENT_CHANNELS))
return -EINVAL; return -EINVAL;
/* DFS only works on one channel. */
if (WARN_ON(c->radar_detect_widths &&
(c->num_different_channels > 1)))
return -EINVAL;
if (WARN_ON(!c->n_limits)) if (WARN_ON(!c->n_limits))
return -EINVAL; return -EINVAL;
......
...@@ -425,7 +425,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -425,7 +425,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev, struct wireless_dev *wdev,
enum nl80211_iftype iftype, enum nl80211_iftype iftype,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
enum cfg80211_chan_mode chanmode); enum cfg80211_chan_mode chanmode,
u8 radar_detect);
static inline int static inline int
cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
...@@ -433,7 +434,7 @@ cfg80211_can_change_interface(struct cfg80211_registered_device *rdev, ...@@ -433,7 +434,7 @@ cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,
enum nl80211_iftype iftype) enum nl80211_iftype iftype)
{ {
return cfg80211_can_use_iftype_chan(rdev, wdev, iftype, NULL, return cfg80211_can_use_iftype_chan(rdev, wdev, iftype, NULL,
CHAN_MODE_UNDEFINED); CHAN_MODE_UNDEFINED, 0);
} }
static inline int static inline int
...@@ -450,7 +451,7 @@ cfg80211_can_use_chan(struct cfg80211_registered_device *rdev, ...@@ -450,7 +451,7 @@ cfg80211_can_use_chan(struct cfg80211_registered_device *rdev,
enum cfg80211_chan_mode chanmode) enum cfg80211_chan_mode chanmode)
{ {
return cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype, return cfg80211_can_use_iftype_chan(rdev, wdev, wdev->iftype,
chan, chanmode); chan, chanmode, 0);
} }
void void
......
...@@ -856,6 +856,9 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy, ...@@ -856,6 +856,9 @@ static int nl80211_put_iface_combinations(struct wiphy *wiphy,
nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM, nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
c->max_interfaces)) c->max_interfaces))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
c->radar_detect_widths))
goto nla_put_failure;
nla_nest_end(msg, nl_combi); nla_nest_end(msg, nl_combi);
} }
......
...@@ -1184,7 +1184,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -1184,7 +1184,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev, struct wireless_dev *wdev,
enum nl80211_iftype iftype, enum nl80211_iftype iftype,
struct ieee80211_channel *chan, struct ieee80211_channel *chan,
enum cfg80211_chan_mode chanmode) enum cfg80211_chan_mode chanmode,
u8 radar_detect)
{ {
struct wireless_dev *wdev_iter; struct wireless_dev *wdev_iter;
u32 used_iftypes = BIT(iftype); u32 used_iftypes = BIT(iftype);
...@@ -1195,14 +1196,45 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -1195,14 +1196,45 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
enum cfg80211_chan_mode chmode; enum cfg80211_chan_mode chmode;
int num_different_channels = 0; int num_different_channels = 0;
int total = 1; int total = 1;
bool radar_required;
int i, j; int i, j;
ASSERT_RTNL(); ASSERT_RTNL();
lockdep_assert_held(&rdev->devlist_mtx); lockdep_assert_held(&rdev->devlist_mtx);
if (WARN_ON(hweight32(radar_detect) > 1))
return -EINVAL;
switch (iftype) {
case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_AP:
case NL80211_IFTYPE_AP_VLAN:
case NL80211_IFTYPE_MESH_POINT:
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_WDS:
radar_required = !!(chan->flags & IEEE80211_CHAN_RADAR);
break;
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_MONITOR:
radar_required = false;
break;
case NL80211_IFTYPE_P2P_DEVICE:
case NUM_NL80211_IFTYPES:
case NL80211_IFTYPE_UNSPECIFIED:
default:
return -EINVAL;
}
if (radar_required && !radar_detect)
return -EINVAL;
/* Always allow software iftypes */ /* Always allow software iftypes */
if (rdev->wiphy.software_iftypes & BIT(iftype)) if (rdev->wiphy.software_iftypes & BIT(iftype)) {
if (radar_detect)
return -EINVAL;
return 0; return 0;
}
memset(num, 0, sizeof(num)); memset(num, 0, sizeof(num));
memset(used_channels, 0, sizeof(used_channels)); memset(used_channels, 0, sizeof(used_channels));
...@@ -1275,7 +1307,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -1275,7 +1307,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
used_iftypes |= BIT(wdev_iter->iftype); used_iftypes |= BIT(wdev_iter->iftype);
} }
if (total == 1) if (total == 1 && !radar_detect)
return 0; return 0;
for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) { for (i = 0; i < rdev->wiphy.n_iface_combinations; i++) {
...@@ -1308,6 +1340,9 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -1308,6 +1340,9 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
} }
} }
if (radar_detect && !(c->radar_detect_widths & radar_detect))
goto cont;
/* /*
* Finally check that all iftypes that we're currently * Finally check that all iftypes that we're currently
* using are actually part of this combination. If they * using are actually part of this combination. If they
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment