u32 rssi_hyst;
s32 last_rssi_event_value;
enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
u32 rssi_hyst;
s32 last_rssi_event_value;
enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
int n_rssi_thresholds;
s32 rssi_thresholds[] __counted_by(n_rssi_thresholds);
};
int n_rssi_thresholds;
s32 rssi_thresholds[] __counted_by(n_rssi_thresholds);
};
int i, n, low_index;
int err;
int i, n, low_index;
int err;
+ /* RSSI reporting disabled? */
+ if (!cqm_config)
+ return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
+
/*
* Obtain current RSSI value if possible, if not and no RSSI threshold
* event has been received yet, we should receive an event after a
/*
* Obtain current RSSI value if possible, if not and no RSSI threshold
* event has been received yet, we should receive an event after a
wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
return -EOPNOTSUPP;
wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
return -EOPNOTSUPP;
+ if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) {
+ if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */
+ return rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
+
+ return rdev_set_cqm_rssi_config(rdev, dev,
+ thresholds[0], hysteresis);
+ }
+
+ if (!wiphy_ext_feature_isset(&rdev->wiphy,
+ NL80211_EXT_FEATURE_CQM_RSSI_LIST))
+ return -EOPNOTSUPP;
+
if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
n_thresholds = 0;
if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
n_thresholds = 0;
old = rcu_dereference_protected(wdev->cqm_config,
lockdep_is_held(&wdev->mtx));
old = rcu_dereference_protected(wdev->cqm_config,
lockdep_is_held(&wdev->mtx));
- /* if already disabled just succeed */
- if (!n_thresholds && !old)
- return 0;
-
- if (n_thresholds > 1) {
- if (!wiphy_ext_feature_isset(&rdev->wiphy,
- NL80211_EXT_FEATURE_CQM_RSSI_LIST) ||
- !rdev->ops->set_cqm_rssi_range_config)
- return -EOPNOTSUPP;
- } else {
- if (!rdev->ops->set_cqm_rssi_config)
- return -EOPNOTSUPP;
- }
-
if (n_thresholds) {
cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
n_thresholds),
if (n_thresholds) {
cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
n_thresholds),
memcpy(cqm_config->rssi_thresholds, thresholds,
flex_array_size(cqm_config, rssi_thresholds,
n_thresholds));
memcpy(cqm_config->rssi_thresholds, thresholds,
flex_array_size(cqm_config, rssi_thresholds,
n_thresholds));
- cqm_config->use_range_api = n_thresholds > 1 ||
- !rdev->ops->set_cqm_rssi_config;
rcu_assign_pointer(wdev->cqm_config, cqm_config);
rcu_assign_pointer(wdev->cqm_config, cqm_config);
-
- if (cqm_config->use_range_api)
- err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
- else
- err = rdev_set_cqm_rssi_config(rdev, dev,
- thresholds[0],
- hysteresis);
} else {
RCU_INIT_POINTER(wdev->cqm_config, NULL);
} else {
RCU_INIT_POINTER(wdev->cqm_config, NULL);
- /* if enabled as range also disable via range */
- if (old->use_range_api)
- err = rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
- else
- err = rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
+ err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
if (err) {
rcu_assign_pointer(wdev->cqm_config, old);
kfree_rcu(cqm_config, rcu_head);
if (err) {
rcu_assign_pointer(wdev->cqm_config, old);
kfree_rcu(cqm_config, rcu_head);
wdev_lock(wdev);
cqm_config = rcu_dereference_protected(wdev->cqm_config,
lockdep_is_held(&wdev->mtx));
wdev_lock(wdev);
cqm_config = rcu_dereference_protected(wdev->cqm_config,
lockdep_is_held(&wdev->mtx));
- if (cqm_config->use_range_api)
- cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
+ cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
rssi_level = cqm_config->last_rssi_event_value;
rssi_event = cqm_config->last_rssi_event_type;
rssi_level = cqm_config->last_rssi_event_value;
rssi_event = cqm_config->last_rssi_event_type;