Skip to content

Commit 00cef41

Browse files
csyuancnbd168
authored andcommitted
wifi: mt76: mt7996: Add mt7996_mcu_sta_mld_setup_tlv() and mt7996_mcu_sta_eht_mld_tlv()
mt7996_mcu_sta_mld_setup_tlv is needed to push MLO configuration to the MCU. This is a preliminary patch to enable MLO for MT7996 driver Co-developed-by: Bo Jiao <Bo.Jiao@mediatek.com> Signed-off-by: Bo Jiao <Bo.Jiao@mediatek.com> Co-developed-by: Peter Chiu <chui-hao.chiu@mediatek.com> Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> Signed-off-by: Shayne Chen <shayne.chen@mediatek.com> Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20250312-b4-mt7996-mlo-p2-v1-2-015b3d6fd928@kernel.org Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent 2660fde commit 00cef41

File tree

2 files changed

+111
-0
lines changed
  • drivers/net/wireless/mediatek/mt76/mt7996

2 files changed

+111
-0
lines changed

drivers/net/wireless/mediatek/mt76/mt7996/mcu.c

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,80 @@ mt7996_mcu_add_group(struct mt7996_dev *dev, struct ieee80211_vif *vif,
21972197
sizeof(req), true);
21982198
}
21992199

2200+
static void
2201+
mt7996_mcu_sta_mld_setup_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
2202+
struct ieee80211_sta *sta)
2203+
{
2204+
struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
2205+
unsigned long links = sta->valid_links;
2206+
unsigned int nlinks = hweight16(links);
2207+
struct mld_setup_link *mld_setup_link;
2208+
struct sta_rec_mld_setup *mld_setup;
2209+
struct mt7996_sta_link *msta_link;
2210+
struct ieee80211_vif *vif;
2211+
unsigned int link_id;
2212+
struct tlv *tlv;
2213+
2214+
msta_link = mt76_dereference(msta->link[msta->deflink_id], &dev->mt76);
2215+
if (!msta_link)
2216+
return;
2217+
2218+
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_MLD,
2219+
sizeof(struct sta_rec_mld_setup) +
2220+
sizeof(struct mld_setup_link) * nlinks);
2221+
2222+
mld_setup = (struct sta_rec_mld_setup *)tlv;
2223+
memcpy(mld_setup->mld_addr, sta->addr, ETH_ALEN);
2224+
mld_setup->setup_wcid = cpu_to_le16(msta_link->wcid.idx);
2225+
mld_setup->primary_id = cpu_to_le16(msta_link->wcid.idx);
2226+
2227+
if (nlinks > 1) {
2228+
link_id = __ffs(links & ~BIT(msta->deflink_id));
2229+
msta_link = mt76_dereference(msta->link[msta->deflink_id],
2230+
&dev->mt76);
2231+
if (!msta_link)
2232+
return;
2233+
}
2234+
mld_setup->seconed_id = cpu_to_le16(msta_link->wcid.idx);
2235+
mld_setup->link_num = nlinks;
2236+
2237+
vif = container_of((void *)msta->vif, struct ieee80211_vif, drv_priv);
2238+
mld_setup_link = (struct mld_setup_link *)mld_setup->link_info;
2239+
for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) {
2240+
struct mt7996_vif_link *link;
2241+
2242+
msta_link = mt76_dereference(msta->link[link_id], &dev->mt76);
2243+
if (!msta_link)
2244+
continue;
2245+
2246+
link = mt7996_vif_link(dev, vif, link_id);
2247+
if (!link)
2248+
continue;
2249+
2250+
if (!msta_link)
2251+
continue;
2252+
2253+
mld_setup_link->wcid = cpu_to_le16(msta_link->wcid.idx);
2254+
mld_setup_link->bss_idx = link->mt76.idx;
2255+
mld_setup_link++;
2256+
}
2257+
}
2258+
2259+
static void
2260+
mt7996_mcu_sta_eht_mld_tlv(struct mt7996_dev *dev, struct sk_buff *skb,
2261+
struct ieee80211_sta *sta)
2262+
{
2263+
struct sta_rec_eht_mld *eht_mld;
2264+
struct tlv *tlv;
2265+
int i;
2266+
2267+
tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_EHT_MLD, sizeof(*eht_mld));
2268+
eht_mld = (struct sta_rec_eht_mld *)tlv;
2269+
2270+
for (i = 0; i < ARRAY_SIZE(eht_mld->str_cap); i++)
2271+
eht_mld->str_cap[i] = 0x7;
2272+
}
2273+
22002274
int mt7996_mcu_add_sta(struct mt7996_dev *dev,
22012275
struct ieee80211_bss_conf *link_conf,
22022276
struct ieee80211_link_sta *link_sta,
@@ -2255,6 +2329,11 @@ int mt7996_mcu_add_sta(struct mt7996_dev *dev,
22552329
mt7996_mcu_sta_eht_tlv(skb, link_sta);
22562330
/* starec muru */
22572331
mt7996_mcu_sta_muru_tlv(dev, skb, link_conf, link_sta);
2332+
2333+
if (sta->mlo) {
2334+
mt7996_mcu_sta_mld_setup_tlv(dev, skb, sta);
2335+
mt7996_mcu_sta_eht_mld_tlv(dev, skb, sta);
2336+
}
22582337
}
22592338

22602339
ret = mt7996_mcu_add_group(dev, link_conf->vif, sta);

drivers/net/wireless/mediatek/mt76/mt7996/mcu.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,35 @@ struct sta_rec_hdr_trans {
625625
u8 mesh;
626626
} __packed;
627627

628+
struct sta_rec_mld_setup {
629+
__le16 tag;
630+
__le16 len;
631+
u8 mld_addr[ETH_ALEN];
632+
__le16 primary_id;
633+
__le16 seconed_id;
634+
__le16 setup_wcid;
635+
u8 link_num;
636+
u8 info;
637+
u8 __rsv[2];
638+
u8 link_info[];
639+
} __packed;
640+
641+
struct sta_rec_eht_mld {
642+
__le16 tag;
643+
__le16 len;
644+
u8 nsep;
645+
u8 __rsv1[2];
646+
u8 str_cap[__MT_MAX_BAND];
647+
__le16 eml_cap;
648+
u8 __rsv2[4];
649+
} __packed;
650+
651+
struct mld_setup_link {
652+
__le16 wcid;
653+
u8 bss_idx;
654+
u8 __rsv;
655+
} __packed;
656+
628657
struct hdr_trans_en {
629658
__le16 tag;
630659
__le16 len;
@@ -798,6 +827,9 @@ enum {
798827
sizeof(struct sta_rec_eht) + \
799828
sizeof(struct sta_rec_hdrt) + \
800829
sizeof(struct sta_rec_hdr_trans) + \
830+
sizeof(struct sta_rec_mld_setup) + \
831+
sizeof(struct mld_setup_link) * 3 + \
832+
sizeof(struct sta_rec_eht_mld) + \
801833
sizeof(struct tlv))
802834

803835
#define MT7996_MAX_BEACON_SIZE 1338

0 commit comments

Comments
 (0)