Message ID | 20250319074426.3782102-2-mingyen.hsieh@mediatek.com (mailing list archive) |
---|---|
State | Deferred |
Delegated to: | Felix Fietkau |
Headers | show |
Series | [1/2] wifi: mt76: add mt76_connac_mcu_build_rnr_scan_param routine | expand |
Mingyen Hsieh <mingyen.hsieh@mediatek.com> wrote: > From: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> > > Enhance the mt7925 to include RNR scan support. It adds > the necessary RNR information to the scan command. > > Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com> > --- > .../net/wireless/mediatek/mt76/mt7925/mcu.c | 35 +++++++++++++++++-- > .../net/wireless/mediatek/mt76/mt7925/mcu.h | 17 +++++---- > 2 files changed, 43 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c > b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c > index 243adace8799..7e24c4aa1e61 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c > +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c > @@ -3042,6 +3042,7 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, > struct mt76_dev *mdev = phy->dev; > struct mt76_connac_mcu_scan_channel *chan; > struct sk_buff *skb; > + u32 short_ssid[MT7925_RNR_SCAN_MAX_BSSIDS] = {0}; Using '= {}' as initializer would be more general for array and struct. > > struct scan_hdr_tlv *hdr; > struct scan_req_tlv *req; > @@ -3054,8 +3055,8 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, > int max_len; > > max_len = sizeof(*hdr) + sizeof(*req) + sizeof(*ssid) + > - sizeof(*bssid) + sizeof(*chan_info) + > - sizeof(*misc) + sizeof(*ie); > + sizeof(*bssid) * MT7925_RNR_SCAN_MAX_BSSIDS + > + sizeof(*chan_info) + sizeof(*misc) + sizeof(*ie); > > skb = mt76_mcu_msg_alloc(mdev, NULL, max_len); > if (!skb) > @@ -3078,7 +3079,11 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, > for (i = 0; i < sreq->n_ssids; i++) { > if (!sreq->ssids[i].ssid_len) > continue; > + if (i > MT7925_RNR_SCAN_MAX_BSSIDS) > + break; > > + short_ssid[i] = ~crc32_le(~0, sreq->ssids[i].ssid, > + sreq->ssids[i].ssid_len); Have you run checkpatch? Third argument doesn't align with open parenthesis. > ssid->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len); > memcpy(ssid->ssids[i].ssid, sreq->ssids[i].ssid, > sreq->ssids[i].ssid_len); > @@ -3087,6 +3092,32 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, > ssid->ssid_type = n_ssids ? BIT(2) : BIT(0); > ssid->ssids_num = n_ssids; > > + if (sreq->n_6ghz_params) { > + u8 j; > + > + mt76_connac_mcu_build_rnr_scan_param(mdev, sreq); > + > + for (j = 0; j < mdev->rnr.bssid_num; j++) { > + if (j > MT7925_RNR_SCAN_MAX_BSSIDS) > + break; > + > + tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_BSSID, > + sizeof(*bssid)); > + bssid = (struct scan_bssid_tlv *)tlv; > + > + memcpy(bssid->bssid, mdev->rnr.bssid[j], ETH_ALEN); If addresses of dst and src BSSID are aligned u16, then ether_addr_copy(). > + bssid->match_ch = mdev->rnr.channel[j]; > + bssid->match_ssid_ind = MT7925_RNR_SCAN_MAX_BSSIDS; > + bssid->match_short_ssid_ind = MT7925_RNR_SCAN_MAX_BSSIDS; > + } > + req->scan_func |= SCAN_FUNC_RNR_SCAN; > + } else { > + tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_BSSID, sizeof(*bssid)); > + bssid = (struct scan_bssid_tlv *)tlv; > + > + memcpy(bssid->bssid, sreq->bssid, ETH_ALEN); > + } > + > tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_BSSID, sizeof(*bssid)); > bssid = (struct scan_bssid_tlv *)tlv; > >
diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c index 243adace8799..7e24c4aa1e61 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c @@ -3042,6 +3042,7 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, struct mt76_dev *mdev = phy->dev; struct mt76_connac_mcu_scan_channel *chan; struct sk_buff *skb; + u32 short_ssid[MT7925_RNR_SCAN_MAX_BSSIDS] = {0}; struct scan_hdr_tlv *hdr; struct scan_req_tlv *req; @@ -3054,8 +3055,8 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, int max_len; max_len = sizeof(*hdr) + sizeof(*req) + sizeof(*ssid) + - sizeof(*bssid) + sizeof(*chan_info) + - sizeof(*misc) + sizeof(*ie); + sizeof(*bssid) * MT7925_RNR_SCAN_MAX_BSSIDS + + sizeof(*chan_info) + sizeof(*misc) + sizeof(*ie); skb = mt76_mcu_msg_alloc(mdev, NULL, max_len); if (!skb) @@ -3078,7 +3079,11 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, for (i = 0; i < sreq->n_ssids; i++) { if (!sreq->ssids[i].ssid_len) continue; + if (i > MT7925_RNR_SCAN_MAX_BSSIDS) + break; + short_ssid[i] = ~crc32_le(~0, sreq->ssids[i].ssid, + sreq->ssids[i].ssid_len); ssid->ssids[i].ssid_len = cpu_to_le32(sreq->ssids[i].ssid_len); memcpy(ssid->ssids[i].ssid, sreq->ssids[i].ssid, sreq->ssids[i].ssid_len); @@ -3087,6 +3092,32 @@ int mt7925_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif, ssid->ssid_type = n_ssids ? BIT(2) : BIT(0); ssid->ssids_num = n_ssids; + if (sreq->n_6ghz_params) { + u8 j; + + mt76_connac_mcu_build_rnr_scan_param(mdev, sreq); + + for (j = 0; j < mdev->rnr.bssid_num; j++) { + if (j > MT7925_RNR_SCAN_MAX_BSSIDS) + break; + + tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_BSSID, + sizeof(*bssid)); + bssid = (struct scan_bssid_tlv *)tlv; + + memcpy(bssid->bssid, mdev->rnr.bssid[j], ETH_ALEN); + bssid->match_ch = mdev->rnr.channel[j]; + bssid->match_ssid_ind = MT7925_RNR_SCAN_MAX_BSSIDS; + bssid->match_short_ssid_ind = MT7925_RNR_SCAN_MAX_BSSIDS; + } + req->scan_func |= SCAN_FUNC_RNR_SCAN; + } else { + tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_BSSID, sizeof(*bssid)); + bssid = (struct scan_bssid_tlv *)tlv; + + memcpy(bssid->bssid, sreq->bssid, ETH_ALEN); + } + tlv = mt76_connac_mcu_add_tlv(skb, UNI_SCAN_BSSID, sizeof(*bssid)); bssid = (struct scan_bssid_tlv *)tlv; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h index 0419aa922e17..96809c2fdff9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.h @@ -196,6 +196,7 @@ enum { UNI_SNIFFER_CONFIG, }; +#define MT7925_RNR_SCAN_MAX_BSSIDS 10 struct scan_hdr_tlv { /* fixed field */ u8 seq_num; @@ -223,7 +224,7 @@ struct scan_req_tlv { __le16 timeout_value; __le16 probe_delay_time; __le32 func_mask_ext; -}; +} __packed; struct scan_ssid_tlv { __le16 tag; @@ -235,9 +236,10 @@ struct scan_ssid_tlv { * BIT(2) + ssid_type_ext BIT(0) specified SSID only */ u8 ssids_num; - u8 pad[2]; - struct mt76_connac_mcu_scan_ssid ssids[4]; -}; + u8 is_short_ssid; + u8 pad; + struct mt76_connac_mcu_scan_ssid ssids[MT7925_RNR_SCAN_MAX_BSSIDS]; +} __packed; struct scan_bssid_tlv { __le16 tag; @@ -247,8 +249,9 @@ struct scan_bssid_tlv { u8 match_ch; u8 match_ssid_ind; u8 rcpi; - u8 pad[3]; -}; + u8 match_short_ssid_ind; + u8 pad[2]; +} __packed; struct scan_chan_info_tlv { __le16 tag; @@ -264,7 +267,7 @@ struct scan_chan_info_tlv { u8 channels_num; /* valid when channel_type is 4 */ u8 pad[2]; struct mt76_connac_mcu_scan_channel channels[64]; -}; +} __packed; struct scan_ie_tlv { __le16 tag;