mbox series

[v2,0/7] mt76x02: Beacon support for USB

Message ID 1548678108-9526-1-git-send-email-sgruszka@redhat.com (mailing list archive)
Headers show
Series mt76x02: Beacon support for USB | expand

Message

Stanislaw Gruszka Jan. 28, 2019, 12:21 p.m. UTC
We can configure beaconing, but without TBTT interrupt we
can not support PS buffering. This can be added later using
kernel hrtimer, if we can keep it in sycn with device timer.

I tested AP and IBSS modes.

Stanislaw Gruszka (7):
  mt76x02: use mask for vifs
  mt76x02: use commmon add interface for mt76x2u
  mt76x02: initialize mutli bss mode when set up address
  mt76x02: minor beaconing init changes
  mt76x02: init beacon config for mt76x2u
  mt76: beaconing fixes for USB
  mt76x02: enable support for IBSS, AP and MESH

 drivers/net/wireless/mediatek/mt76/mac80211.c |  3 +-
 .../net/wireless/mediatek/mt76/mt76x0/pci.c   |  7 ++
 drivers/net/wireless/mediatek/mt76/mt76x02.h  |  5 +-
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 44 ++++++++++-
 .../net/wireless/mediatek/mt76/mt76x02_mac.h  |  6 +-
 .../net/wireless/mediatek/mt76/mt76x02_util.c | 73 +++++++++----------
 .../wireless/mediatek/mt76/mt76x2/pci_init.c  | 12 ++-
 .../wireless/mediatek/mt76/mt76x2/usb_init.c  |  6 +-
 .../wireless/mediatek/mt76/mt76x2/usb_main.c  | 15 +---
 9 files changed, 100 insertions(+), 71 deletions(-)

Comments

Kalle Valo Jan. 29, 2019, 11:47 a.m. UTC | #1
Stanislaw Gruszka <sgruszka@redhat.com> writes:

> We can configure beaconing, but without TBTT interrupt we
> can not support PS buffering. This can be added later using
> kernel hrtimer, if we can keep it in sycn with device timer.
>
> I tested AP and IBSS modes.

So how does this work reliably so that there's no packet loss with
clients using power save?
Felix Fietkau Jan. 29, 2019, 11:49 a.m. UTC | #2
On 2019-01-29 12:47, Kalle Valo wrote:
> Stanislaw Gruszka <sgruszka@redhat.com> writes:
> 
>> We can configure beaconing, but without TBTT interrupt we
>> can not support PS buffering. This can be added later using
>> kernel hrtimer, if we can keep it in sycn with device timer.
>>
>> I tested AP and IBSS modes.
> 
> So how does this work reliably so that there's no packet loss with
> clients using power save?
There will be multicast packet loss for clients using power save.

- Felix
Kalle Valo Jan. 29, 2019, 12:07 p.m. UTC | #3
Felix Fietkau <nbd@nbd.name> writes:

> On 2019-01-29 12:47, Kalle Valo wrote:
>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
>> 
>>> We can configure beaconing, but without TBTT interrupt we
>>> can not support PS buffering. This can be added later using
>>> kernel hrtimer, if we can keep it in sycn with device timer.
>>>
>>> I tested AP and IBSS modes.
>> 
>> So how does this work reliably so that there's no packet loss with
>> clients using power save?
>
> There will be multicast packet loss for clients using power save.

Isn't that a problem? At least as a normal user I would very frustrated
if sometimes my connection work and sometimes not, for example if I'm
trying discover devices from my network. Hopefully nobody won't use USB
devices for any real AP stuff, but still enabling something which we
know doesn't work realiably is concerning.
Felix Fietkau Jan. 29, 2019, 12:10 p.m. UTC | #4
On 2019-01-29 13:07, Kalle Valo wrote:
> Felix Fietkau <nbd@nbd.name> writes:
> 
>> On 2019-01-29 12:47, Kalle Valo wrote:
>>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
>>> 
>>>> We can configure beaconing, but without TBTT interrupt we
>>>> can not support PS buffering. This can be added later using
>>>> kernel hrtimer, if we can keep it in sycn with device timer.
>>>>
>>>> I tested AP and IBSS modes.
>>> 
>>> So how does this work reliably so that there's no packet loss with
>>> clients using power save?
>>
>> There will be multicast packet loss for clients using power save.
> 
> Isn't that a problem? At least as a normal user I would very frustrated
> if sometimes my connection work and sometimes not, for example if I'm
> trying discover devices from my network. Hopefully nobody won't use USB
> devices for any real AP stuff, but still enabling something which we
> know doesn't work realiably is concerning.
I agree. Maybe we should leave out the flag for AP mode in this patch
until we have PS buffering and leave the rest of the code intact.

