From patchwork Tue Jan 14 02:07:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 857570 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89C5E3595A for ; Tue, 14 Jan 2025 02:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736820444; cv=none; b=FaJQPiu6hNNWU489wlwngukgbfY9EXdhF3HdKevdFQd4L3dy1eY3+hBP/gs7Dtf8nID5tTr0Jn7SpDSkE/C4YyEeaJ2k9nzJ4zupGRgRPSYr6LWu64tGFZ7Clhxgzs3FBWBAWjGZTPRD9K7u/cTd8qUUgR6r7lpb24fo2EJq2R0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736820444; c=relaxed/simple; bh=TerTb66Xzt9NyRBG/CthhfVJrp8N9Maabg7tHY2QzKU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iW1D+2KoAUlIfiKVWThEpPEqEhxCrtUd5i34yXRHgL1FKBYsbpfTZ/Q0GtfcXeVXCILX8uQ/feMOw3ot1/P5vkHwbzFTsEc9ZvszhFjDNicDgDoHIOKA77H7AhRtV7+7uP6ZjUEJ4aMUTfXytrwifLTsSIGozh/y5trPznRFIPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-71e1e051e50so1334722a34.0 for ; Mon, 13 Jan 2025 18:07:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736820441; x=1737425241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YtFuvbzeBTNVOBWO3ySJleq1Z7QhqifLZ+UmNMZ8jrQ=; b=mKRdGKBW98ob8DiBzF9ArF0D1sQIPu631UGy+Xs467y2KMCICejwbcBcI5cVQ3l7W1 RVRfZiSLKNqSOmSXHAsgXoTSBoPs0utpFI0wxVnHnbAXoPdPPtTkrdvz8YGjK789drCR YoMw6Z7VrYZy1SMyOeNumAtBQgmn7HgaXL2fpAvTSYiLG7uWabkAMt5jy9iUPZsunGIs Fhz3XqV80eiAD09PdWo6WU3J/VehYh/9tGln+4219adx6tgEgSQgM/SMVs3pqzyOWUYQ 8ybnJEkUEcaE/CbGs4Es4MDcgxHriGWMGmejJXV3h8S+s4E7JfVLXFUQBV8ngh1ubrVP C4PA== X-Forwarded-Encrypted: i=1; AJvYcCXGwvJutxg6TTYGWJ0Jj/1m/+fPOu7T5kdz47SZizBmC6pbAEfpFLE+ZgudnnzscgjZBfUt/G6Nkz1+x4NeRw==@vger.kernel.org X-Gm-Message-State: AOJu0YwnoQ6hGNu0Y3dTO3A5cik/fhRJByOdPsBAwfLwmtyyTq+ZCt5D +2tiVbQqv+9fQ8Ppl+Un5qyTf2m2AuHYvjYqNdbMw0MSeLkuMZnX X-Gm-Gg: ASbGncsbSgJpL1ID1e7Ft/GLyiNuqgVxYfs82VaZzY+El6Mha2HmO3DQEDjcBfqhK6X 5+wYt3FeEjVz2WyN+UOnUHZ60/SxOHnQQyR+OI34UQ3AhHFbVZw2ATFSoZ8wagtpcizqs8OgOop cClJiUt2HxCHGvmRAEz6T7lOAC8IA1nH5wJxaJTCZYIUp7Ll0pmftwnG2PBLx3UZNyOS0lfVy8R AawdzOuP6Fc0JteH2FT6/iKTN7Yu3kcdiqLV0XxAlWNACpEKzOXirLYSw8WIHU7EEUBsveMIw== X-Google-Smtp-Source: AGHT+IHd5Kld9d0+YVuyqDqLcd2oa2ia62Q6ta0zrOvMzrIgUFpRMWwtfoHQSwdMtTatTt9OkenVdA== X-Received: by 2002:a05:6830:61c2:b0:71d:5f22:aff5 with SMTP id 46e09a7af769-721e2e23192mr15792855a34.10.1736820441541; Mon, 13 Jan 2025 18:07:21 -0800 (PST) Received: from sean-ThinkPad-T450s.lan ([207.191.35.252]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f882755172sm3915340eaf.27.2025.01.13.18.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 18:07:20 -0800 (PST) From: sean.wang@kernel.org To: nbd@nbd.name, lorenzo.bianconi@redhat.com Cc: sean.wang@mediatek.com, deren.wu@mediatek.com, mingyen.hsieh@mediatek.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 2/6] wifi: mt76: mt7925: fix the wrong link_idx when has p2p_device Date: Mon, 13 Jan 2025 18:07:08 -0800 Message-Id: <20250114020712.704254-2-sean.wang@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250114020712.704254-1-sean.wang@kernel.org> References: <20250114020712.704254-1-sean.wang@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ming Yen Hsieh When the p2p device and MLO station concurrent, the p2p device will occupy the wrong link_idx when the MLO secondary link is added. Fixes: e38a82d25b08 ("wifi: mt76: connac: Extend mt76_connac_mcu_uni_add_dev for MLO") Signed-off-by: Ming Yen Hsieh Signed-off-by: Sean Wang --- v2: generate the patch based on the latest mt76 tree --- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + .../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 14 ++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 132148f7b107..05651efb549e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -769,6 +769,7 @@ struct mt76_testmode_data { struct mt76_vif_link { u8 idx; + u8 link_idx; u8 omac_idx; u8 band_idx; u8 wmm_idx; diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index f30cf9e71610..d0e49d68c5db 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -1168,7 +1168,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy, .tag = cpu_to_le16(DEV_INFO_ACTIVE), .len = cpu_to_le16(sizeof(struct req_tlv)), .active = enable, - .link_idx = mvif->idx, + .link_idx = mvif->link_idx, }, }; struct { @@ -1191,7 +1191,7 @@ int mt76_connac_mcu_uni_add_dev(struct mt76_phy *phy, .bmc_tx_wlan_idx = cpu_to_le16(wcid->idx), .sta_idx = cpu_to_le16(wcid->idx), .conn_state = 1, - .link_idx = mvif->idx, + .link_idx = mvif->link_idx, }, }; int err, idx, cmd, len; diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 2082e3904d76..502b76a40ca8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -360,10 +360,15 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, struct mt76_txq *mtxq; int idx, ret = 0; - mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask); - if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { - ret = -ENOSPC; - goto out; + if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { + mconf->mt76.idx = MT792x_MAX_INTERFACES; + } else { + mconf->mt76.idx = __ffs64(~dev->mt76.vif_mask); + + if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { + ret = -ENOSPC; + goto out; + } } mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ? @@ -371,6 +376,7 @@ static int mt7925_mac_link_bss_add(struct mt792x_dev *dev, mconf->mt76.band_idx = 0xff; mconf->mt76.wmm_idx = ieee80211_vif_is_mld(vif) ? 0 : mconf->mt76.idx % MT76_CONNAC_MAX_WMM_SETS; + mconf->mt76.link_idx = hweight16(mvif->valid_links); if (mvif->phy->mt76->chandef.chan->band != NL80211_BAND_2GHZ) mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL + 4; From patchwork Tue Jan 14 02:07:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 857569 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 423C6230242 for ; Tue, 14 Jan 2025 02:07:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736820449; cv=none; b=oIhJmZbtMggQdSUZBhywFt4DEw+cHQVpDGZ5ntr6Td5iKxCvPE5xvbrjzigA858lG1dE/E8VHTBX9aGQXdlQln/hq5owXQKJ127l6Aj2WBShaBB6yQ/Y+6HMxfPCQfg6c5dmsjj95iq5a41N+w1qJfR7Pon4z01f4UzuNjaMu34= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736820449; c=relaxed/simple; bh=C/lG8AqhxqgGve1Znsts+hDisNDVg4gAKWUJro7j/4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BDsEA+nuuyZNYUkOrHXQD4zEbnDz4y1cOmd81/Xid6wdpPIbPi9EoJSLKqqeqtC3DBFAdCURv5Vhy1XoFWywXvdSGarfCTAiRklOW4Y/p+wnjSN6ftWXvJMUXjM1gOd7eR43CBcGsqbRScNK9JrSfzmZRFdjcKBtZ5MYs6mI+Kc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3eb7ca55c3bso2772877b6e.3 for ; Mon, 13 Jan 2025 18:07:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736820447; x=1737425247; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8Z5nZ9Qy6TBKcXoruppicIm/anRrncBfElUKQXmiVQU=; b=fXECp5mrrzbPlvp0w3hS4TrWxheWORfELqZijhMQawrHgKsnFsjnXiHcq2nc0y8KSR zjWpJ8G6O3V9qViyHFKMPatdHhvHMMXrsp9APXtWJ7OCDfSiK902lx/BqOFfiaLeMnTB DwX4DVADP+rdN7/s5jkf1C6AjcEl7cXKHE4NlGb1mi7DKDx9KszMta7puv9tNuz2x3// g4Hj90dBzj854jBLVali0TnMwqYGDjLQ4ooQVmL4U6lx/e6y23vHCCFIgQ0TuIkyERXu C1+lS8yGUDY1r/puNAXmEKyXZS3dMvSYFGcYhNjwy/qXOXBmuth67ksrmemfzgvvrBmy 7lhg== X-Forwarded-Encrypted: i=1; AJvYcCXKX4sKEEmQLq7veGy/Vb/2qRmxoF8Vp7TaOydwvayQm9cTGWkMLkX/GICJvhgOY4D1ZTibInBJXfixgL2OPQ==@vger.kernel.org X-Gm-Message-State: AOJu0YzpDvnWBs14NuR0DBTb7ItY5MB//J9GDkkJFh0pYRGfMIKr1dcr 0RBo5kVZSblBb2qb5aGm6L93QxgBvNvMrNCNY8rzUjoP3gbBDY3h X-Gm-Gg: ASbGncvkmR3KeZ/pkWp8fVwjtFFmSAbqujLybE4Fi2Col1qVMeR7VGPuhSlKbz5GNlM y1hZttALdWNkMKXJ7hH9WrO8vTnxj/8b9lfrqzoiHqJ/byJmgz93eYBtWpNp4XUvRfs+KIbjQp2 yK1k29NtFBomuMoEiuV7MXibQzb5kygIIA+Rxwy2e/UW1C+tdkvEKctMxsfeNAjY6nkA1mF1Ghd n14uQdupSYQsUP8bKVYbOidZRC+7Yfmg+hw8LH8wDBqcGqwo9icH3OEA9iY/5i3Bnhw0fU/Cw== X-Google-Smtp-Source: AGHT+IFPnxxgbKjlJbwdgjkdDZ23zr97Zrq/9q+Ux+jFcDA4w58GsYGswXUPdk/KqYG0HgtKz1Q0yw== X-Received: by 2002:a05:6808:350b:b0:3e8:1f5d:b804 with SMTP id 5614622812f47-3ef2ec96cdcmr12856369b6e.15.1736820447188; Mon, 13 Jan 2025 18:07:27 -0800 (PST) Received: from sean-ThinkPad-T450s.lan ([207.191.35.252]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f882755172sm3915340eaf.27.2025.01.13.18.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 18:07:25 -0800 (PST) From: sean.wang@kernel.org To: nbd@nbd.name, lorenzo.bianconi@redhat.com Cc: sean.wang@mediatek.com, deren.wu@mediatek.com, mingyen.hsieh@mediatek.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 4/6] wifi: mt76: mt7925: adjust rm BSS flow to prevent next connection failure Date: Mon, 13 Jan 2025 18:07:10 -0800 Message-Id: <20250114020712.704254-4-sean.wang@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250114020712.704254-1-sean.wang@kernel.org> References: <20250114020712.704254-1-sean.wang@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ming Yen Hsieh Removing BSS without removing STAREC first will cause firmware abnormal and next connection fail. Fixes: f8797298565e ("wifi: mt76: mt7925: Cleanup MLO settings post-disconnection") Signed-off-by: Ming Yen Hsieh Signed-off-by: Sean Wang --- v2: generate the patch based on the latest mt76 tree --- .../net/wireless/mediatek/mt76/mt7925/main.c | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 90a6d62aa816..07e5c1a6d5d5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -1155,7 +1155,12 @@ static void mt7925_mac_link_sta_remove(struct mt76_dev *mdev, struct mt792x_bss_conf *mconf; mconf = mt792x_link_conf_to_mconf(link_conf); - mt792x_mac_link_bss_remove(dev, mconf, mlink); + + if (ieee80211_vif_is_mld(vif)) + mt792x_mac_link_bss_remove(dev, mconf, mlink); + else + mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf, + link_sta, false); } spin_lock_bh(&mdev->sta_poll_lock); @@ -1175,6 +1180,31 @@ mt7925_mac_sta_remove_links(struct mt792x_dev *dev, struct ieee80211_vif *vif, struct mt76_wcid *wcid; unsigned int link_id; + /* clean up bss before starec */ + for_each_set_bit(link_id, &old_links, IEEE80211_MLD_MAX_NUM_LINKS) { + struct ieee80211_link_sta *link_sta; + struct ieee80211_bss_conf *link_conf; + struct mt792x_bss_conf *mconf; + struct mt792x_link_sta *mlink; + + link_sta = mt792x_sta_to_link_sta(vif, sta, link_id); + if (!link_sta) + continue; + + mlink = mt792x_sta_to_link(msta, link_id); + if (!mlink) + continue; + + link_conf = mt792x_vif_to_bss_conf(vif, link_id); + if (!link_conf) + continue; + + mconf = mt792x_link_conf_to_mconf(link_conf); + + mt7925_mcu_add_bss_info(&dev->phy, mconf->mt76.ctx, link_conf, + link_sta, false); + } + for_each_set_bit(link_id, &old_links, IEEE80211_MLD_MAX_NUM_LINKS) { struct ieee80211_link_sta *link_sta; struct mt792x_link_sta *mlink; @@ -1212,6 +1242,7 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, { struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76); struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; struct { struct { u8 omac_idx; @@ -1242,14 +1273,10 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, mt7925_mac_sta_remove_links(dev, vif, sta, rem); - if (ieee80211_vif_is_mld(vif)) { - mt7925_mcu_set_dbdc(&dev->mphy, false); - - /* recovery omac address for the legacy interface */ - memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN); - mt76_mcu_send_msg(mdev, MCU_UNI_CMD(DEV_INFO_UPDATE), - &dev_req, sizeof(dev_req), true); - } + /* recovery omac address for the legacy interface */ + memcpy(dev_req.tlv.omac_addr, vif->addr, ETH_ALEN); + mt76_mcu_send_msg(mdev, MCU_UNI_CMD(DEV_INFO_UPDATE), + &dev_req, sizeof(dev_req), true); if (vif->type == NL80211_IFTYPE_STATION) { struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; From patchwork Tue Jan 14 02:07:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Wang X-Patchwork-Id: 857568 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63DBD3595A for ; Tue, 14 Jan 2025 02:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736820457; cv=none; b=BepyVcV+f+A6eJJAogen9RLMdsSuBIu04Al/k8LHPmoMCnJDJwjMooFhJ/n1NPSxEzgAfSUA+3I/3CpFMbx0Z32q9ftgT8wpyf+rEEE1WSjY/lhwPS2uXgjF4OSFTksxjrBCrHeDAf3PW+2KdaRrrZeoAtylOanLlCGff9gTh+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736820457; c=relaxed/simple; bh=Mng3srfWjqHXiy9aFXtvgRc7fiI8EaDZpU4EaRs8RUY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BsSDDw4ItEcAiwgPxNx19MHz+VC7HJDSrfMCITttacgRVAPT1fx9a7Q76qsT9AfZX1znSDuXLLV3wma8399VkWwPrY+SZQVl9/8BV4Zc2dJbCqrIoULHeBqnn8kiAFL2WQ1dwYuysnrHTbtMEJeHXnBu7dQb+gdlMRAD9PSFEzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-71e1d7130a5so2290551a34.0 for ; Mon, 13 Jan 2025 18:07:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736820454; x=1737425254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qAFvRSI6KUOifB1Mi3IpomlOOrHuk58k3cEKclUqi60=; b=MgrYKGwdApAdvJW0Rl45YHbOf731Y0McYlOq7wDkopbpy69mBlgD3pMPD0ceEQu/pF RTNvuG3h3eeOEches+f+JsWJ9A+gfnO5u7xeEqpcwlOsbVh7vIcwO/qAkTrCNit+NXnR 8pV+tR5+yN3MZiGTY31Kb6OeNcmOZ3br0xKbHEj5rgPA7thc5rSHiGDG/NazxgkfOdSz 1K3fqau9XR9Lwcs4b+wTBPHIWy9+fEIAlqJsyWRLyeQ7k4IJ0hXta+ym+vbRwapJKms8 wbrgOAfZvD/rMGwOrp527dDd0QTHa7ohTaUoqjTpkw9XTcX1MK3EQAxw8sU2OfECvOZH M2pQ== X-Forwarded-Encrypted: i=1; AJvYcCW/w/C6JaTI8I7MVr/CzdqHmdXCsI7FurTgNi2rJKg7+tcKlnutPH2dIzFphFU8JFPFcGzi4+sJWjUaCZ3HAQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyuiwKLqtLgR9KSBElfLdtHSHoV7Qs4pubKqmkHbuh5C7nV7nBr OzUXwfxvq4zXTcZ9E8qsf7kUSqrIBIeGv2h8fCaCiohLLtrlRpVM/xhKKS7Y X-Gm-Gg: ASbGncsSiyii+Hwh9xH5kg0s6eawVZFFxE7nhYdPzFmapZYAo42a9s76uAu7wilfuPK OH+4yZ9Fy7wqy3tF0AIb6fq1Wdzdh7mNCYW1GqYEd3FCqhJ812Rfkad9hCIH/Y7HXuo6k/FIP7f rz7jRK0TaS6S9Rr6qggeWSyYhW7+lnkVPejCAEaqyBrGgA8xqsJ/jomA/gzDg5hoxpdrkvEqT2i 8367hD5zbk9HO51HIJV41YLYAvZwbvKtYcL7ORM3E1wbDCtujAH44gqgUvwiqz3P1hUntzlpQ== X-Google-Smtp-Source: AGHT+IFjDi5J9hUEA72Jlvdihlar6QxaFWy8rUuil5dFauMav65dN9TFe89jrIIz7Uhr/G2MVCahhQ== X-Received: by 2002:a05:6830:6405:b0:71e:4fc:6ee1 with SMTP id 46e09a7af769-721e2e3a547mr16525548a34.9.1736820454411; Mon, 13 Jan 2025 18:07:34 -0800 (PST) Received: from sean-ThinkPad-T450s.lan ([207.191.35.252]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f882755172sm3915340eaf.27.2025.01.13.18.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 18:07:32 -0800 (PST) From: sean.wang@kernel.org To: nbd@nbd.name, lorenzo.bianconi@redhat.com Cc: sean.wang@mediatek.com, deren.wu@mediatek.com, mingyen.hsieh@mediatek.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 6/6] wifi: mt76: mt7925: update the power-saving flow Date: Mon, 13 Jan 2025 18:07:12 -0800 Message-Id: <20250114020712.704254-6-sean.wang@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250114020712.704254-1-sean.wang@kernel.org> References: <20250114020712.704254-1-sean.wang@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Ming Yen Hsieh After joining MLO, ensure that all links are setup before enabling power-saving. Fixes: 86c051f2c418 ("wifi: mt76: mt7925: enabling MLO when the firmware supports it") Signed-off-by: Ming Yen Hsieh Signed-off-by: Sean Wang --- v2: generate the patch based on the latest mt76 tree --- .../net/wireless/mediatek/mt76/mt7925/init.c | 1 + .../net/wireless/mediatek/mt76/mt7925/main.c | 65 ++++++++++++++++--- .../wireless/mediatek/mt76/mt7925/mt7925.h | 1 + drivers/net/wireless/mediatek/mt76/mt792x.h | 9 +++ 4 files changed, 67 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/init.c b/drivers/net/wireless/mediatek/mt76/mt7925/init.c index f41ca4248497..a2bb36dab231 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/init.c @@ -244,6 +244,7 @@ int mt7925_register_device(struct mt792x_dev *dev) dev->mt76.tx_worker.fn = mt792x_tx_worker; INIT_DELAYED_WORK(&dev->pm.ps_work, mt792x_pm_power_save_work); + INIT_DELAYED_WORK(&dev->mlo_pm_work, mt7925_mlo_pm_work); INIT_WORK(&dev->pm.wake_work, mt792x_pm_wake_work); spin_lock_init(&dev->pm.wake.lock); mutex_init(&dev->pm.mutex); diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 07e5c1a6d5d5..4d8b4272e147 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -427,6 +427,7 @@ mt7925_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mvif->bss_conf.vif = mvif; mvif->sta.vif = mvif; mvif->deflink_id = IEEE80211_LINK_UNSPECIFIED; + mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; ret = mt7925_mac_link_bss_add(dev, &vif->bss_conf, &mvif->sta.deflink); if (ret < 0) @@ -1284,6 +1285,8 @@ void mt7925_mac_sta_remove(struct mt76_dev *mdev, struct ieee80211_vif *vif, mvif->wep_sta = NULL; ewma_rssi_init(&mvif->bss_conf.rssi); } + + mvif->mlo_pm_state = MT792x_MLO_LINK_DISASSOC; } EXPORT_SYMBOL_GPL(mt7925_mac_sta_remove); @@ -1355,6 +1358,38 @@ mt7925_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return ret; } +static void +mt7925_mlo_pm_iter(void *priv, u8 *mac, struct ieee80211_vif *vif) +{ + struct mt792x_dev *dev = priv; + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + unsigned long valid = ieee80211_vif_is_mld(vif) ? + mvif->valid_links : BIT(0); + struct ieee80211_bss_conf *bss_conf; + int i; + + if (mvif->mlo_pm_state != MT792x_MLO_CHANGED_PS) + return; + + mt792x_mutex_acquire(dev); + for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { + bss_conf = mt792x_vif_to_bss_conf(vif, i); + mt7925_mcu_uni_bss_ps(dev, bss_conf); + } + mt792x_mutex_release(dev); +} + +void mt7925_mlo_pm_work(struct work_struct *work) +{ + struct mt792x_dev *dev = container_of(work, struct mt792x_dev, + mlo_pm_work.work); + struct ieee80211_hw *hw = mt76_hw(dev); + + ieee80211_iterate_active_interfaces(hw, + IEEE80211_IFACE_ITER_RESUME_ALL, + mt7925_mlo_pm_iter, dev); +} + static bool is_valid_alpha2(const char *alpha2) { if (!alpha2) @@ -1904,6 +1939,9 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, mt7925_mcu_sta_update(dev, NULL, vif, true, MT76_STA_INFO_STATE_ASSOC); mt7925_mcu_set_beacon_filter(dev, vif, vif->cfg.assoc); + + if (ieee80211_vif_is_mld(vif)) + mvif->mlo_pm_state = MT792x_MLO_LINK_ASSOC; } if (changed & BSS_CHANGED_ARP_FILTER) { @@ -1914,9 +1952,19 @@ static void mt7925_vif_cfg_changed(struct ieee80211_hw *hw, } if (changed & BSS_CHANGED_PS) { - for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { - bss_conf = mt792x_vif_to_bss_conf(vif, i); + if (hweight16(mvif->valid_links) < 2) { + /* legacy */ + bss_conf = &vif->bss_conf; mt7925_mcu_uni_bss_ps(dev, bss_conf); + } else { + if (mvif->mlo_pm_state == MT792x_MLO_LINK_ASSOC) { + mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS_PENDING; + } else if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS) { + for_each_set_bit(i, &valid, IEEE80211_MLD_MAX_NUM_LINKS) { + bss_conf = mt792x_vif_to_bss_conf(vif, i); + mt7925_mcu_uni_bss_ps(dev, bss_conf); + } + } } } @@ -1967,11 +2015,12 @@ static void mt7925_link_info_changed(struct ieee80211_hw *hw, if (changed & (BSS_CHANGED_QOS | BSS_CHANGED_BEACON_ENABLED)) mt7925_mcu_set_tx(dev, info); - if (changed & BSS_CHANGED_BSSID) { - if (ieee80211_vif_is_mld(vif) && - hweight16(mvif->valid_links) == 2) - /* Indicate the secondary setup done */ - mt7925_mcu_uni_bss_bcnft(dev, info, true); + if (mvif->mlo_pm_state == MT792x_MLO_CHANGED_PS_PENDING) { + /* Indicate the secondary setup done */ + mt7925_mcu_uni_bss_bcnft(dev, info, true); + + ieee80211_queue_delayed_work(hw, &dev->mlo_pm_work, 5 * HZ); + mvif->mlo_pm_state = MT792x_MLO_CHANGED_PS; } mt792x_mutex_release(dev); @@ -2055,8 +2104,6 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, goto free; if (mconf != &mvif->bss_conf) { - mt7925_mcu_set_bss_pm(dev, link_conf, true); - err = mt7925_set_mlo_roc(phy, &mvif->bss_conf, vif->active_links); if (err < 0) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h index fd5f9d4ea4a7..cb7b1a49fbd1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mt7925.h @@ -268,6 +268,7 @@ int mt7925_mcu_uni_tx_ba(struct mt792x_dev *dev, int mt7925_mcu_uni_rx_ba(struct mt792x_dev *dev, struct ieee80211_ampdu_params *params, bool enable); +void mt7925_mlo_pm_work(struct work_struct *work); void mt7925_scan_work(struct work_struct *work); void mt7925_roc_work(struct work_struct *work); int mt7925_mcu_uni_bss_ps(struct mt792x_dev *dev, diff --git a/drivers/net/wireless/mediatek/mt76/mt792x.h b/drivers/net/wireless/mediatek/mt76/mt792x.h index 32ed01a96bf7..6e25a4421e12 100644 --- a/drivers/net/wireless/mediatek/mt76/mt792x.h +++ b/drivers/net/wireless/mediatek/mt76/mt792x.h @@ -81,6 +81,13 @@ enum mt792x_reg_power_type { MT_AP_VLP, }; +enum mt792x_mlo_pm_state { + MT792x_MLO_LINK_DISASSOC, + MT792x_MLO_LINK_ASSOC, + MT792x_MLO_CHANGED_PS_PENDING, + MT792x_MLO_CHANGED_PS, +}; + DECLARE_EWMA(avg_signal, 10, 8) struct mt792x_link_sta { @@ -134,6 +141,7 @@ struct mt792x_vif { struct mt792x_phy *phy; u16 valid_links; u8 deflink_id; + enum mt792x_mlo_pm_state mlo_pm_state; struct work_struct csa_work; struct timer_list csa_timer; @@ -239,6 +247,7 @@ struct mt792x_dev { const struct mt792x_irq_map *irq_map; struct work_struct ipv6_ns_work; + struct delayed_work mlo_pm_work; /* IPv6 addresses for WoWLAN */ struct sk_buff_head ipv6_ns_list;