Skip to content

Commit

Permalink
wifi: mt76: mt7921: get regulatory information from the clc event
Browse files Browse the repository at this point in the history
The clc event can report the radio configuration for the corresponding
country and the driver would take it as regulatory information of a
certain platform device.

This patch would change the clc commnad from no-waiting to waiting for
event. For backward compatible, we also add a new nic capability tag
to indicate the firmware did support this new clc event from now on.

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>
  • Loading branch information
Ming Yen Hsieh authored and nbd168 committed Sep 30, 2023
1 parent 51ba0e3 commit 4fc8df5
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ enum {
MT_NIC_CAP_ANTSWP = 0x16,
MT_NIC_CAP_WFDMA_REALLOC,
MT_NIC_CAP_6G,
MT_NIC_CAP_CHIP_CAP = 0x20,
};

#define UNI_WOW_DETECT_TYPE_MAGIC BIT(0)
Expand Down
26 changes: 22 additions & 4 deletions drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,9 @@ static int mt7921_mcu_get_nic_capability(struct mt792x_phy *mphy)
mt7921_mcu_parse_tx_resource(phy->dev,
skb);
break;
case MT_NIC_CAP_CHIP_CAP:
memcpy(&mphy->chip_cap, (void *)skb->data, sizeof(u64));
break;
default:
break;
}
Expand Down Expand Up @@ -1243,15 +1246,16 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
struct mt7921_clc *clc,
u8 idx)
{
struct sk_buff *skb;
#define CLC_CAP_EVT_EN BIT(0)
struct sk_buff *skb, *ret_skb = NULL;
struct {
u8 ver;
u8 pad0;
__le16 len;
u8 idx;
u8 env;
u8 acpi_conf;
u8 pad1;
u8 cap;
u8 alpha2[2];
u8 type[2];
u8 env_6g;
Expand All @@ -1268,6 +1272,9 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
if (!clc)
return 0;

if (dev->phy.chip_cap & MT792x_CHIP_CAP_CLC_EVT_EN)
req.cap |= CLC_CAP_EVT_EN;

pos = clc->data;
for (i = 0; i < clc->nr_country; i++) {
struct mt7921_clc_rule *rule = (struct mt7921_clc_rule *)pos;
Expand All @@ -1289,10 +1296,21 @@ int __mt7921_mcu_set_clc(struct mt792x_dev *dev, u8 *alpha2,
return -ENOMEM;
skb_put_data(skb, rule->data, len);

ret = mt76_mcu_skb_send_msg(&dev->mt76, skb,
MCU_CE_CMD(SET_CLC), false);
ret = mt76_mcu_skb_send_and_get_msg(&dev->mt76, skb,
MCU_CE_CMD(SET_CLC),
!!(req.cap & CLC_CAP_EVT_EN),
&ret_skb);
if (ret < 0)
return ret;

if (ret_skb) {
struct mt7921_clc_info_tlv *info;

info = (struct mt7921_clc_info_tlv *)(ret_skb->data + 4);
dev->phy.clc_chan_conf = info->chan_conf;
dev_kfree_skb(ret_skb);
}

valid_cnt++;
}

Expand Down
13 changes: 13 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt7921/mcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@ struct mt7921_rftest_evt {
__le32 param0;
__le32 param1;
} __packed;

struct mt7921_clc_info_tlv {
__le16 tag;
__le16 len;

u8 chan_conf; /* BIT(0) : Enable UNII-4
* BIT(1) : Enable UNII-5
* BIT(2) : Enable UNII-6
* BIT(3) : Enable UNII-7
* BIT(4) : Enable UNII-8
*/
u8 rsv[63];
} __packed;
#endif
1 change: 1 addition & 0 deletions drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define MT7921_SKU_TABLE_SIZE (MT7921_SKU_RATE_NUM + 1)

#define MCU_UNI_EVENT_ROC 0x27
#define MCU_UNI_EVENT_CLC 0x80

enum {
UNI_ROC_ACQUIRE,
Expand Down
4 changes: 4 additions & 0 deletions drivers/net/wireless/mediatek/mt76/mt792x.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define MT792x_FW_TAG_FEATURE 4
#define MT792x_FW_CAP_CNM BIT(7)

#define MT792x_CHIP_CAP_CLC_EVT_EN BIT(0)

/* NOTE: used to map mt76_rates. idx may change if firmware expands table */
#define MT792x_BASIC_RATES_TBL 11

Expand Down Expand Up @@ -125,6 +127,7 @@ struct mt792x_phy {
struct mt76_mib_stats mib;

u8 sta_work_count;
u8 clc_chan_conf;
enum mt792x_reg_power_type power_type;

struct sk_buff_head scan_event_list;
Expand All @@ -133,6 +136,7 @@ struct mt792x_phy {
void *acpisar;
#endif
void *clc[MT792x_CLC_MAX_NUM];
u64 chip_cap;

struct work_struct roc_work;
struct timer_list roc_timer;
Expand Down

0 comments on commit 4fc8df5

Please sign in to comment.