- Felix
Kalle Valo Jan. 29, 2019, 12:18 p.m. UTC | #5
Felix Fietkau <nbd@nbd.name> writes:

> On 2019-01-29 13:07, Kalle Valo wrote:
>> Felix Fietkau <nbd@nbd.name> writes:
>> 
>>> On 2019-01-29 12:47, Kalle Valo wrote:
>>>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
>>>> 
>>>>> We can configure beaconing, but without TBTT interrupt we
>>>>> can not support PS buffering. This can be added later using
>>>>> kernel hrtimer, if we can keep it in sycn with device timer.
>>>>>
>>>>> I tested AP and IBSS modes.
>>>> 
>>>> So how does this work reliably so that there's no packet loss with
>>>> clients using power save?
>>>
>>> There will be multicast packet loss for clients using power save.
>> 
>> Isn't that a problem? At least as a normal user I would very frustrated
>> if sometimes my connection work and sometimes not, for example if I'm
>> trying discover devices from my network. Hopefully nobody won't use USB
>> devices for any real AP stuff, but still enabling something which we
>> know doesn't work realiably is concerning.
>
> I agree. Maybe we should leave out the flag for AP mode in this patch
> until we have PS buffering and leave the rest of the code intact.

At least for me that sounds good.
Lorenzo Bianconi Jan. 29, 2019, 12:40 p.m. UTC | #6
> Felix Fietkau <nbd@nbd.name> writes:
> 
> > On 2019-01-29 13:07, Kalle Valo wrote:
> >> Felix Fietkau <nbd@nbd.name> writes:
> >> 
> >>> On 2019-01-29 12:47, Kalle Valo wrote:
> >>>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
> >>>> 
> >>>>> We can configure beaconing, but without TBTT interrupt we
> >>>>> can not support PS buffering. This can be added later using
> >>>>> kernel hrtimer, if we can keep it in sycn with device timer.
> >>>>>
> >>>>> I tested AP and IBSS modes.
> >>>> 
> >>>> So how does this work reliably so that there's no packet loss with
> >>>> clients using power save?
> >>>
> >>> There will be multicast packet loss for clients using power save.
> >> 
> >> Isn't that a problem? At least as a normal user I would very frustrated
> >> if sometimes my connection work and sometimes not, for example if I'm
> >> trying discover devices from my network. Hopefully nobody won't use USB
> >> devices for any real AP stuff, but still enabling something which we
> >> know doesn't work realiably is concerning.
> >
> > I agree. Maybe we should leave out the flag for AP mode in this patch
> > until we have PS buffering and leave the rest of the code intact.
> 
> At least for me that sounds good.

We can support ps buffering in AP as well using a hrtimer. In this way we
can reuse most of the existing code

Regards,
Lorenzo

> 
> -- 
> Kalle Valo
Stanislaw Gruszka Jan. 30, 2019, 8:29 a.m. UTC | #7
On Tue, Jan 29, 2019 at 01:10:08PM +0100, Felix Fietkau wrote:
> On 2019-01-29 13:07, Kalle Valo wrote:
> > Felix Fietkau <nbd@nbd.name> writes:
> > 
> >> On 2019-01-29 12:47, Kalle Valo wrote:
> >>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
> >>> 
> >>>> We can configure beaconing, but without TBTT interrupt we
> >>>> can not support PS buffering. This can be added later using
> >>>> kernel hrtimer, if we can keep it in sycn with device timer.
> >>>>
> >>>> I tested AP and IBSS modes.
> >>> 
> >>> So how does this work reliably so that there's no packet loss with
> >>> clients using power save?
> >>
> >> There will be multicast packet loss for clients using power save.
> > 
> > Isn't that a problem? At least as a normal user I would very frustrated
> > if sometimes my connection work and sometimes not, for example if I'm
> > trying discover devices from my network. Hopefully nobody won't use USB
> > devices for any real AP stuff, but still enabling something which we
> > know doesn't work realiably is concerning.
> I agree. Maybe we should leave out the flag for AP mode in this patch
> until we have PS buffering and leave the rest of the code intact.

But how serious problem of dropping multicast frames for PS stations is?
I don't think from user perspective this is "sometimes my connection
work and sometimes not", but something much less annoying. 

Another thing is that this (D)TIM PS is not reliable by design,
that why UAPSD was introduced.

