Add the capability to configure ack timeout and slottime to mt7615 driver.
Fix coverage_class definition in mt76x02 driver.
Set 0 as minimum configurable value for coverage_class since mt76 does
not support dynack.
Changes since v1:
- drop patch 2/3 'mt76: move coverage_class and slottime in mt76_dev'
- set 0 as minimum configurable value for coverage_class
Lorenzo Bianconi (3):
mt76: mt76x02: fix coverage_class type
mt76: mt7603: set 0 as min coverage_class value
mt76: mt7615: add set_coverage class support
.../net/wireless/mediatek/mt76/mt7603/main.c | 2 +-
.../net/wireless/mediatek/mt76/mt7615/init.c | 1 +
.../net/wireless/mediatek/mt76/mt7615/mac.c | 41 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7615/main.c | 20 +++++++++
.../wireless/mediatek/mt76/mt7615/mt7615.h | 7 ++++
.../net/wireless/mediatek/mt76/mt7615/regs.h | 21 ++++++++++
drivers/net/wireless/mediatek/mt76/mt76x02.h | 2 +-
.../net/wireless/mediatek/mt76/mt76x02_util.c | 2 +-
8 files changed, 93 insertions(+), 3 deletions(-)
--
2.21.0
Fix coverage_class type in mt76x02_dev data structure since
coverage_class can be negative to enable dynack (just supported by
ath9k). Set 0 as minimum value for coverage_class
Fixes: 7bc04215a66b ("mt76: add driver code for MT76x2e")
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt76x02.h | 2 +-
drivers/net/wireless/mediatek/mt76/mt76x02_util.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h
index 0ca0bbfe8769..cdc1cbd1d392 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h
@@ -110,7 +110,7 @@ struct mt76x02_dev {
bool no_2ghz;
- u8 coverage_class;
+ s16 coverage_class;
u8 slottime;
struct mt76x02_dfs_pattern_detector dfs_pd;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
index c0500d8f9a67..dd0fc87ee9a7 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x02_util.c
@@ -544,7 +544,7 @@ void mt76x02_set_coverage_class(struct ieee80211_hw *hw,
struct mt76x02_dev *dev = hw->priv;
mutex_lock(&dev->mt76.mutex);
- dev->coverage_class = coverage_class;
+ dev->coverage_class = max_t(s16, coverage_class, 0);
mt76x02_set_tx_ackto(dev);
mutex_unlock(&dev->mt76.mutex);
}
--
2.21.0
Add the capability to configure actimeout for mt7615 driver. Moreover
configure slottime according to the value provided by mac80211
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7615/init.c | 1 +
.../net/wireless/mediatek/mt76/mt7615/mac.c | 41 +++++++++++++++++++
.../net/wireless/mediatek/mt76/mt7615/main.c | 20 +++++++++
.../wireless/mediatek/mt76/mt7615/mt7615.h | 7 ++++
.../net/wireless/mediatek/mt76/mt7615/regs.h | 21 ++++++++++
5 files changed, 90 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
index 553bd4d988f7..ed1cacd9a43d 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
@@ -304,6 +304,7 @@ int mt7615_register_device(struct mt7615_dev *dev)
IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK |
IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
dev->dfs_state = -1;
+ dev->slottime = 9;
ret = mt76_register_device(&dev->mt76, true, mt7615_rates,
ARRAY_SIZE(mt7615_rates));
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
index c77adc5d2552..cead1bb1b578 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
@@ -60,6 +60,47 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
}
+/* XXX: DBDC support */
+void mt7615_mac_set_timing(struct mt7615_dev *dev)
+{
+ u32 cck = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 231) |
+ FIELD_PREP(MT_TIMEOUT_VAL_CCA, 48);
+ u32 ofdm = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, 60) |
+ FIELD_PREP(MT_TIMEOUT_VAL_CCA, 24);
+ int offset = 3 * dev->coverage_class;
+ u32 reg_offset = FIELD_PREP(MT_TIMEOUT_VAL_PLCP, offset) |
+ FIELD_PREP(MT_TIMEOUT_VAL_CCA, offset);
+ int sifs;
+ u32 val;
+
+ if (dev->mt76.chandef.chan->band == NL80211_BAND_5GHZ)
+ sifs = 16;
+ else
+ sifs = 10;
+
+ mt76_set(dev, MT_ARB_SCR,
+ MT_ARB_SCR_TX0_DISABLE | MT_ARB_SCR_RX0_DISABLE);
+ udelay(1);
+
+ mt76_wr(dev, MT_TMAC_CDTR, cck + reg_offset);
+ mt76_wr(dev, MT_TMAC_ODTR, ofdm + reg_offset);
+ mt76_wr(dev, MT_TMAC_ICR0,
+ FIELD_PREP(MT_IFS_EIFS, 360) |
+ FIELD_PREP(MT_IFS_RIFS, 2) |
+ FIELD_PREP(MT_IFS_SIFS, sifs) |
+ FIELD_PREP(MT_IFS_SLOT, dev->slottime));
+
+ if (dev->slottime < 20)
+ val = MT7615_CFEND_RATE_DEFAULT;
+ else
+ val = MT7615_CFEND_RATE_11B;
+
+ mt76_rmw_field(dev, MT_AGG_ACR0, MT_AGG_ACR_CFEND_RATE, val);
+
+ mt76_clear(dev, MT_ARB_SCR,
+ MT_ARB_SCR_TX0_DISABLE | MT_ARB_SCR_RX0_DISABLE);
+}
+
int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb)
{
struct mt76_rx_status *status = (struct mt76_rx_status *)skb->cb;
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/main.c b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
index 78bbed7a4645..45dac03834d0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/main.c
@@ -155,6 +155,7 @@ static int mt7615_set_channel(struct mt7615_dev *dev)
if (ret)
goto out;
+ mt7615_mac_set_timing(dev);
ret = mt7615_dfs_init_radar_detector(dev);
mt7615_mac_cca_stats_reset(dev);
dev->mt76.survey_time = ktime_get_boottime();
@@ -327,6 +328,15 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
if (changed & BSS_CHANGED_ASSOC)
mt7615_mcu_set_bss_info(dev, vif, info->assoc);
+ if (changed & BSS_CHANGED_ERP_SLOT) {
+ int slottime = info->use_short_slot ? 9 : 20;
+
+ if (slottime != dev->slottime) {
+ dev->slottime = slottime;
+ mt7615_mac_set_timing(dev);
+ }
+ }
+
/* TODO: update beacon content
* BSS_CHANGED_BEACON
*/
@@ -520,6 +530,15 @@ mt7615_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
return 0;
}
+static void
+mt7615_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
+{
+ struct mt7615_dev *dev = hw->priv;
+
+ dev->coverage_class = max_t(s16, coverage_class, 0);
+ mt7615_mac_set_timing(dev);
+}
+
const struct ieee80211_ops mt7615_ops = {
.tx = mt7615_tx,
.start = mt7615_start,
@@ -543,4 +562,5 @@ const struct ieee80211_ops mt7615_ops = {
.channel_switch_beacon = mt7615_channel_switch_beacon,
.get_survey = mt76_get_survey,
.get_antenna = mt76_get_antenna,
+ .set_coverage_class = mt7615_set_coverage_class,
};
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index d537f68c5531..1e29e4333335 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -36,6 +36,9 @@
#define MT_FRAC_SCALE 12
#define MT_FRAC(val, div) (((val) << MT_FRAC_SCALE) / (div))
+#define MT7615_CFEND_RATE_DEFAULT 0x69 /* chip default (24M) */
+#define MT7615_CFEND_RATE_11B 0x03 /* 11B LP, 11M */
+
struct mt7615_vif;
struct mt7615_sta;
@@ -105,6 +108,9 @@ struct mt7615_dev {
s8 cck_sensitivity;
bool scs_en;
+ s16 coverage_class;
+ u8 slottime;
+
spinlock_t token_lock;
struct idr token;
};
@@ -246,6 +252,7 @@ int mt7615_mac_write_txwi(struct mt7615_dev *dev, __le32 *txwi,
struct sk_buff *skb, struct mt76_wcid *wcid,
struct ieee80211_sta *sta, int pid,
struct ieee80211_key_conf *key);
+void mt7615_mac_set_timing(struct mt7615_dev *dev);
int mt7615_mac_fill_rx(struct mt7615_dev *dev, struct sk_buff *skb);
void mt7615_mac_add_txs(struct mt7615_dev *dev, void *data);
void mt7615_mac_tx_free(struct mt7615_dev *dev, struct sk_buff *skb);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
index 61a4aa9ac6e6..5ac52758d7b1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
@@ -153,14 +153,35 @@
#define MT_AGG_SCR MT_WF_AGG(0x0fc)
#define MT_AGG_SCR_NLNAV_MID_PTEC_DIS BIT(3)
+#define MT_WF_ARB_BASE 0x20c00
+#define MT_WF_ARB(ofs) (MT_WF_ARB_BASE + (ofs))
+
+#define MT_ARB_SCR MT_WF_ARB(0x080)
+#define MT_ARB_SCR_TX0_DISABLE BIT(8)
+#define MT_ARB_SCR_RX0_DISABLE BIT(9)
+#define MT_ARB_SCR_TX1_DISABLE BIT(10)
+#define MT_ARB_SCR_RX1_DISABLE BIT(11)
+
#define MT_WF_TMAC_BASE 0x21000
#define MT_WF_TMAC(ofs) (MT_WF_TMAC_BASE + (ofs))
+#define MT_TMAC_CDTR MT_WF_TMAC(0x090)
+#define MT_TMAC_ODTR MT_WF_TMAC(0x094)
+#define MT_TIMEOUT_VAL_PLCP GENMASK(15, 0)
+#define MT_TIMEOUT_VAL_CCA GENMASK(31, 16)
+
#define MT_TMAC_TRCR0 MT_WF_TMAC(0x09c)
#define MT_TMAC_TRCR1 MT_WF_TMAC(0x070)
#define MT_TMAC_TRCR_CCA_SEL GENMASK(31, 30)
#define MT_TMAC_TRCR_SEC_CCA_SEL GENMASK(29, 28)
+#define MT_TMAC_ICR0 MT_WF_TMAC(0x0a4)
+#define MT_TMAC_ICR1 MT_WF_TMAC(0x074)
+#define MT_IFS_EIFS GENMASK(8, 0)
+#define MT_IFS_RIFS GENMASK(14, 10)
+#define MT_IFS_SIFS GENMASK(22, 16)
+#define MT_IFS_SLOT GENMASK(30, 24)
+
#define MT_TMAC_CTCR0 MT_WF_TMAC(0x0f4)
#define MT_TMAC_CTCR0_INS_DDLMT_REFTIME GENMASK(5, 0)
#define MT_TMAC_CTCR0_INS_DDLMT_DENSITY GENMASK(15, 12)
--
2.21.0
Set 0 as minimum configurable value for coverage_class since mt76 does
not support dynack
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7603/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/main.c b/drivers/net/wireless/mediatek/mt76/mt7603/main.c
index d31c9d307c2d..3ff822863391 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7603/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7603/main.c
@@ -635,7 +635,7 @@ mt7603_set_coverage_class(struct ieee80211_hw *hw, s16 coverage_class)
{
struct mt7603_dev *dev = hw->priv;
- dev->coverage_class = coverage_class;
+ dev->coverage_class = max_t(s16, coverage_class, 0);
mt7603_mac_set_timing(dev);
}
--
2.21.0
Lorenzo Bianconi <[email protected]> writes:
> Add the capability to configure actimeout for mt7615 driver. Moreover
acktimeout?
> configure slottime according to the value provided by mac80211
>
> Signed-off-by: Lorenzo Bianconi <[email protected]>
[...]
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> @@ -60,6 +60,47 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
> mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
> }
>
> +/* XXX: DBDC support */
> +void mt7615_mac_set_timing(struct mt7615_dev *dev)
Should this be "FIXME:"? Thought don't remember what style is used in
mt76.
--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> Lorenzo Bianconi <[email protected]> writes:
>
> > Add the capability to configure actimeout for mt7615 driver. Moreover
>
> acktimeout?
Hi Kalle,
yes, it suppposed to be acktimeout
>
> > configure slottime according to the value provided by mac80211
> >
> > Signed-off-by: Lorenzo Bianconi <[email protected]>
>
> [...]
>
> > --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> > @@ -60,6 +60,47 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
> > mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
> > }
> >
> > +/* XXX: DBDC support */
> > +void mt7615_mac_set_timing(struct mt7615_dev *dev)
>
> Should this be "FIXME:"? Thought don't remember what style is used in
> mt76.
actually for DBDC we used TODO. Should I resend?
Regards,
Lorenzo
>
> --
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Lorenzo Bianconi <[email protected]> writes:
>> Lorenzo Bianconi <[email protected]> writes:
>>
>> > Add the capability to configure actimeout for mt7615 driver. Moreover
>>
>> acktimeout?
>
> Hi Kalle,
>
> yes, it suppposed to be acktimeout
>
>>
>> > configure slottime according to the value provided by mac80211
>> >
>> > Signed-off-by: Lorenzo Bianconi <[email protected]>
>>
>> [...]
>>
>> > --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
>> > @@ -60,6 +60,47 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
>> > mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
>> > }
>> >
>> > +/* XXX: DBDC support */
>> > +void mt7615_mac_set_timing(struct mt7615_dev *dev)
>>
>> Should this be "FIXME:"? Thought don't remember what style is used in
>> mt76.
>
> actually for DBDC we used TODO.
Even better.
> Should I resend?
No strong feelings from me, just wanted to point out while reviewing the
pathces. Up to Felix :)
--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
> Lorenzo Bianconi <[email protected]> writes:
>
> >> Lorenzo Bianconi <[email protected]> writes:
> >>
> >> > Add the capability to configure actimeout for mt7615 driver. Moreover
> >>
> >> acktimeout?
> >
> > Hi Kalle,
> >
> > yes, it suppposed to be acktimeout
> >
> >>
> >> > configure slottime according to the value provided by mac80211
> >> >
> >> > Signed-off-by: Lorenzo Bianconi <[email protected]>
> >>
> >> [...]
> >>
> >> > --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> >> > +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c
> >> > @@ -60,6 +60,47 @@ void mt7615_mac_reset_counters(struct mt7615_dev *dev)
> >> > mt76_set(dev, MT_WF_RMAC_MIB_AIRTIME0, MT_WF_RMAC_MIB_RXTIME_CLR);
> >> > }
> >> >
> >> > +/* XXX: DBDC support */
> >> > +void mt7615_mac_set_timing(struct mt7615_dev *dev)
> >>
> >> Should this be "FIXME:"? Thought don't remember what style is used in
> >> mt76.
> >
> > actually for DBDC we used TODO.
>
> Even better.
>
> > Should I resend?
>
> No strong feelings from me, just wanted to point out while reviewing the
> pathces. Up to Felix :)
ack, both ways are fine for me.
Regards,
Lorenzo
>
> --
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
>