diff mbox series

[v2,1/9] wifi: wfx: fix power_save setting when AP is stopped

Message ID 20230927163257.568496-2-jerome.pouiller@silabs.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series wfx: implement Remain On Channel | expand

Commit Message

Jérôme Pouiller Sept. 27, 2023, 4:32 p.m. UTC
The WF200 allow to start two network interfaces (one AP, one station) on
two different channels. Since magic does not exist, it only works if the
station interface enables power save.

Thus, the driver detects this case and enforce power save as necessary.

This patch fixes the case where the AP interface is stopped and it is no
more necessary to enforce power saving on the station interface.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
---
 drivers/net/wireless/silabs/wfx/sta.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kalle Valo Oct. 4, 2023, 10:20 a.m. UTC | #1
Jérôme Pouiller <jerome.pouiller@silabs.com> writes:

> The WF200 allow to start two network interfaces (one AP, one station) on
> two different channels. Since magic does not exist, it only works if the
> station interface enables power save.
>
> Thus, the driver detects this case and enforce power save as necessary.
>
> This patch fixes the case where the AP interface is stopped and it is no
> more necessary to enforce power saving on the station interface.
>
> Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
> ---
>  drivers/net/wireless/silabs/wfx/sta.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c
> index 626dfb4b7a55d..9c0a11c277e97 100644
> --- a/drivers/net/wireless/silabs/wfx/sta.c
> +++ b/drivers/net/wireless/silabs/wfx/sta.c
> @@ -402,7 +402,12 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>  		 struct ieee80211_bss_conf *link_conf)
>  {
>  	struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
> +	struct wfx_dev *wdev = wvif->wdev;
>  
> +	wvif =  NULL;
> +	while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
> +		wfx_update_pm(wvif);

Isn't the assignment of wvif to NULL unnecessary as in the next line we
assign it to again?
Jérôme Pouiller Oct. 4, 2023, 10:37 a.m. UTC | #2
Hi Kalle,

On Wednesday 4 October 2023 12:20:12 CEST Kalle Valo wrote:
> 
> Jérôme Pouiller <jerome.pouiller@silabs.com> writes:
> 
> > The WF200 allow to start two network interfaces (one AP, one station) on
> > two different channels. Since magic does not exist, it only works if the
> > station interface enables power save.
> >
> > Thus, the driver detects this case and enforce power save as necessary.
> >
> > This patch fixes the case where the AP interface is stopped and it is no
> > more necessary to enforce power saving on the station interface.
> >
> > Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
> > ---
> >  drivers/net/wireless/silabs/wfx/sta.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c
> > index 626dfb4b7a55d..9c0a11c277e97 100644
> > --- a/drivers/net/wireless/silabs/wfx/sta.c
> > +++ b/drivers/net/wireless/silabs/wfx/sta.c
> > @@ -402,7 +402,12 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> >                struct ieee80211_bss_conf *link_conf)
> >  {
> >       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
> > +     struct wfx_dev *wdev = wvif->wdev;
> >
> > +     wvif =  NULL;
> > +     while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
> > +             wfx_update_pm(wvif);
> 
> Isn't the assignment of wvif to NULL unnecessary as in the next line we
> assign it to again?

wvif is also passed as argument to wvif_iterate(). wvif_iterate() uses this
parameter to know where the iteration has stopped on previous call.

However, the assignation during the declaration of wvif is useless.
Kalle Valo Oct. 4, 2023, 11:30 a.m. UTC | #3
Jérôme Pouiller <jerome.pouiller@silabs.com> writes:

> Hi Kalle,
>
> On Wednesday 4 October 2023 12:20:12 CEST Kalle Valo wrote:
>> 
>> Jérôme Pouiller <jerome.pouiller@silabs.com> writes:
>> 
>> > The WF200 allow to start two network interfaces (one AP, one station) on
>> > two different channels. Since magic does not exist, it only works if the
>> > station interface enables power save.
>> >
>> > Thus, the driver detects this case and enforce power save as necessary.
>> >
>> > This patch fixes the case where the AP interface is stopped and it is no
>> > more necessary to enforce power saving on the station interface.
>> >
>> > Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
>> > ---
>> >  drivers/net/wireless/silabs/wfx/sta.c | 5 +++++
>> >  1 file changed, 5 insertions(+)
>> >
>> > diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c
>> > index 626dfb4b7a55d..9c0a11c277e97 100644
>> > --- a/drivers/net/wireless/silabs/wfx/sta.c
>> > +++ b/drivers/net/wireless/silabs/wfx/sta.c
>> > @@ -402,7 +402,12 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
>> >                struct ieee80211_bss_conf *link_conf)
>> >  {
>> >       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
>> > +     struct wfx_dev *wdev = wvif->wdev;
>> >
>> > +     wvif =  NULL;
>> > +     while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
>> > +             wfx_update_pm(wvif);
>> 
>> Isn't the assignment of wvif to NULL unnecessary as in the next line we
>> assign it to again?
>
> wvif is also passed as argument to wvif_iterate(). wvif_iterate() uses this
> parameter to know where the iteration has stopped on previous call.

Ah, I missed that.

> However, the assignation during the declaration of wvif is useless.

Indeed, missed that as well.
Jérôme Pouiller Oct. 4, 2023, 5:26 p.m. UTC | #4
On Wednesday 4 October 2023 13:30:45 CEST Kalle Valo wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> Jérôme Pouiller <jerome.pouiller@silabs.com> writes:
> 
> > Hi Kalle,
> >
> > On Wednesday 4 October 2023 12:20:12 CEST Kalle Valo wrote:
> >>
> >> Jérôme Pouiller <jerome.pouiller@silabs.com> writes:
> >>
> >> > The WF200 allow to start two network interfaces (one AP, one station) on
> >> > two different channels. Since magic does not exist, it only works if the
> >> > station interface enables power save.
> >> >
> >> > Thus, the driver detects this case and enforce power save as necessary.
> >> >
> >> > This patch fixes the case where the AP interface is stopped and it is no
> >> > more necessary to enforce power saving on the station interface.
> >> >
> >> > Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
> >> > ---
> >> >  drivers/net/wireless/silabs/wfx/sta.c | 5 +++++
> >> >  1 file changed, 5 insertions(+)
> >> >
> >> > diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c
> >> > index 626dfb4b7a55d..9c0a11c277e97 100644
> >> > --- a/drivers/net/wireless/silabs/wfx/sta.c
> >> > +++ b/drivers/net/wireless/silabs/wfx/sta.c
> >> > @@ -402,7 +402,12 @@ void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
> >> >                struct ieee80211_bss_conf *link_conf)
> >> >  {
> >> >       struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
> >> > +     struct wfx_dev *wdev = wvif->wdev;
> >> >
> >> > +     wvif =  NULL;
> >> > +     while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
> >> > +             wfx_update_pm(wvif);
> >>
> >> Isn't the assignment of wvif to NULL unnecessary as in the next line we
> >> assign it to again?
> >
> > wvif is also passed as argument to wvif_iterate(). wvif_iterate() uses this
> > parameter to know where the iteration has stopped on previous call.
> 
> Ah, I missed that.
> 
> > However, the assignation during the declaration of wvif is useless.
> 
> Indeed, missed that as well.

In fact, this first assignation is used to fill wdev just below. So I am
keeping this code as-is.
diff mbox series

Patch

diff --git a/drivers/net/wireless/silabs/wfx/sta.c b/drivers/net/wireless/silabs/wfx/sta.c
index 626dfb4b7a55d..9c0a11c277e97 100644
--- a/drivers/net/wireless/silabs/wfx/sta.c
+++ b/drivers/net/wireless/silabs/wfx/sta.c
@@ -402,7 +402,12 @@  void wfx_stop_ap(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		 struct ieee80211_bss_conf *link_conf)
 {
 	struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv;
+	struct wfx_dev *wdev = wvif->wdev;
 
+	wvif =  NULL;
+	while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
+		wfx_update_pm(wvif);
+	wvif = (struct wfx_vif *)vif->drv_priv;
 	wfx_reset(wvif);
 }