Moreover in the tree we have already bunch of drivers that do 
advertise AP mode support without HOST_BROADCAST_PS_BUFFERING 
like iwlwifi or brcm80211 .

So I don't think we should drop AP flag, AP mode works with
this patch set quite well.

Thanks
Stanislaw
Stanislaw Gruszka Jan. 30, 2019, 8:37 a.m. UTC | #8
On Tue, Jan 29, 2019 at 01:40:57PM +0100, Lorenzo Bianconi wrote:
> > Felix Fietkau <nbd@nbd.name> writes:
> > 
> > > On 2019-01-29 13:07, Kalle Valo wrote:
> > >> Felix Fietkau <nbd@nbd.name> writes:
> > >> 
> > >>> On 2019-01-29 12:47, Kalle Valo wrote:
> > >>>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
> > >>>> 
> > >>>>> We can configure beaconing, but without TBTT interrupt we
> > >>>>> can not support PS buffering. This can be added later using
> > >>>>> kernel hrtimer, if we can keep it in sycn with device timer.
> > >>>>>
> > >>>>> I tested AP and IBSS modes.
> > >>>> 
> > >>>> So how does this work reliably so that there's no packet loss with
> > >>>> clients using power save?
> > >>>
> > >>> There will be multicast packet loss for clients using power save.
> > >> 
> > >> Isn't that a problem? At least as a normal user I would very frustrated
> > >> if sometimes my connection work and sometimes not, for example if I'm
> > >> trying discover devices from my network. Hopefully nobody won't use USB
> > >> devices for any real AP stuff, but still enabling something which we
> > >> know doesn't work realiably is concerning.
> > >
> > > I agree. Maybe we should leave out the flag for AP mode in this patch
> > > until we have PS buffering and leave the rest of the code intact.
> > 
> > At least for me that sounds good.
> 
> We can support ps buffering in AP as well using a hrtimer. In this way we
> can reuse most of the existing code

Yes, but there is issue to address, since kernel timer and device TBT
timer are independed, they possibly can get out of sync after some time,
for example few hours or days. So there is need to prevent/fix this
somehow.

Thanks
Stanislaw
Felix Fietkau Jan. 30, 2019, 9:16 a.m. UTC | #9
On 2019-01-30 09:37, Stanislaw Gruszka wrote:
> On Tue, Jan 29, 2019 at 01:40:57PM +0100, Lorenzo Bianconi wrote:
>> > Felix Fietkau <nbd@nbd.name> writes:
>> > 
>> > > On 2019-01-29 13:07, Kalle Valo wrote:
>> > >> Felix Fietkau <nbd@nbd.name> writes:
>> > >> 
>> > >>> On 2019-01-29 12:47, Kalle Valo wrote:
>> > >>>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
>> > >>>> 
>> > >>>>> We can configure beaconing, but without TBTT interrupt we
>> > >>>>> can not support PS buffering. This can be added later using
>> > >>>>> kernel hrtimer, if we can keep it in sycn with device timer.
>> > >>>>>
>> > >>>>> I tested AP and IBSS modes.
>> > >>>> 
>> > >>>> So how does this work reliably so that there's no packet loss with
>> > >>>> clients using power save?
>> > >>>
>> > >>> There will be multicast packet loss for clients using power save.
>> > >> 
>> > >> Isn't that a problem? At least as a normal user I would very frustrated
>> > >> if sometimes my connection work and sometimes not, for example if I'm
>> > >> trying discover devices from my network. Hopefully nobody won't use USB
>> > >> devices for any real AP stuff, but still enabling something which we
>> > >> know doesn't work realiably is concerning.
>> > >
>> > > I agree. Maybe we should leave out the flag for AP mode in this patch
>> > > until we have PS buffering and leave the rest of the code intact.
>> > 
>> > At least for me that sounds good.
>> 
>> We can support ps buffering in AP as well using a hrtimer. In this way we
>> can reuse most of the existing code
> 
> Yes, but there is issue to address, since kernel timer and device TBT
> timer are independed, they possibly can get out of sync after some time,
> for example few hours or days. So there is need to prevent/fix this
> somehow.
We could read the TSF timer value from the hardware and sync the hrtimer
against that.

