Commit 913a6182 authored by Ming Yen Hsieh's avatar Ming Yen Hsieh Committed by Felix Fietkau
Browse files

wifi: mt76: add mt76_connac_mcu_build_rnr_scan_param routine



Introduce mt76_connac_mcu_build_rnr_scan_param routine for handling
RNR scan. This is a preliminary patch to enable RNR scan in mt7921 and
mt7925 driver.

Signed-off-by: default avatarMing Yen Hsieh <mingyen.hsieh@mediatek.com>
Link: https://patch.msgid.link/20250321013829.3598-1-mingyen.hsieh@mediatek.com


Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent 7e1fcf68
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -162,6 +162,16 @@ enum mt76_dfs_state {
	MT_DFS_STATE_ACTIVE,
};

#define MT76_RNR_SCAN_MAX_BSSIDS       16
struct mt76_scan_rnr_param {
	u8 bssid[MT76_RNR_SCAN_MAX_BSSIDS][ETH_ALEN];
	u8 channel[MT76_RNR_SCAN_MAX_BSSIDS];
	u8 random_mac[ETH_ALEN];
	u8 seq_num;
	u8 bssid_num;
	u32 sreq_flag;
};

struct mt76_queue_buf {
	dma_addr_t addr;
	u16 len:15,
@@ -941,6 +951,8 @@ struct mt76_dev {
	char alpha2[3];
	enum nl80211_dfs_regions region;

	struct mt76_scan_rnr_param rnr;

	u32 debugfs_reg;

	u8 csa_complete;
+38 −0
Original line number Diff line number Diff line
@@ -1666,6 +1666,44 @@ int mt76_connac_mcu_uni_add_bss(struct mt76_phy *phy,
}
EXPORT_SYMBOL_GPL(mt76_connac_mcu_uni_add_bss);

void mt76_connac_mcu_build_rnr_scan_param(struct mt76_dev *mdev,
					  struct cfg80211_scan_request *sreq)
{
	struct ieee80211_channel **scan_list = sreq->channels;
	int i, bssid_index = 0;

	/* clear 6G active Scan BSSID table */
	memset(&mdev->rnr, 0, sizeof(mdev->rnr));

	for (i = 0; i < sreq->n_6ghz_params; i++) {
		u8 ch_idx = sreq->scan_6ghz_params[i].channel_idx;
		int k = 0;

		/* Remove the duplicated BSSID */
		for (k = 0; k < bssid_index; k++) {
			if (!memcmp(&mdev->rnr.bssid[k],
				    sreq->scan_6ghz_params[i].bssid,
				    ETH_ALEN))
				break;
		}

		if (k == bssid_index &&
		    bssid_index < MT76_RNR_SCAN_MAX_BSSIDS) {
			memcpy(&mdev->rnr.bssid[bssid_index++],
			       sreq->scan_6ghz_params[i].bssid, ETH_ALEN);
			mdev->rnr.channel[k] = scan_list[ch_idx]->hw_value;
		}
	}

	mdev->rnr.bssid_num = bssid_index;

	if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
		memcpy(mdev->rnr.random_mac, sreq->mac_addr, ETH_ALEN);
		mdev->rnr.sreq_flag = sreq->flags;
	}
}
EXPORT_SYMBOL_GPL(mt76_connac_mcu_build_rnr_scan_param);

#define MT76_CONNAC_SCAN_CHANNEL_TIME		60
int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
			    struct ieee80211_scan_request *scan_req)
+3 −0
Original line number Diff line number Diff line
@@ -869,6 +869,7 @@ enum {
#define NETWORK_WDS			BIT(21)

#define SCAN_FUNC_RANDOM_MAC		BIT(0)
#define SCAN_FUNC_RNR_SCAN		BIT(3)
#define SCAN_FUNC_SPLIT_SCAN		BIT(5)

#define CONNECTION_INFRA_STA		(STA_TYPE_STA | NETWORK_INFRA)
@@ -1972,6 +1973,8 @@ int mt76_connac_mcu_start_patch(struct mt76_dev *dev);
int mt76_connac_mcu_patch_sem_ctrl(struct mt76_dev *dev, bool get);
int mt76_connac_mcu_start_firmware(struct mt76_dev *dev, u32 addr, u32 option);

void mt76_connac_mcu_build_rnr_scan_param(struct mt76_dev *mdev,
					  struct cfg80211_scan_request *sreq);
int mt76_connac_mcu_hw_scan(struct mt76_phy *phy, struct ieee80211_vif *vif,
			    struct ieee80211_scan_request *scan_req);
int mt76_connac_mcu_cancel_hw_scan(struct mt76_phy *phy,