diff mbox series

[RFC/RFT,1/4] mt76x02: configure basic rates and fallback on STA mode

Message ID 1541688430-31855-2-git-send-email-sgruszka@redhat.com (mailing list archive)
State RFC
Delegated to: Kalle Valo
Headers show
Series restore some old mt76x0u behaviour | expand

Commit Message

Stanislaw Gruszka Nov. 8, 2018, 2:47 p.m. UTC
For STA mode configure legacy basic rates according to info
mac80211 provides to us, as well as follback registers, which
are setup in vendor driver under CONFIG_STA_SUPPORT .
For LB_FBK_CFG1 register use values from vendor driver, which
are different for mt76x0 and mt76x2 .

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
 drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Lorenzo Bianconi Nov. 8, 2018, 2:58 p.m. UTC | #1
> For STA mode configure legacy basic rates according to info
> mac80211 provides to us, as well as follback registers, which
> are setup in vendor driver under CONFIG_STA_SUPPORT .
> For LB_FBK_CFG1 register use values from vendor driver, which
> are different for mt76x0 and mt76x2 .
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
>  drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> index 87ce6a51fb05..2be4b527477f 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> @@ -678,6 +678,18 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
>                 tasklet_enable(&dev->pre_tbtt_tasklet);
>         }
>
> +       if (changed & BSS_CHANGED_BASIC_RATES &&
> +           vif->type == NL80211_IFTYPE_STATION) {
> +               mt76_wr(dev, MT_LEGACY_BASIC_RATE, info->basic_rates);
> +               mt76_wr(dev, MT_VHT_HT_FBK_CFG0, 0x65432100);
> +               mt76_wr(dev, MT_VHT_HT_FBK_CFG1, 0xedcba980);
> +               mt76_wr(dev, MT_LG_FBK_CFG0, 0xedcba988);
> +               if (is_mt76x2(dev))
> +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x87872100);
> +               else
> +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x00872100);
> +       }
> +

since these values are constant, why not put them init_vals?

Regards,
Lorenzo

>         if (changed & BSS_CHANGED_BEACON_INT) {
>                 mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
>                                MT_BEACON_TIME_CFG_INTVAL,
> --
> 1.9.3
>
Stanislaw Gruszka Nov. 8, 2018, 3:52 p.m. UTC | #2
On Thu, Nov 08, 2018 at 03:58:29PM +0100, Lorenzo Bianconi wrote:
> > For STA mode configure legacy basic rates according to info
> > mac80211 provides to us, as well as follback registers, which
> > are setup in vendor driver under CONFIG_STA_SUPPORT .
> > For LB_FBK_CFG1 register use values from vendor driver, which
> > are different for mt76x0 and mt76x2 .
> >
> > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> > ---
> >  drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > index 87ce6a51fb05..2be4b527477f 100644
> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
> > @@ -678,6 +678,18 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
> >                 tasklet_enable(&dev->pre_tbtt_tasklet);
> >         }
> >
> > +       if (changed & BSS_CHANGED_BASIC_RATES &&
> > +           vif->type == NL80211_IFTYPE_STATION) {
> > +               mt76_wr(dev, MT_LEGACY_BASIC_RATE, info->basic_rates);
> > +               mt76_wr(dev, MT_VHT_HT_FBK_CFG0, 0x65432100);
> > +               mt76_wr(dev, MT_VHT_HT_FBK_CFG1, 0xedcba980);
> > +               mt76_wr(dev, MT_LG_FBK_CFG0, 0xedcba988);
> > +               if (is_mt76x2(dev))
> > +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x87872100);
> > +               else
> > +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x00872100);
> > +       }
> > +
> 
> since these values are constant, why not put them init_vals?

I wanted them to be used only in STA mode like vendor driver does.
However if we will have AP+STA , we still will configure them,
so better to configure them anyway and put in init_vals .

Thanks
Stanislaw
Felix Fietkau Nov. 8, 2018, 4:02 p.m. UTC | #3
On 2018-11-08 16:52, Stanislaw Gruszka wrote:
> On Thu, Nov 08, 2018 at 03:58:29PM +0100, Lorenzo Bianconi wrote:
>> > For STA mode configure legacy basic rates according to info
>> > mac80211 provides to us, as well as follback registers, which
>> > are setup in vendor driver under CONFIG_STA_SUPPORT .
>> > For LB_FBK_CFG1 register use values from vendor driver, which
>> > are different for mt76x0 and mt76x2 .
>> >
>> > Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
>> > ---
>> >  drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 12 ++++++++++++
>> >  1 file changed, 12 insertions(+)
>> >
>> > diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>> > index 87ce6a51fb05..2be4b527477f 100644
>> > --- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>> > +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
>> > @@ -678,6 +678,18 @@ void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
>> >                 tasklet_enable(&dev->pre_tbtt_tasklet);
>> >         }
>> >
>> > +       if (changed & BSS_CHANGED_BASIC_RATES &&
>> > +           vif->type == NL80211_IFTYPE_STATION) {
>> > +               mt76_wr(dev, MT_LEGACY_BASIC_RATE, info->basic_rates);
>> > +               mt76_wr(dev, MT_VHT_HT_FBK_CFG0, 0x65432100);
>> > +               mt76_wr(dev, MT_VHT_HT_FBK_CFG1, 0xedcba980);
>> > +               mt76_wr(dev, MT_LG_FBK_CFG0, 0xedcba988);
>> > +               if (is_mt76x2(dev))
>> > +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x87872100);
>> > +               else
>> > +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x00872100);
>> > +       }
>> > +
>> 
>> since these values are constant, why not put them init_vals?
> 
> I wanted them to be used only in STA mode like vendor driver does.
> However if we will have AP+STA , we still will configure them,
> so better to configure them anyway and put in init_vals .
Yes, I think we should put them in initvals. Also, I think we should
keep the values the shared between mt76x0 and mt76x2.