- Felix
Felix Fietkau Jan. 30, 2019, 9:25 a.m. UTC | #10
On 2019-01-30 09:29, Stanislaw Gruszka wrote:
> On Tue, Jan 29, 2019 at 01:10:08PM +0100, Felix Fietkau wrote:
>> On 2019-01-29 13:07, Kalle Valo wrote:
>> > Felix Fietkau <nbd@nbd.name> writes:
>> > 
>> >> On 2019-01-29 12:47, Kalle Valo wrote:
>> >>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
>> >>> 
>> >>>> We can configure beaconing, but without TBTT interrupt we
>> >>>> can not support PS buffering. This can be added later using
>> >>>> kernel hrtimer, if we can keep it in sycn with device timer.
>> >>>>
>> >>>> I tested AP and IBSS modes.
>> >>> 
>> >>> So how does this work reliably so that there's no packet loss with
>> >>> clients using power save?
>> >>
>> >> There will be multicast packet loss for clients using power save.
>> > 
>> > Isn't that a problem? At least as a normal user I would very frustrated
>> > if sometimes my connection work and sometimes not, for example if I'm
>> > trying discover devices from my network. Hopefully nobody won't use USB
>> > devices for any real AP stuff, but still enabling something which we
>> > know doesn't work realiably is concerning.
>> I agree. Maybe we should leave out the flag for AP mode in this patch
>> until we have PS buffering and leave the rest of the code intact.
> 
> But how serious problem of dropping multicast frames for PS stations is?
> I don't think from user perspective this is "sometimes my connection
> work and sometimes not", but something much less annoying. 
Actually, if you're considering two stations on an AP trying to connect
to each other, it is exactly "sometimes my connection work and sometimes
not", because of ARP. Clients won't see the ARP requests sent to each
other, if the client being asked is in powersave mode.

> Another thing is that this (D)TIM PS is not reliable by design,
> that why UAPSD was introduced.
UAPSD doesn't replace TIM based powersave indication, and I'm pretty
sure it doesn't handle multicast either.

> Moreover in the tree we have already bunch of drivers that do 
> advertise AP mode support without HOST_BROADCAST_PS_BUFFERING 
> like iwlwifi or brcm80211 .
I haven't looked at the code, but they may be handling buffered
multicast in a different way, possibly with firmware involvement.

- Felix
Stanislaw Gruszka Jan. 30, 2019, 10:07 a.m. UTC | #11
On Wed, Jan 30, 2019 at 10:16:34AM +0100, Felix Fietkau wrote:
> On 2019-01-30 09:37, Stanislaw Gruszka wrote:
> > On Tue, Jan 29, 2019 at 01:40:57PM +0100, Lorenzo Bianconi wrote:
> >> > Felix Fietkau <nbd@nbd.name> writes:
> >> > 
> >> > > On 2019-01-29 13:07, Kalle Valo wrote:
> >> > >> Felix Fietkau <nbd@nbd.name> writes:
> >> > >> 
> >> > >>> On 2019-01-29 12:47, Kalle Valo wrote:
> >> > >>>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
> >> > >>>> 
> >> > >>>>> We can configure beaconing, but without TBTT interrupt we
> >> > >>>>> can not support PS buffering. This can be added later using
> >> > >>>>> kernel hrtimer, if we can keep it in sycn with device timer.
> >> > >>>>>
> >> > >>>>> I tested AP and IBSS modes.
> >> > >>>> 
> >> > >>>> So how does this work reliably so that there's no packet loss with
> >> > >>>> clients using power save?
> >> > >>>
> >> > >>> There will be multicast packet loss for clients using power save.
> >> > >> 
> >> > >> Isn't that a problem? At least as a normal user I would very frustrated
> >> > >> if sometimes my connection work and sometimes not, for example if I'm
> >> > >> trying discover devices from my network. Hopefully nobody won't use USB
> >> > >> devices for any real AP stuff, but still enabling something which we
> >> > >> know doesn't work realiably is concerning.
> >> > >
> >> > > I agree. Maybe we should leave out the flag for AP mode in this patch
> >> > > until we have PS buffering and leave the rest of the code intact.
> >> > 
> >> > At least for me that sounds good.
> >> 
> >> We can support ps buffering in AP as well using a hrtimer. In this way we
> >> can reuse most of the existing code
> > 
> > Yes, but there is issue to address, since kernel timer and device TBT
> > timer are independed, they possibly can get out of sync after some time,
> > for example few hours or days. So there is need to prevent/fix this
> > somehow.
> We could read the TSF timer value from the hardware and sync the hrtimer
> against that.

Ok then. I'll implement hrtimer solution and repost this set. Patch
6 will no longer be necessery.

Regards
Stanislaw
Kalle Valo Jan. 30, 2019, 10:27 a.m. UTC | #12
Stanislaw Gruszka <sgruszka@redhat.com> writes:

