2018-09-25 06:49:54

by Stanislaw Gruszka

[permalink] [raw]
Subject: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

TP-LINK Archer T1U do not support 2.4GHz band despite EEPROM
reports that. Add quirk to mask out 2.4GHz support.

Reported-by: Sid Hayn <[email protected]>
Signed-off-by: Stanislaw Gruszka <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c | 5 +++++
drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h | 2 ++
drivers/net/wireless/mediatek/mt76/mt76x0/usb.c | 7 ++++++-
3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
index 18bd80adbb51..3d712f6d7078 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c
@@ -62,6 +62,11 @@ static void mt76x0_set_chip_cap(struct mt76x0_dev *dev)
dev_dbg(dev->mt76.dev, "2GHz %d 5GHz %d\n",
dev->mt76.cap.has_2ghz, dev->mt76.cap.has_5ghz);

+ if (dev->no_2ghz) {
+ dev->mt76.cap.has_2ghz = false;
+ dev_dbg(dev->mt76.dev, "mask out 2GHz support\n");
+ }
+
if (!mt76x02_field_valid(nic_conf1 & 0xff))
nic_conf1 &= 0xff00;

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
index 7e131241344b..242abab69cdb 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/mt76x0.h
@@ -108,6 +108,8 @@ struct mt76x0_dev {
u8 agc_save;
u16 chainmask;

+ bool no_2ghz;
+
struct mac_stats stats;
};

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
index 76d607f73758..b7a1069ecd0e 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
@@ -45,7 +45,8 @@
{ USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
{ USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
{ USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
- { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
+ { USB_DEVICE(0x2357, 0x0105),
+ .driver_info = 1, }, /* TP-LINK Archer T1U */
{ USB_DEVICE_AND_INTERFACE_INFO(0x0E8D, 0x7630, 0xff, 0x2, 0xff)}, /* MT7630U */
{ USB_DEVICE_AND_INTERFACE_INFO(0x0E8D, 0x7650, 0xff, 0x2, 0xff)}, /* MT7650U */
{ 0, }
@@ -222,6 +223,10 @@ static int mt76x0u_probe(struct usb_interface *usb_intf,
if (!dev)
return -ENOMEM;

+ /* Quirk for Archer T1U */
+ if (id->driver_info)
+ dev->no_2ghz = true;
+
usb_dev = usb_get_dev(usb_dev);
usb_reset_device(usb_dev);

--
1.9.3



2018-09-25 07:54:52

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> index 76d607f73758..b7a1069ecd0e 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> @@ -45,7 +45,8 @@
> { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
> { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
> { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
> - { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
> + { USB_DEVICE(0x2357, 0x0105),
> + .driver_info = 1, }, /* TP-LINK Archer T1U */

Hi Stanislaw,

what about using 'ieee80211-freq-limit' OF property to limit available wireless
band? In this way we can take into account even the opposite case (no 5GHz).

Regards,
Lorenzo

2018-09-25 08:00:12

by Felix Fietkau

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

On 2018-09-25 09:54, Lorenzo Bianconi wrote:
>>
>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
>> index 76d607f73758..b7a1069ecd0e 100644
>> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
>> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
>> @@ -45,7 +45,8 @@
>> { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
>> { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
>> { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
>> - { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
>> + { USB_DEVICE(0x2357, 0x0105),
>> + .driver_info = 1, }, /* TP-LINK Archer T1U */
>
> Hi Stanislaw,
>
> what about using 'ieee80211-freq-limit' OF property to limit available wireless
> band? In this way we can take into account even the opposite case (no 5GHz).
That doesn't make sense for USB devices, which can be plugged into any
machine.

- Felix

2018-09-25 09:07:53

by Lorenzo Bianconi

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

On Sep 25, Felix Fietkau wrote:
> On 2018-09-25 09:54, Lorenzo Bianconi wrote:
> >>
> >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> >> index 76d607f73758..b7a1069ecd0e 100644
> >> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> >> @@ -45,7 +45,8 @@
> >> { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
> >> { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
> >> { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
> >> - { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
> >> + { USB_DEVICE(0x2357, 0x0105),
> >> + .driver_info = 1, }, /* TP-LINK Archer T1U */
> >
> > Hi Stanislaw,
> >
> > what about using 'ieee80211-freq-limit' OF property to limit available wireless
> > band? In this way we can take into account even the opposite case (no 5GHz).
> That doesn't make sense for USB devices, which can be plugged into any
> machine.

Ack, right.
What about a more general solution like adding an enum { NO_5GHz = 1, NO_2GHz }?
Does it worth to implement it now?

Regards,
Lorenzo

>
> - Felix

2018-09-25 09:48:44

by Stanislaw Gruszka

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

On Tue, Sep 25, 2018 at 11:07:47AM +0200, Lorenzo Bianconi wrote:
> On Sep 25, Felix Fietkau wrote:
> > On 2018-09-25 09:54, Lorenzo Bianconi wrote:
> > >>
> > >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> > >> index 76d607f73758..b7a1069ecd0e 100644
> > >> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> > >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> > >> @@ -45,7 +45,8 @@
> > >> { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
> > >> { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
> > >> { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
> > >> - { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
> > >> + { USB_DEVICE(0x2357, 0x0105),
> > >> + .driver_info = 1, }, /* TP-LINK Archer T1U */
> > >
> > > Hi Stanislaw,
> > >
> > > what about using 'ieee80211-freq-limit' OF property to limit available wireless
> > > band? In this way we can take into account even the opposite case (no 5GHz).
> > That doesn't make sense for USB devices, which can be plugged into any
> > machine.
>
> Ack, right.
> What about a more general solution like adding an enum { NO_5GHz = 1, NO_2GHz }?
> Does it worth to implement it now?

I do not see reason for that. Basically band information should be
read from EEPROM, I do not expect need for more quirks like this.

Thanks
Stanislaw

2018-09-25 09:55:53

by Arend Van Spriel

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

On 9/25/2018 11:48 AM, Stanislaw Gruszka wrote:
> On Tue, Sep 25, 2018 at 11:07:47AM +0200, Lorenzo Bianconi wrote:
>> On Sep 25, Felix Fietkau wrote:
>>> On 2018-09-25 09:54, Lorenzo Bianconi wrote:
>>>>>
>>>>> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
>>>>> index 76d607f73758..b7a1069ecd0e 100644
>>>>> --- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
>>>>> +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
>>>>> @@ -45,7 +45,8 @@
>>>>> { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
>>>>> { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
>>>>> { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
>>>>> - { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
>>>>> + { USB_DEVICE(0x2357, 0x0105),
>>>>> + .driver_info = 1, }, /* TP-LINK Archer T1U */
>>>>
>>>> Hi Stanislaw,
>>>>
>>>> what about using 'ieee80211-freq-limit' OF property to limit available wireless
>>>> band? In this way we can take into account even the opposite case (no 5GHz).
>>> That doesn't make sense for USB devices, which can be plugged into any
>>> machine.
>>
>> Ack, right.
>> What about a more general solution like adding an enum { NO_5GHz = 1, NO_2GHz }?
>> Does it worth to implement it now?
>
> I do not see reason for that. Basically band information should be
> read from EEPROM, I do not expect need for more quirks like this.

Well. Never say never :-p And the phrase "quirks like this" does seem to
leave the door open for other quirks. Or did you mean "quirks using
driver_info"?

Regards,
Arend


2018-09-25 10:02:06

by Stanislaw Gruszka

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

On Tue, Sep 25, 2018 at 11:55:48AM +0200, Arend van Spriel wrote:
> On 9/25/2018 11:48 AM, Stanislaw Gruszka wrote:
> >On Tue, Sep 25, 2018 at 11:07:47AM +0200, Lorenzo Bianconi wrote:
> >>On Sep 25, Felix Fietkau wrote:
> >>>On 2018-09-25 09:54, Lorenzo Bianconi wrote:
> >>>>>
> >>>>>diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> >>>>>index 76d607f73758..b7a1069ecd0e 100644
> >>>>>--- a/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> >>>>>+++ b/drivers/net/wireless/mediatek/mt76/mt76x0/usb.c
> >>>>>@@ -45,7 +45,8 @@
> >>>>> { USB_DEVICE(0x20f4, 0x806b) }, /* TRENDnet TEW-806UBH */
> >>>>> { USB_DEVICE(0x7392, 0xc711) }, /* Devolo Wifi ac Stick */
> >>>>> { USB_DEVICE(0x0df6, 0x0079) }, /* Sitecom Europe B.V. ac Stick */
> >>>>>- { USB_DEVICE(0x2357, 0x0105) }, /* TP-LINK Archer T1U */
> >>>>>+ { USB_DEVICE(0x2357, 0x0105),
> >>>>>+ .driver_info = 1, }, /* TP-LINK Archer T1U */
> >>>>
> >>>>Hi Stanislaw,
> >>>>
> >>>>what about using 'ieee80211-freq-limit' OF property to limit available wireless
> >>>>band? In this way we can take into account even the opposite case (no 5GHz).
> >>>That doesn't make sense for USB devices, which can be plugged into any
> >>>machine.
> >>
> >>Ack, right.
> >>What about a more general solution like adding an enum { NO_5GHz = 1, NO_2GHz }?
> >>Does it worth to implement it now?
> >
> >I do not see reason for that. Basically band information should be
> >read from EEPROM, I do not expect need for more quirks like this.
>
> Well. Never say never :-p And the phrase "quirks like this" does
> seem to leave the door open for other quirks. Or did you mean
> "quirks using driver_info"?

I mean quirks that mask out band. Anyway if the need for any other
quirk will show up then the things can be modified. Do not see point
for doing it now, when we don't know if new stuff will be used
at all.

Thanks
Stanislaw


2018-09-26 15:42:27

by Felix Fietkau

[permalink] [raw]
Subject: Re: [PATCH] mt76x0: add quirk to disable 2.4GHz band for Archer T1U

On 2018-09-25 08:49, Stanislaw Gruszka wrote:
> TP-LINK Archer T1U do not support 2.4GHz band despite EEPROM
> reports that. Add quirk to mask out 2.4GHz support.
>
> Reported-by: Sid Hayn <[email protected]>
> Signed-off-by: Stanislaw Gruszka <[email protected]>
Merged, thanks.

- Felix