For MT_LG_FBK_CFG1 there is no need to make a distinction between 76x2
and 76x0, because 76x0 will simply ignore the upper values (they apply
to 2SS transmission only).
Also, I don't think MT_VHT_HT_FBK_CFG1 even gets used on mt76x0, because
it is for 2SS rates only. However, the value in there seems more useful
than the one we currently use on mt76x2, because it allows fallback from
2SS MCS0 to 1SS MCS0.
The contents of MT_LG_FBK_CFG0 also match the default initialization
values documented in the 7612E datasheet.

I don't think there is any meaningful difference between the 76x2 and
the 76x0 MAC except for the missing 2SS support.

- Felix
Stanislaw Gruszka Dec. 7, 2018, 1:25 p.m. UTC | #4
On Thu, Nov 08, 2018 at 05:02:14PM +0100, Felix Fietkau wrote:
> >> > +       if (changed & BSS_CHANGED_BASIC_RATES &&
> >> > +           vif->type == NL80211_IFTYPE_STATION) {
> >> > +               mt76_wr(dev, MT_LEGACY_BASIC_RATE, info->basic_rates);

It's a bit hard to interpret how vendor driver set LEGACY_BIT_RATE
in MlmeUpdateTxRates(). It seems to always enable bits for
OFDM6/OFDM12/OFDM24 (bitmask 0x150) or maybe just do this for 5GHz,
I'm not sure. Need more investigation on this.
 
> >> > +               mt76_wr(dev, MT_VHT_HT_FBK_CFG0, 0x65432100);
> >> > +               mt76_wr(dev, MT_VHT_HT_FBK_CFG1, 0xedcba980);
> >> > +               mt76_wr(dev, MT_LG_FBK_CFG0, 0xedcba988);
> >> > +               if (is_mt76x2(dev))
> >> > +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x87872100);
> >> > +               else
> >> > +                       mt76_wr(dev, MT_LG_FBK_CFG1, 0x00872100);
> >> > +       }
> >> > +
> >> 
> >> since these values are constant, why not put them init_vals?
> > 
> > I wanted them to be used only in STA mode like vendor driver does.
> > However if we will have AP+STA , we still will configure them,
> > so better to configure them anyway and put in init_vals .
> Yes, I think we should put them in initvals. Also, I think we should
> keep the values the shared between mt76x0 and mt76x2.
> 
> For MT_LG_FBK_CFG1 there is no need to make a distinction between 76x2
> and 76x0, because 76x0 will simply ignore the upper values (they apply
> to 2SS transmission only).
> Also, I don't think MT_VHT_HT_FBK_CFG1 even gets used on mt76x0, because
> it is for 2SS rates only. However, the value in there seems more useful
> than the one we currently use on mt76x2, because it allows fallback from
> 2SS MCS0 to 1SS MCS0.
> The contents of MT_LG_FBK_CFG0 also match the default initialization
> values documented in the 7612E datasheet.
> 
> I don't think there is any meaningful difference between the 76x2 and
> the 76x0 MAC except for the missing 2SS support.

Since there are different initvals tables for mt76x2 and mt76x0, I use
different values of MT_LG_FBK_CFG1. Will post a patches soon, please
comment there, if something is not correct.

Thanks
Stanislaw
diff mbox series

Patch

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index 87ce6a51fb05..2be4b527477f 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -678,6 +678,18 @@  void mt76x02_bss_info_changed(struct ieee80211_hw *hw,
 		tasklet_enable(&dev->pre_tbtt_tasklet);
 	}
 
+	if (changed & BSS_CHANGED_BASIC_RATES &&
+	    vif->type == NL80211_IFTYPE_STATION) {
+		mt76_wr(dev, MT_LEGACY_BASIC_RATE, info->basic_rates);
+		mt76_wr(dev, MT_VHT_HT_FBK_CFG0, 0x65432100);
+		mt76_wr(dev, MT_VHT_HT_FBK_CFG1, 0xedcba980);
+		mt76_wr(dev, MT_LG_FBK_CFG0, 0xedcba988);
+		if (is_mt76x2(dev))
+			mt76_wr(dev, MT_LG_FBK_CFG1, 0x87872100);
+		else
+			mt76_wr(dev, MT_LG_FBK_CFG1, 0x00872100);
+	}
+
 	if (changed & BSS_CHANGED_BEACON_INT) {
 		mt76_rmw_field(dev, MT_BEACON_TIME_CFG,
 			       MT_BEACON_TIME_CFG_INTVAL,