Commit a5a8eb1f authored by Jérôme Pouiller's avatar Jérôme Pouiller Committed by Greg Kroah-Hartman
Browse files

staging: wfx: ignore PS when STA/AP share same channel



When multiple interface are in use. One is always AP while the other is
always station. When the two interface use the same channel, it makes no
sense to enabled Power Saving (PS) on the station. Indeed, because of
the AP, the device will be kept awake on this channel anyway.

In add, when multiple interface are in use, mac80211 does not update the
PS information and delegate to the driver responsibility to do the
right thing.

Thus, in the current code, when the user enable PS in this
configuration, the driver finally enable PS-Poll which is probably not
what the user expected.

This patch detect this case and applies a sane configuration in all
cases.

Signed-off-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20210913130203.1903622-4-Jerome.Pouiller@silabs.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0ccb2c9d
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -154,9 +154,16 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps)
		chan0 = wdev_to_wvif(wvif->wdev, 0)->vif->bss_conf.chandef.chan;
	if (wdev_to_wvif(wvif->wdev, 1))
		chan1 = wdev_to_wvif(wvif->wdev, 1)->vif->bss_conf.chandef.chan;
	if (chan0 && chan1 && chan0->hw_value != chan1->hw_value &&
	    wvif->vif->type != NL80211_IFTYPE_AP) {
		// It is necessary to enable powersave if channels
	if (chan0 && chan1 && wvif->vif->type != NL80211_IFTYPE_AP) {
		if (chan0->hw_value == chan1->hw_value) {
			// It is useless to enable PS if channels are the same.
			if (enable_ps)
				*enable_ps = false;
			if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps)
				dev_info(wvif->wdev->dev, "ignoring requested PS mode");
			return -1;
		} else {
			// It is necessary to enable PS if channels
			// are different.
			if (enable_ps)
				*enable_ps = true;
@@ -167,6 +174,7 @@ static int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps)
			else
				return 30;
		}
	}
	if (enable_ps)
		*enable_ps = wvif->vif->bss_conf.ps;
	if (wvif->wdev->force_ps_timeout > -1)