> On Tue, Jan 29, 2019 at 01:10:08PM +0100, Felix Fietkau wrote:
>> On 2019-01-29 13:07, Kalle Valo wrote:
>> > Felix Fietkau <nbd@nbd.name> writes:
>> > 
>> >> On 2019-01-29 12:47, Kalle Valo wrote:
>> >>> Stanislaw Gruszka <sgruszka@redhat.com> writes:
>> >>> 
>> >>>> We can configure beaconing, but without TBTT interrupt we
>> >>>> can not support PS buffering. This can be added later using
>> >>>> kernel hrtimer, if we can keep it in sycn with device timer.
>> >>>>
>> >>>> I tested AP and IBSS modes.
>> >>> 
>> >>> So how does this work reliably so that there's no packet loss with
>> >>> clients using power save?
>> >>
>> >> There will be multicast packet loss for clients using power save.
>> > 
>> > Isn't that a problem? At least as a normal user I would very frustrated
>> > if sometimes my connection work and sometimes not, for example if I'm
>> > trying discover devices from my network. Hopefully nobody won't use USB
>> > devices for any real AP stuff, but still enabling something which we
>> > know doesn't work realiably is concerning.
>> I agree. Maybe we should leave out the flag for AP mode in this patch
>> until we have PS buffering and leave the rest of the code intact.
>
> But how serious problem of dropping multicast frames for PS stations
> is?

It's _both_ broadcast and multicast frames. Felix already mentioned ARP
but there are also other protocols which rely on broadcast/multicast
frames.

> I don't think from user perspective this is "sometimes my connection
> work and sometimes not", but something much less annoying.

So basically you are saying that we should just depend on lock and hope
that users don't notice the packet loss. I don't think that's really
good design philosophy.

> Moreover in the tree we have already bunch of drivers that do 
> advertise AP mode support without HOST_BROADCAST_PS_BUFFERING 
> like iwlwifi or brcm80211 .

After seeing how much those drivers are tested I would be very surprised
to see that their broadcast and multicast packet handling is broken.

> So I don't think we should drop AP flag, AP mode works with
> this patch set quite well.

"Works" is a very broad statement and depends on what you have tested.
Sure, if you tested tested with ping and iperf from a client to AP
without using power save mode that will work. But if you try to connect
from another device on the network to another client using aggressive
power saving it's a totally different situation.

Back in the Nokia N800 days I wasted a lot of time debugging all sort of
buggy APs which didn't work correctly with power save, it was really
annoying and very frustrating for the users. Let's not do the same
mistakes, we are better than that.
Stanislaw Gruszka Jan. 30, 2019, 3:22 p.m. UTC | #13
On Wed, Jan 30, 2019 at 11:07:48AM +0100, Stanislaw Gruszka wrote:
> > >> We can support ps buffering in AP as well using a hrtimer. In this way we
> > >> can reuse most of the existing code
> > > 
> > > Yes, but there is issue to address, since kernel timer and device TBT
> > > timer are independed, they possibly can get out of sync after some time,
> > > for example few hours or days. So there is need to prevent/fix this
> > > somehow.
> > We could read the TSF timer value from the hardware and sync the hrtimer
> > against that.
> 
> Ok then. I'll implement hrtimer solution and repost this set. Patch
> 6 will no longer be necessery.

This require more changes than I expected to allow programming registers
from atomic context for mt76-usb. So I'll repost without AP support for
now.

Stanislaw
Stanislaw Gruszka Feb. 5, 2019, 2:58 p.m. UTC | #14
On Wed, Jan 30, 2019 at 04:22:55PM +0100, Stanislaw Gruszka wrote:
> On Wed, Jan 30, 2019 at 11:07:48AM +0100, Stanislaw Gruszka wrote:
> > > >> We can support ps buffering in AP as well using a hrtimer. In this way we
> > > >> can reuse most of the existing code
> > > > 
> > > > Yes, but there is issue to address, since kernel timer and device TBT
> > > > timer are independed, they possibly can get out of sync after some time,
> > > > for example few hours or days. So there is need to prevent/fix this
> > > > somehow.
> > > We could read the TSF timer value from the hardware and sync the hrtimer
> > > against that.
> > 
> > Ok then. I'll implement hrtimer solution and repost this set. Patch
> > 6 will no longer be necessery.
> 
> This require more changes than I expected to allow programming registers
> from atomic context for mt76-usb. So I'll repost without AP support for
> now.

There are more obstacles here. On USB we do not have PSD queue available 
via endpoinds. I have some solutions to this problem, but non of them work
satisfactory so far. Still experimenting ...
 
Stanislaw