introduce single-sku support for mt7663/mt7921 drivers
Subsystems (4)
Lorenzo Bianconi
maintainerv2 cover introduce single-sku support for mt7663/mt7921 drivers
Add per-rate power limitations for 802.11n/802.11ac/802.11ax rates to mt7663/mt7921 drivers.
Introduce per-rate power limit dts parsing/binding.
Changes since v1:
- drop patch 1/8 and move regdomain property in mt76.yaml
- various power-limits property fixes in mt76.yaml
Felix Fietkau (2):
mt76: add functions for parsing rate power limits from DT
mt76: mt7615: implement support for using DT rate power limits
Lorenzo Bianconi (3):
dt-bindings:net:wireless:mediatek,mt76: introduce power-limits node
mt76: mt7615: do not use mt7615 single-sku values for mt7663
mt76: introduce single-sku support for mt7663/mt7921
Sean Wang (1):
mt76: mt7921: add dumping Tx power table
Shayne Chen (1):
mt76: extend DT rate power limits to support 11ax devices
.../bindings/net/wireless/mediatek,mt76.yaml | 96 ++++++++ drivers/net/wireless/mediatek/mt76/eeprom.c | 220 ++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 13 ++ .../net/wireless/mediatek/mt76/mt7615/init.c | 15 +- .../net/wireless/mediatek/mt76/mt7615/main.c | 4 + .../net/wireless/mediatek/mt76/mt7615/mcu.c | 66 +++++- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 133 +++++++++++ .../wireless/mediatek/mt76/mt76_connac_mcu.h | 24 ++ .../wireless/mediatek/mt76/mt7921/debugfs.c | 79 +++++++ .../net/wireless/mediatek/mt76/mt7921/init.c | 2 + .../net/wireless/mediatek/mt76/mt7921/main.c | 4 + .../net/wireless/mediatek/mt76/mt7921/mcu.c | 23 ++ .../net/wireless/mediatek/mt76/mt7921/mcu.h | 17 ++ .../wireless/mediatek/mt76/mt7921/mt7921.h | 31 +++ 14 files changed, 724 insertions(+), 3 deletions(-)
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 1/7 dt-bindings:net:wireless:mediatek,mt76: introduce power-limits node
Introduce power-limits node in mt76 binding in order to specify per-rate power limit values for each 802.11n/802.11ac rate
--- .../bindings/net/wireless/mediatek,mt76.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+)
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +96 -0
@@ -72,6 +72,79 @@ properties: led-sources: maxItems: 1 + power-limits: + type: object + patternProperties: + "^r[0-9]+": + type: object + properties: + regdomain: + $ref: /schemas/types.yaml#/definitions/string + description: + Regdomain refers to a legal regulatory region. Different + countries define different levels of allowable transmitter + power, time that a channel can be occupied, and different + available channels + enum: + - FCC + - ETSI + - JP + + patternProperties: + "^txpower-[256]g$": + type: object + patternProperties: + "^b[0-9]+$": + type: object + properties: + channels: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + description: + Pairs of first and last channel number of the selected + band + + rates-cck: + $ref: /schemas/types.yaml#/definitions/uint8-array + minItems: 4 + maxItems: 4 + description: + 4 half-dBm per-rate power limit values + + rates-ofdm: + $ref: /schemas/types.yaml#/definitions/uint8-array + minItems: 8 + maxItems: 8 + description: + 8 half-dBm per-rate power limit values + + rates-mcs: + $ref: /schemas/types.yaml#/definitions/uint8-matrix + description: + Sets of per-rate power limit values for 802.11n/802.11ac + rates for multiple channel bandwidth settings. + Each set starts with the number of channel bandwidth + settings for which the rate set applies, followed by + either 8 or 10 power limit values. The order of the + channel bandwidth settings is 20, 40, 80 and 160 MHz. + + rates-ru: + $ref: /schemas/types.yaml#/definitions/uint8-matrix + description: + Sets of per-rate power limit values for 802.11ax rates + for multiple channel bandwidth or resource unit settings. + Each set starts with the number of channel bandwidth or + resource unit settings for which the rate set applies, + followed by 12 power limit values. The order of the + channel resource unit settings is RU26, RU52, RU106, + RU242/SU20, RU484/SU40, RU996/SU80 and RU2x996/SU160. + + txs-delta: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Half-dBm power delta for different numbers of antennas + required: - compatible - reg
@@ -93,6 +166,29 @@ examples: led { led-sources = <2>; }; + + power-limits { + r0 { + regdomain = "FCC"; + txpower-5g { + b0 { + channels = <36 48>; + rates-ofdm = /bits/ 8 <23 23 23 23 23 23 23 23>; + rates-mcs = /bits/ 8 <1 23 23 23 23 23 23 23 23 23 23>, + <3 22 22 22 22 22 22 22 22 22 22>; + rates-ru = /bits/ 8 <3 22 22 22 22 22 22 22 22 22 22 22 22>, + <4 20 20 20 20 20 20 20 20 20 20 20 20>; + }; + b1 { + channels = <100 181>; + rates-ofdm = /bits/ 8 <14 14 14 14 14 14 14 14>; + rates-mcs = /bits/ 8 <4 14 14 14 14 14 14 14 14 14 14>; + txs-delta = <12 9 6>; + rates-ru = /bits/ 8 <7 14 14 14 14 14 14 14 14 14 14 14 14>; + }; + }; + }; + }; }; };
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 2/7 mt76: add functions for parsing rate power limits from DT
In reply to Lorenzo BianconiFrom: Felix Fietkau <[email protected]>
This subnode can be used to set per-rate tx power limits either per country code / regdomain or globally.
These limits are typically provided by the device manufacturers and are used to limit sideband emissions and stay within regulatory limits
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 204 ++++++++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 12 ++ 2 files changed, 216 insertions(+)
drivers/net/wireless/mediatek/mt76/eeprom.c +204 -0
@@ -111,6 +111,210 @@ mt76_eeprom_override(struct mt76_phy *phy) }EXPORT_SYMBOL_GPL (mt76_eeprom_override); +static bool mt76_string_prop_find (struct property *prop,const char *str) +{ +const char *cp =NULL ; + +if (!prop || !str || !str[0 ]) +return false; + +while ((cp =of_prop_next_string (prop, cp)) !=NULL ) +if (!strcasecmp (cp, str)) +return true; + +return false; +} + +static struct device_node * +mt76_find_power_limits_node (struct mt76_dev *dev) +{ +struct device_node *np = dev->dev->of_node; +const char *const region_names[] = { + [NL80211_DFS_ETSI ] ="etsi" , + [NL80211_DFS_FCC ] ="fcc" , + [NL80211_DFS_JP ] ="jp" , + }; +struct device_node *cur, *fallback =NULL ; +const char *region_name =NULL ; + +if (dev->region <ARRAY_SIZE (region_names)) + region_name = region_names[dev->region]; + + np =of_get_child_by_name (np,"power-limits" ); +if (!np) +return NULL ; + +for_each_child_of_node (np, cur) { +struct property *country =of_find_property (cur,"country" ,NULL ); +struct property *regd =of_find_property (cur,"regdomain" ,NULL ); + +if (!country && !regd) { + fallback = cur; +continue ; + } + +if (mt76_string_prop_find (country, dev->alpha2) || +mt76_string_prop_find (regd, region_name)) +return cur; + } + +return fallback; +} + +static const __be32 * +mt76_get_of_array (struct device_node *np,char *name,size_t *len,int min) +{ +struct property *prop =of_find_property (np, name,NULL ); + +if (!prop || !prop->value || prop->length < min *4 ) +return NULL ; + + *len = prop->length; + +return prop->value; +} + +static struct device_node * +mt76_find_channel_node (struct device_node *np,struct ieee80211_channel *chan) +{ +struct device_node *cur; +const __be32 *val; +size_t len; + +for_each_child_of_node (np, cur) { + val =mt76_get_of_array (cur,"channels" , &len,2 ); +if (!val) +continue ; + +while (len >=2 *sizeof (*val)) { +if (chan->hw_value >=be32_to_cpu (val[0 ]) && + chan->hw_value <=be32_to_cpu (val[1 ])) +return cur; + + val +=2 ; + len -=2 *sizeof (*val); + } + } + +return NULL ; +} + +static s8 +mt76_get_txs_delta (struct device_node *np,u8 nss) +{ +const __be32 *val; +size_t len; + + val =mt76_get_of_array (np,"txs-delta" , &len, nss); +if (!val) +return 0 ; + +return be32_to_cpu (val[nss -1 ]); +} + +static void +mt76_apply_array_limit (s8 *pwr,size_t pwr_len,const __be32 *data, +s8 target_power,s8 nss_delta,s8 *max_power) +{ +int i; + +if (!data) +return ; + +for (i =0 ; i < pwr_len; i++) { + pwr[i] =min_t (s8, target_power, +be32_to_cpu (data[i]) + nss_delta); + *max_power =max (*max_power, pwr[i]); + } +} + +s8 mt76_get_rate_power_limits (struct mt76_phy *phy, +struct ieee80211_channel *chan, +struct mt76_power_limits *dest, +s8 target_power) +{ +struct mt76_dev *dev = phy->dev; +struct device_node *np; +const __be32 *val; +char name[16 ]; +u32 mcs_rates = dev->drv->mcs_rates; +char band; +size_t len; +int i, cur; +s8 max_power =0 ; +s8 txs_delta; + +if (!mcs_rates) + mcs_rates =10 ; + +memset (dest, target_power,sizeof (*dest)); + +if (!IS_ENABLED (CONFIG_OF )) +return target_power; + + np =mt76_find_power_limits_node (dev); +if (!np) +return target_power; + +switch (chan->band) { +case NL80211_BAND_2GHZ : + band ='2' ; +break ; +case NL80211_BAND_5GHZ : + band ='5' ; +break ; +default : +return target_power; + } + +snprintf (name,sizeof (name),"txpower-%cg" , band); + np =of_get_child_by_name (np, name); +if (!np) +return target_power; + + np =mt76_find_channel_node (np, chan); +if (!np) +return target_power; + + txs_delta =mt76_get_txs_delta (np,hweight8 (phy->antenna_mask)); + + val =mt76_get_of_array (np,"rates-cck" , &len,ARRAY_SIZE (dest->cck)); +mt76_apply_array_limit (dest->cck,ARRAY_SIZE (dest->cck), val, + target_power, txs_delta, &max_power); + + val =mt76_get_of_array (np,"rates-ofdm" , + &len,ARRAY_SIZE (dest->ofdm)); +mt76_apply_array_limit (dest->ofdm,ARRAY_SIZE (dest->ofdm), val, + target_power, txs_delta, &max_power); + + val =mt76_get_of_array (np,"rates-mcs" , &len, mcs_rates +1 ); +if (!val) +return max_power; + + len /=4 ; + cur =be32_to_cpu (val[0 ]); +for (i =0 ; i <ARRAY_SIZE (dest->mcs); i++) { +if (len < mcs_rates +1 ) +break ; + +mt76_apply_array_limit (dest->mcs[i],ARRAY_SIZE (dest->mcs[i]), + val +1 , target_power, txs_delta, + &max_power); +if (--cur >0 ) +continue ; + + val += mcs_rates +1 ; + len -= mcs_rates +1 ; +if (!len) +break ; + + cur =be32_to_cpu (val[0 ]); + } + +return max_power; +} +EXPORT_SYMBOL_GPL (mt76_get_rate_power_limits); +int mt76_eeprom_init (struct mt76_dev *dev,int len) {
drivers/net/wireless/mediatek/mt76/mt76.h +12 -0
@@ -331,6 +331,7 @@ struct mt76_driver_ops {u32 drv_flags;u32 survey_flags;u16 txwi_size; +u8 mcs_rates;void (*update_survey)(struct mt76_dev *dev);
@@ -710,6 +711,12 @@ struct mt76_dev { }; }; +struct mt76_power_limits { +s8 cck[4 ]; +s8 ofdm[8 ]; +s8 mcs[4 ][10 ]; +}; +enum mt76_phy_type {MT_PHY_TYPE_CCK ,MT_PHY_TYPE_OFDM ,
@@ -1193,4 +1200,9 @@ mt76_mcu_skb_send_msg(struct mt76_dev *dev, struct sk_buff *skb, int cmd,void mt76_set_irq_mask (struct mt76_dev *dev,u32 addr,u32 clear,u32 set); +s8 mt76_get_rate_power_limits (struct mt76_phy *phy, +struct ieee80211_channel *chan, +struct mt76_power_limits *dest, +s8 target_power); +#endif
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 3/7 mt76: extend DT rate power limits to support 11ax devices
In reply to Lorenzo BianconiFrom: Shayne Chen <[email protected]>
Enable parsing per-rate txpower limits from DT for 11ax chipsets.
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 62 +++++++++++++-------- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + 2 files changed, 40 insertions(+), 23 deletions(-)
drivers/net/wireless/mediatek/mt76/eeprom.c +39 -23
@@ -228,6 +228,36 @@ mt76_apply_array_limit(s8 *pwr, size_t pwr_len, const __be32 *data, } } +static void +mt76_apply_multi_array_limit (s8 *pwr,size_t pwr_len,s8 pwr_num, +const __be32 *data,size_t len,s8 target_power, +s8 nss_delta,s8 *max_power) +{ +int i, cur; + +if (!data) +return ; + + len /=4 ; + cur =be32_to_cpu (data[0 ]); +for (i =0 ; i < pwr_num; i++) { +if (len < pwr_len +1 ) +break ; + +mt76_apply_array_limit (pwr + pwr_len * i, pwr_len, data +1 , + target_power, nss_delta, max_power); +if (--cur >0 ) +continue ; + + data += pwr_len +1 ; + len -= pwr_len +1 ; +if (!len) +break ; + + cur =be32_to_cpu (data[0 ]); + } +} + s8 mt76_get_rate_power_limits(struct mt76_phy *phy, struct ieee80211_channel *chan, struct mt76_power_limits *dest,
@@ -238,9 +268,9 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy,const __be32 *val;char name[16 ];u32 mcs_rates = dev->drv->mcs_rates; +u32 ru_rates =ARRAY_SIZE (dest->ru[0 ]);char band;size_t len; -int i, cur;s8 max_power =0 ;s8 txs_delta;
@@ -288,28 +318,14 @@ s8 mt76_get_rate_power_limits(struct mt76_phy *phy, target_power, txs_delta, &max_power); val =mt76_get_of_array (np,"rates-mcs" , &len, mcs_rates +1 ); -if (!val) -return max_power; - - len /=4 ; - cur =be32_to_cpu (val[0 ]); -for (i =0 ; i <ARRAY_SIZE (dest->mcs); i++) { -if (len < mcs_rates +1 ) -break ; - -mt76_apply_array_limit (dest->mcs[i],ARRAY_SIZE (dest->mcs[i]), - val +1 , target_power, txs_delta, - &max_power); -if (--cur >0 ) -continue ; - - val += mcs_rates +1 ; - len -= mcs_rates +1 ; -if (!len) -break ; - - cur =be32_to_cpu (val[0 ]); - } +mt76_apply_multi_array_limit (dest->mcs[0 ],ARRAY_SIZE (dest->mcs[0 ]), +ARRAY_SIZE (dest->mcs), val, len, + target_power, txs_delta, &max_power); + + val =mt76_get_of_array (np,"rates-ru" , &len, ru_rates +1 ); +mt76_apply_multi_array_limit (dest->ru[0 ],ARRAY_SIZE (dest->ru[0 ]), +ARRAY_SIZE (dest->ru), val, len, + target_power, txs_delta, &max_power);return max_power; }
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -715,6 +715,7 @@ struct mt76_power_limits {s8 cck[4 ];s8 ofdm[8 ];s8 mcs[4 ][10 ]; +s8 ru[7 ][12 ]; };enum mt76_phy_type {
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 4/7 mt76: mt7615: implement support for using DT rate power limits
In reply to Lorenzo BianconiFrom: Felix Fietkau <[email protected]>
Limits are used to update the channel max_power settings and also passed to the firmware on channel changes
--- .../net/wireless/mediatek/mt76/mt7615/init.c | 10 ++- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 61 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +9 -1
@@ -252,6 +252,7 @@ void mt7615_init_txpower(struct mt7615_dev *dev,int delta_idx, delta =mt76_tx_power_nss_delta (n_chains);u8 *eep = (u8 *)dev->mt76.eeprom.data;enum nl80211_band band = sband->band; +struct mt76_power_limits limits;u8 rate_val; delta_idx =mt7615_eeprom_get_power_delta_index (dev, band);
@@ -280,7 +281,11 @@ void mt7615_init_txpower(struct mt7615_dev *dev, target_power =max (target_power, eep[index]); } - target_power =DIV_ROUND_UP (target_power + delta,2 ); + target_power =mt76_get_rate_power_limits (&dev->mphy, chan, + &limits, + target_power); + target_power += delta; + target_power =DIV_ROUND_UP (target_power,2 ); chan->max_power =min_t (int, chan->max_reg_power, target_power); chan->orig_mpwr = target_power;
@@ -311,6 +316,9 @@ mt7615_regd_notifier(struct wiphy *wiphy,memcpy (dev->mt76.alpha2, request->alpha2,sizeof (dev->mt76.alpha2)); dev->mt76.region = request->dfs_region; +mt7615_init_txpower (dev, &mphy->sband_2g.sband); +mt7615_init_txpower (dev, &mphy->sband_5g.sband); +mt7615_mutex_acquire (dev);if (chandef->chan->flags &IEEE80211_CHAN_RADAR )
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +60 -1
76 lines not on this page · raw message
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 5/7 mt76: mt7615: do not use mt7615 single-sku values for mt7663
In reply to Lorenzo Bianconimt7663 mcu relies on different APIs to configure APIs per-rate power limit respect to mt7615 driver.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +5 -0
@@ -2202,6 +2202,11 @@ static void mt7615_mcu_set_txpower_sku(struct mt7615_phy *phy, u8 *sku) &limits, tx_power); mphy->txpower_cur = tx_power; +if (is_mt7663 (mphy->dev)) { +memset (sku, tx_power,MT_SKU_4SS_DELTA +1 ); +return ; + } +for (i =0 ; i <MT_SKU_1SS_DELTA ; i++) sku[i] = limits_array[sku_mapping[i]];
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 6/7 mt76: introduce single-sku support for mt7663/mt7921
In reply to Lorenzo BianconiIntroduce support for rate-txpower compensation for mt7663/mt7921 chipsets. Rate-txpower limit is specified through dts
--- .../net/wireless/mediatek/mt76/mt7615/init.c | 5 +- .../net/wireless/mediatek/mt76/mt7615/main.c | 4 + .../wireless/mediatek/mt76/mt76_connac_mcu.c | 133 ++++++++++++++++++ .../wireless/mediatek/mt76/mt76_connac_mcu.h | 23 +++ .../net/wireless/mediatek/mt76/mt7921/init.c | 2 + .../net/wireless/mediatek/mt76/mt7921/main.c | 4 + 6 files changed, 170 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +4 -1
@@ -323,8 +323,11 @@ mt7615_regd_notifier(struct wiphy *wiphy,if (chandef->chan->flags &IEEE80211_CHAN_RADAR )mt7615_dfs_init_radar_detector (phy); -if (mt7615_firmware_offload (phy->dev)) + +if (mt7615_firmware_offload (phy->dev)) {mt76_connac_mcu_set_channel_domain (mphy); +mt76_connac_mcu_set_rate_txpower (mphy); + }mt7615_mutex_release (dev); }
drivers/net/wireless/mediatek/mt76/mt7615/main.c +4 -0
@@ -66,6 +66,10 @@ static int mt7615_start(struct ieee80211_hw *hw) ret =mt76_connac_mcu_set_channel_domain (phy->mt76);if (ret) goto out; + + ret =mt76_connac_mcu_set_rate_txpower (phy->mt76); +if (ret) + goto out; } ret =mt7615_mcu_set_chan_info (phy,MCU_EXT_CMD_SET_RX_PATH );
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +133 -0
139 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +23 -0
@@ -895,6 +895,28 @@ struct mt76_sta_cmd_info {u8 rcpi; }; +#define MT_SKU_POWER_LIMIT 161 + +struct mt76_connac_sku_tlv { +u8 channel; +s8 pwr_limit[MT_SKU_POWER_LIMIT ]; +} __packed; + +struct mt76_connac_tx_power_limit_tlv { +/* DW0 - common info*/ +u8 ver; +u8 pad0; +__le16 len; +/* DW1 - cmd hint */ +u8 n_chan;/* # channel */ +u8 band;/* 2.4GHz - 5GHz */ +u8 last_msg; +u8 pad1; +/* DW3 */ +u8 alpha2[4 ];/* regulatory_request.alpha2 */ +u8 pad2[32 ]; +} __packed; +#define to_wcid_lo (id) FIELD_GET(GENMASK(7, 0), (u16)id)#define to_wcid_hi (id) FIELD_GET(GENMASK(9, 8), (u16)id)
@@ -997,4 +1019,5 @@ void mt76_connac_mcu_set_suspend_iter(void *priv, u8 *mac,int mt76_connac_mcu_chip_config (struct mt76_dev *dev);void mt76_connac_mcu_coredump_event (struct mt76_dev *dev,struct sk_buff *skb,struct mt76_connac_coredump *coredump); +int mt76_connac_mcu_set_rate_txpower (struct mt76_phy *phy);#endif /* __MT76_CONNAC_MCU_H */
drivers/net/wireless/mediatek/mt76/mt7921/init.c +2 -0
@@ -58,12 +58,14 @@ mt7921_regd_notifier(struct wiphy *wiphy, {struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy);struct mt7921_dev *dev =mt7921_hw_dev (hw); +struct mt7921_phy *phy =mt7921_hw_phy (hw);memcpy (dev->mt76.alpha2, request->alpha2,sizeof (dev->mt76.alpha2)); dev->mt76.region = request->dfs_region;mt7921_mutex_acquire (dev);mt76_connac_mcu_set_channel_domain (hw->priv); +mt76_connac_mcu_set_rate_txpower (phy->mt76);mt7921_mutex_release (dev); }
drivers/net/wireless/mediatek/mt76/mt7921/main.c +4 -0
@@ -186,6 +186,10 @@ int __mt7921_start(struct mt7921_phy *phy)if (err)return err; + err =mt76_connac_mcu_set_rate_txpower (phy->mt76); +if (err) +return err; +mt7921_mac_reset_counters (phy);set_bit (MT76_STATE_RUNNING , &mphy->state);
Signature · 1 line
2.30.2
Lorenzo Bianconi
maintainerPATCH v2 7/7 mt76: mt7921: add dumping Tx power table
In reply to Lorenzo BianconiFrom: Sean Wang <[email protected]>
Dump the tx power table saved in offload firmware.
--- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 1 + .../wireless/mediatek/mt76/mt7921/debugfs.c | 79 +++++++++++++++++++ .../net/wireless/mediatek/mt76/mt7921/mcu.c | 23 ++++++ .../net/wireless/mediatek/mt76/mt7921/mcu.h | 17 ++++ .../wireless/mediatek/mt76/mt7921/mt7921.h | 31 ++++++++ 5 files changed, 151 insertions(+)
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +1 -0
@@ -564,6 +564,7 @@ enum {MCU_CMD_CHIP_CONFIG =MCU_CE_PREFIX |0xca ,MCU_CMD_FWLOG_2_HOST =MCU_CE_PREFIX |0xc5 ,MCU_CMD_GET_WTBL =MCU_CE_PREFIX |0xcd , + MCU_CMD_GET_TXPWR = MCU_CE_PREFIX | 0xd0, }; enum {
drivers/net/wireless/mediatek/mt76/mt7921/debugfs.c +79 -0
91 lines not on this page · raw message
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +23 -0
@@ -1358,3 +1358,26 @@ int mt7921_mcu_update_arp_filter(struct ieee80211_hw *hw,return mt76_mcu_skb_send_msg (&dev->mt76, skb,MCU_UNI_CMD_OFFLOAD , true); } + +int mt7921_get_txpwr_info (struct mt7921_dev *dev,struct mt7921_txpwr *txpwr) +{ +struct mt7921_txpwr_event *event; +struct mt7921_txpwr_req req = { + .dbdc_idx =0 , + }; +struct sk_buff *skb; +int ret; + + ret =mt76_mcu_send_and_get_msg (&dev->mt76,MCU_CMD_GET_TXPWR , + &req,sizeof (req), true, &skb); +if (ret) +return ret; + + event = (struct mt7921_txpwr_event *)skb->data; +WARN_ON (skb->len !=le16_to_cpu (event->len)); +memcpy (txpwr, &event->txpwr,sizeof (event->txpwr)); + +dev_kfree_skb (skb); + +return 0 ; +}
drivers/net/wireless/mediatek/mt76/mt7921/mcu.h +17 -0
@@ -85,6 +85,7 @@ enum {MCU_EVENT_CH_PRIVILEGE =0x18 ,MCU_EVENT_SCHED_SCAN_DONE =0x23 ,MCU_EVENT_DBG_MSG =0x27 , +MCU_EVENT_TXPWR =0xd0 , MCU_EVENT_COREDUMP = 0xf0, };
@@ -389,4 +390,20 @@ struct mt7921_mcu_wlan_info {__le32 wlan_idx; struct mt7921_mcu_wlan_info_event event; } __packed; + +struct mt7921_txpwr_req { +u8 ver; +u8 action; +__le16 len; +u8 dbdc_idx; +u8 rsv[3 ]; +} __packed; + +struct mt7921_txpwr_event { +u8 ver; +u8 action; +__le16 len; +struct mt7921_txpwr txpwr; +} __packed; +#endif
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +31 -0
@@ -172,6 +172,36 @@ struct mt7921_dev {struct mt76_connac_coredump coredump; }; +enum { +TXPWR_USER , +TXPWR_EEPROM , +TXPWR_MAC , +TXPWR_MAX_NUM , +}; + +struct mt7921_txpwr { +u8 ch; +u8 rsv[3 ]; +struct { +u8 ch; +u8 cck[4 ]; +u8 ofdm[8 ]; +u8 ht20[8 ]; +u8 ht40[9 ]; +u8 vht20[12 ]; +u8 vht40[12 ]; +u8 vht80[12 ]; +u8 vht160[12 ]; +u8 he26[12 ]; +u8 he52[12 ]; +u8 he106[12 ]; +u8 he242[12 ]; +u8 he484[12 ]; +u8 he996[12 ]; +u8 he996x2[12 ]; + } data[TXPWR_MAX_NUM ]; +}; +enum {MT_LMAC_AC00 ,MT_LMAC_AC01 ,
@@ -352,4 +382,5 @@ int mt7921_mcu_update_arp_filter(struct ieee80211_hw *hw,struct ieee80211_vif *vif, struct ieee80211_bss_conf *info);int mt7921_wfsys_reset (struct mt7921_dev *dev); +int mt7921_get_txpwr_info (struct mt7921_dev *dev,struct mt7921_txpwr *txpwr);#endif
Signature · 1 line
2.30.2
Rob Herring
maintainerRe: [PATCH v2 1/7] dt-bindings:net:wireless:mediatek,mt76: introduce power-limits node
In reply to Lorenzo BianconiQuoted 13 lines · Lorenzo Bianconi
Introduce power-limits node in mt76 binding in order to specify per-rate power limit values for each 802.11n/802.11ac rate
Signed-off-by Lorenzo Bianconi <[email protected]>--- .../bindings/net/wireless/mediatek,mt76.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+)Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +0
-0
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml properties: · line 76
Quoted 5 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +2
-0@@ -72,6 +72,79 @@ properties: led-sources: maxItems: 1 + power-limits: + type: object
additionalProperties: false
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml properties: · line 79
Quoted 3 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +3
-0+ patternProperties: + "^r[0-9]+": + type: object
additionalProperties: false
Quoted 6 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +6
-0+ properties: + regdomain: + $ref: /schemas/types.yaml#/definitions/string + description: + Regdomain refers to a legal regulatory region. Different + countries define different levels of allowable transmitter
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml properties: · line 95
Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +10
-0+ power, time that a channel can be occupied, and different + available channels + enum: + - FCC + - ETSI + - JP + + patternProperties: + "^txpower-[256]g$": + type: object
additionalProperties: false
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml properties: · line 98
Quoted 3 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +3
-0+ patternProperties: + "^b[0-9]+$": + type: object
additionalProperties: false
Quoted 22 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +22
-0+ properties: + channels: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + description: + Pairs of first and last channel number of the selected + band + + rates-cck: + $ref: /schemas/types.yaml#/definitions/uint8-array + minItems: 4 + maxItems: 4 + description: + 4 half-dBm per-rate power limit values + + rates-ofdm: + $ref: /schemas/types.yaml#/definitions/uint8-array + minItems: 8 + maxItems: 8 + description: + 8 half-dBm per-rate power limit values
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml properties: · line 130
Quoted 10 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +10
-0+ + rates-mcs: + $ref: /schemas/types.yaml#/definitions/uint8-matrix + description: + Sets of per-rate power limit values for 802.11n/802.11ac + rates for multiple channel bandwidth settings. + Each set starts with the number of channel bandwidth + settings for which the rate set applies, followed by + either 8 or 10 power limit values. The order of the + channel bandwidth settings is 20, 40, 80 and 160 MHz.
This can be expressed as a schema:
maxItems: 4
items:
minItems: 9
maxItems: 11
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml properties: · line 141
Quoted 11 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +11
-0+ + rates-ru: + $ref: /schemas/types.yaml#/definitions/uint8-matrix + description: + Sets of per-rate power limit values for 802.11ax rates + for multiple channel bandwidth or resource unit settings. + Each set starts with the number of channel bandwidth or + resource unit settings for which the rate set applies, + followed by 12 power limit values. The order of the + channel resource unit settings is RU26, RU52, RU106, + RU242/SU20, RU484/SU40, RU996/SU80 and RU2x996/SU160.
items:
minItems: 13
maxItems: 13
Quoted 42 lines
Documentation/devicetree/bindings/net/wireless/mediatek,mt76.yaml +29
-0+ + txs-delta: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Half-dBm power delta for different numbers of antennas + required: - compatible - reg@@ -93,6 +166,29 @@ examples: led { led-sources = <2>; }; + + power-limits { + r0 { + regdomain = "FCC"; + txpower-5g { + b0 { + channels = <36 48>; + rates-ofdm = /bits/ 8 <23 23 23 23 23 23 23 23>; + rates-mcs = /bits/ 8 <1 23 23 23 23 23 23 23 23 23 23>, + <3 22 22 22 22 22 22 22 22 22 22>; + rates-ru = /bits/ 8 <3 22 22 22 22 22 22 22 22 22 22 22 22>, + <4 20 20 20 20 20 20 20 20 20 20 20 20>; + }; + b1 { + channels = <100 181>; + rates-ofdm = /bits/ 8 <14 14 14 14 14 14 14 14>; + rates-mcs = /bits/ 8 <4 14 14 14 14 14 14 14 14 14 14>; + txs-delta = <12 9 6>; + rates-ru = /bits/ 8 <7 14 14 14 14 14 14 14 14 14 14 14 14>; + }; + }; + }; + }; }; };Signature · 1 line
2.30.2