Commit 9ed8b0d0 authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman

staging: wfx: simplify hif_set_rcpi_rssi_threshold() usage

The structure hif_mib_rcpi_rssi_threshold come from hardware API. It is
not intended to be manipulated in upper layers of the driver.

In add, current code for hif_set_rcpi_rssi_threshold() is dumb. It
should pack data using the hardware representation instead of leaving
all work to the caller.
Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200115135338.14374-8-Jerome.Pouiller@silabs.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5fd64673
......@@ -44,10 +44,25 @@ static inline int hif_set_beacon_wakeup_period(struct wfx_vif *wvif,
}
static inline int hif_set_rcpi_rssi_threshold(struct wfx_vif *wvif,
struct hif_mib_rcpi_rssi_threshold *arg)
int rssi_thold, int rssi_hyst)
{
struct hif_mib_rcpi_rssi_threshold arg = {
.rolling_average_count = 8,
.detection = 1,
};
if (!rssi_thold && !rssi_hyst) {
arg.upperthresh = 1;
arg.lowerthresh = 1;
} else {
arg.upper_threshold = rssi_thold + rssi_hyst;
arg.upper_threshold = (arg.upper_threshold + 110) * 2;
arg.lower_threshold = rssi_thold;
arg.lower_threshold = (arg.lower_threshold + 110) * 2;
}
return hif_write_mib(wvif->wdev, wvif->id,
HIF_MIB_ID_RCPI_RSSI_THRESHOLD, arg, sizeof(*arg));
HIF_MIB_ID_RCPI_RSSI_THRESHOLD, &arg, sizeof(arg));
}
static inline int hif_get_counters_table(struct wfx_dev *wdev,
......
......@@ -1033,31 +1033,9 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw,
hif_slot_time(wvif, info->use_short_slot ? 9 : 20);
if (changed & BSS_CHANGED_ASSOC || changed & BSS_CHANGED_CQM) {
struct hif_mib_rcpi_rssi_threshold th = {
.rolling_average_count = 8,
.detection = 1,
};
wvif->cqm_rssi_thold = info->cqm_rssi_thold;
if (!info->cqm_rssi_thold && !info->cqm_rssi_hyst) {
th.upperthresh = 1;
th.lowerthresh = 1;
} else {
/* FIXME It's not a correct way of setting threshold.
* Upper and lower must be set equal here and adjusted
* in callback. However current implementation is much
* more reliable and stable.
*/
/* RSSI: signed Q8.0, RCPI: unsigned Q7.1
* RSSI = RCPI / 2 - 110
*/
th.upper_threshold = info->cqm_rssi_thold + info->cqm_rssi_hyst;
th.upper_threshold = (th.upper_threshold + 110) * 2;
th.lower_threshold = info->cqm_rssi_thold;
th.lower_threshold = (th.lower_threshold + 110) * 2;
}
hif_set_rcpi_rssi_threshold(wvif, &th);
hif_set_rcpi_rssi_threshold(wvif, info->cqm_rssi_thold,
info->cqm_rssi_hyst);
}
if (changed & BSS_CHANGED_TXPOWER &&
......
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