wifi: mt76: mt7921: update the channel usage when the regd domain changed
The 5.9/6GHz channel license of a certain platform device has been regulated in various countries. That may be difference with standard Liunx regulatory domain settings. In this case, when .reg_notifier() called for regulatory change, mt792x chipset should update the channel usage based on clc or dts configurations. Channel would be disabled by following cases. * clc report the particular UNII-x is disabled. * dts enabled and the channel is not configured. Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> Co-developed-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Deren Wu <deren.wu@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
4fc8df50fd
commit
09382d8f86
4 changed files with 64 additions and 2 deletions
|
@ -188,7 +188,7 @@ static bool mt76_string_prop_find(struct property *prop, const char *str)
|
|||
return false;
|
||||
}
|
||||
|
||||
static struct device_node *
|
||||
struct device_node *
|
||||
mt76_find_power_limits_node(struct mt76_dev *dev)
|
||||
{
|
||||
struct device_node *np = dev->dev->of_node;
|
||||
|
@ -227,6 +227,7 @@ mt76_find_power_limits_node(struct mt76_dev *dev)
|
|||
of_node_put(np);
|
||||
return fallback;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_find_power_limits_node);
|
||||
|
||||
static const __be32 *
|
||||
mt76_get_of_array(struct device_node *np, char *name, size_t *len, int min)
|
||||
|
@ -241,7 +242,7 @@ mt76_get_of_array(struct device_node *np, char *name, size_t *len, int min)
|
|||
return prop->value;
|
||||
}
|
||||
|
||||
static struct device_node *
|
||||
struct device_node *
|
||||
mt76_find_channel_node(struct device_node *np, struct ieee80211_channel *chan)
|
||||
{
|
||||
struct device_node *cur;
|
||||
|
@ -265,6 +266,8 @@ mt76_find_channel_node(struct device_node *np, struct ieee80211_channel *chan)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76_find_channel_node);
|
||||
|
||||
|
||||
static s8
|
||||
mt76_get_txs_delta(struct device_node *np, u8 nss)
|
||||
|
|
|
@ -1537,6 +1537,11 @@ 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);
|
||||
|
||||
struct device_node *
|
||||
mt76_find_power_limits_node(struct mt76_dev *dev);
|
||||
struct device_node *
|
||||
mt76_find_channel_node(struct device_node *np, struct ieee80211_channel *chan);
|
||||
|
||||
s8 mt76_get_rate_power_limits(struct mt76_phy *phy,
|
||||
struct ieee80211_channel *chan,
|
||||
struct mt76_power_limits *dest,
|
||||
|
|
|
@ -58,6 +58,55 @@ static int mt7921_thermal_init(struct mt792x_phy *phy)
|
|||
return PTR_ERR_OR_ZERO(hwmon);
|
||||
}
|
||||
|
||||
static void
|
||||
mt7921_regd_channel_update(struct wiphy *wiphy, struct mt792x_dev *dev)
|
||||
{
|
||||
#define IS_UNII_INVALID(idx, sfreq, efreq) \
|
||||
(!(dev->phy.clc_chan_conf & BIT(idx)) && (cfreq) >= (sfreq) && (cfreq) <= (efreq))
|
||||
struct ieee80211_supported_band *sband;
|
||||
struct mt76_dev *mdev = &dev->mt76;
|
||||
struct device_node *np, *band_np;
|
||||
struct ieee80211_channel *ch;
|
||||
int i, cfreq;
|
||||
|
||||
np = mt76_find_power_limits_node(mdev);
|
||||
|
||||
sband = wiphy->bands[NL80211_BAND_5GHZ];
|
||||
band_np = np ? of_get_child_by_name(np, "txpower-5g") : NULL;
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
cfreq = ch->center_freq;
|
||||
|
||||
if (np && (!band_np || !mt76_find_channel_node(band_np, ch))) {
|
||||
ch->flags |= IEEE80211_CHAN_DISABLED;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* UNII-4 */
|
||||
if (IS_UNII_INVALID(0, 5850, 5925))
|
||||
ch->flags |= IEEE80211_CHAN_DISABLED;
|
||||
}
|
||||
|
||||
sband = wiphy->bands[NL80211_BAND_6GHZ];
|
||||
band_np = np ? of_get_child_by_name(np, "txpower-6g") : NULL;
|
||||
for (i = 0; i < sband->n_channels; i++) {
|
||||
ch = &sband->channels[i];
|
||||
cfreq = ch->center_freq;
|
||||
|
||||
if (np && (!band_np || !mt76_find_channel_node(band_np, ch))) {
|
||||
ch->flags |= IEEE80211_CHAN_DISABLED;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* UNII-5/6/7/8 */
|
||||
if (IS_UNII_INVALID(1, 5925, 6425) ||
|
||||
IS_UNII_INVALID(2, 6425, 6525) ||
|
||||
IS_UNII_INVALID(3, 6525, 6875) ||
|
||||
IS_UNII_INVALID(4, 6875, 7125))
|
||||
ch->flags |= IEEE80211_CHAN_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
mt7921_regd_notifier(struct wiphy *wiphy,
|
||||
struct regulatory_request *request)
|
||||
|
@ -74,6 +123,8 @@ mt7921_regd_notifier(struct wiphy *wiphy,
|
|||
mt76_connac_mcu_set_channel_domain(hw->priv);
|
||||
mt7921_set_tx_sar_pwr(hw, NULL);
|
||||
mt792x_mutex_release(dev);
|
||||
|
||||
mt7921_regd_channel_update(wiphy, dev);
|
||||
}
|
||||
|
||||
int mt7921_mac_init(struct mt792x_dev *dev)
|
||||
|
|
|
@ -1247,6 +1247,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
|
|||
u8 idx)
|
||||
{
|
||||
#define CLC_CAP_EVT_EN BIT(0)
|
||||
#define CLC_CAP_DTS_EN BIT(1)
|
||||
struct sk_buff *skb, *ret_skb = NULL;
|
||||
struct {
|
||||
u8 ver;
|
||||
|
@ -1274,6 +1275,8 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
|
|||
|
||||
if (dev->phy.chip_cap & MT792x_CHIP_CAP_CLC_EVT_EN)
|
||||
req.cap |= CLC_CAP_EVT_EN;
|
||||
if (mt76_find_power_limits_node(&dev->mt76))
|
||||
req.cap |= CLC_CAP_DTS_EN;
|
||||
|
||||
pos = clc->data;
|
||||
for (i = 0; i < clc->nr_country; i++) {
|
||||
|
|
Loading…
Add table
Reference in a new issue