Commit fa6ad88e authored by Ming Yen Hsieh's avatar Ming Yen Hsieh Committed by Felix Fietkau

wifi: mt76: mt7921: fix country count limitation for CLC

Due to the increase in the number of power tables for 6Ghz on CLC,
the variable nr_country is no longer sufficient to represent the
total quantity. Therefore, we have switched to calculating the
length of clc buf to obtain the correct power table. Additionally,
the version number has been incremented to 1.

Fixes: 23bdc5d8 ("wifi: mt76: mt7921: introduce Country Location Control support")
Signed-off-by: default avatarMing Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 4812ba9a
...@@ -1263,6 +1263,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, ...@@ -1263,6 +1263,7 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
u8 mtcl_conf; u8 mtcl_conf;
u8 rsvd[62]; u8 rsvd[62];
} __packed req = { } __packed req = {
.ver = 1,
.idx = idx, .idx = idx,
.env = env_cap, .env = env_cap,
.env_6g = dev->phy.power_type, .env_6g = dev->phy.power_type,
...@@ -1270,7 +1271,8 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, ...@@ -1270,7 +1271,8 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
.mtcl_conf = mt792x_acpi_get_mtcl_conf(&dev->phy, alpha2), .mtcl_conf = mt792x_acpi_get_mtcl_conf(&dev->phy, alpha2),
}; };
int ret, valid_cnt = 0; int ret, valid_cnt = 0;
u8 i, *pos; u16 buf_len = 0;
u8 *pos;
if (!clc) if (!clc)
return 0; return 0;
...@@ -1280,12 +1282,15 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2, ...@@ -1280,12 +1282,15 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
if (mt76_find_power_limits_node(&dev->mt76)) if (mt76_find_power_limits_node(&dev->mt76))
req.cap |= CLC_CAP_DTS_EN; req.cap |= CLC_CAP_DTS_EN;
buf_len = le16_to_cpu(clc->len) - sizeof(*clc);
pos = clc->data; pos = clc->data;
for (i = 0; i < clc->nr_country; i++) { while (buf_len > 16) {
struct mt7921_clc_rule *rule = (struct mt7921_clc_rule *)pos; struct mt7921_clc_rule *rule = (struct mt7921_clc_rule *)pos;
u16 len = le16_to_cpu(rule->len); u16 len = le16_to_cpu(rule->len);
u16 offset = len + sizeof(*rule);
pos += len + sizeof(*rule); pos += offset;
buf_len -= offset;
if (rule->alpha2[0] != alpha2[0] || if (rule->alpha2[0] != alpha2[0] ||
rule->alpha2[1] != alpha2[1]) rule->alpha2[1] != alpha2[1])
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment