Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp272499rdb; Thu, 21 Dec 2023 08:44:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEe48oL2WYTBRZsGUzt3p3jUZJs7IZIm8SYMfr/xZ0guB4KH7DaLrdWsqV+W2K52RZxJwFG X-Received: by 2002:a05:6512:6c2:b0:50e:36e9:2be9 with SMTP id u2-20020a05651206c200b0050e36e92be9mr3123671lff.194.1703177069271; Thu, 21 Dec 2023 08:44:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703177069; cv=none; d=google.com; s=arc-20160816; b=nfPyU5w57j86/Dv/86f/fXHobFnz9jL4bIxvfVhsCcV9DtDNmRrMyRBNoEvvoRJqct JnmYpAOJ7gdWC12hAi3IRF71nhbeo6gKNSMX1mrpym0G31h6nVykMQV64iYkE5TnL8rl dfkoupBP91MET42+Rzlzp74UfC9OSWyPwDgmBQih0IAtsQifoavwfOQRsqHPVKVopEsI Y40o15liDhsLfDmbw22tgtKBQPjg4BxHFTMJ+4i180HVWpWVSG0w4ElSl/kLy5MMQa6Q GsMcDPWbgXN/vicoI6MJGS0G2fTM+h54saKP6HGAh5XIBjnUnB2cA2yjBNtEOUs9AXXf 6tVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=yuh+ofRV0CoC+Gftj1zT66pmd0kQj5yDJl758CSUz3U=; fh=KsoNWtazjfstHns8t6UZ1pulwZL69aEO39vRs0LPvyo=; b=WrTUgxbW9KP8Uv5mYYrzbQf8XXmp0MjsXWgJ2YST8uOsYSZkWT2civx5Y1KldZ60rl yVMoi7depB84/cp5j7b3N1Bi+jR97r2D9v+cPX5nH2wAlbIiPwqO1rLLd0ivUK9PTOE7 oWx8T1AZ+C5xfNGfcx/0JFCswBmKCWqUKmGR/L9vuHBpljFE/oYQ1FF8PaXQRVXaZc2J pyDjwCrQkd5STChTUy1oQBQlC3hJ870l4hpVY0Ejb+d/qoPDuuyOyfl2GWUqvAYdcLBO cXgpDVKNzrfhcvsjGi4nYxZGGQv/F/tdaMcLHGfUU2C8Qvs9qkqGfS9xWS8y4yLoyYrf 7lKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cmA2cQ5r; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-wireless+bounces-1153-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1153-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ay5-20020a170906d28500b00a237004e450si972899ejb.395.2023.12.21.08.44.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 08:44:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-1153-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cmA2cQ5r; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-wireless+bounces-1153-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1153-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 07BA11F250BC for ; Thu, 21 Dec 2023 16:44:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30E9B58229; Thu, 21 Dec 2023 16:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="cmA2cQ5r"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mLPTWfNk" X-Original-To: linux-wireless@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05E1155E77 for ; Thu, 21 Dec 2023 16:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Martin Kaistra DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703177043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yuh+ofRV0CoC+Gftj1zT66pmd0kQj5yDJl758CSUz3U=; b=cmA2cQ5r0LjBVTwNAZdBbeglYpcohaZyu5gBIs1L4MEx2S6qRGZBcQwkWmlF0GsVbAfqQ9 VjnQLejw2hCr85mqZuGd4xAbgNTvuw2ZVtzNBEcN55x2TnVGFVyRVYeD4TUH/Vzks8DwHk Z/2o3hkgd347Mo0jomfh6vsDo/ctn0W3zMTGDWlwAUDr+Ju4pSqhdWLXcM8a5OW1O667u7 Xv7ECxOULureBKjWJtmPUEIiHJhw0Yt7SOiBPJfjohrlh5wSTTXvgXzPHyAToZQWgfg1qD R3sbJetqgdnSScJ9o0SS6AS0W7KzM1bzTGwwWO3ReQCGDrX3ULRVakcwf22Xww== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703177043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yuh+ofRV0CoC+Gftj1zT66pmd0kQj5yDJl758CSUz3U=; b=mLPTWfNkl7+zYDf4goGTdR4Y97fQfNuXZ2F7PXTSTbzGHolEYvLqoWX2/RxLTm4MgWdkll QloEn5VjzsUNn0BA== To: linux-wireless@vger.kernel.org Cc: Jes Sorensen , Kalle Valo , Ping-Ke Shih , Bitterblue Smith , Sebastian Andrzej Siewior Subject: [PATCH v2 03/21] wifi: rtl8xxxu: support setting linktype for both interfaces Date: Thu, 21 Dec 2023 17:43:35 +0100 Message-Id: <20231221164353.603258-4-martin.kaistra@linutronix.de> In-Reply-To: <20231221164353.603258-1-martin.kaistra@linutronix.de> References: <20231221164353.603258-1-martin.kaistra@linutronix.de> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To prepare for concurrent mode, enhance the set_linktype function to be able to set the linktype in the MSR register for both hardware ports. Until the users of set_linktype can handle multiple interfaces, use port_num = 0. Signed-off-by: Martin Kaistra Reviewed-by: Ping-Ke Shih --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 5b7c20970a973..305d6dd585dfa 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -1633,33 +1633,41 @@ rtl8xxxu_gen1_set_tx_power(struct rtl8xxxu_priv *priv, int channel, bool ht40) } static void rtl8xxxu_set_linktype(struct rtl8xxxu_priv *priv, - enum nl80211_iftype linktype) + enum nl80211_iftype linktype, int port_num) { - u8 val8; - - val8 = rtl8xxxu_read8(priv, REG_MSR); - val8 &= ~MSR_LINKTYPE_MASK; + u8 val8, type; switch (linktype) { case NL80211_IFTYPE_UNSPECIFIED: - val8 |= MSR_LINKTYPE_NONE; + type = MSR_LINKTYPE_NONE; break; case NL80211_IFTYPE_ADHOC: - val8 |= MSR_LINKTYPE_ADHOC; + type = MSR_LINKTYPE_ADHOC; break; case NL80211_IFTYPE_STATION: - val8 |= MSR_LINKTYPE_STATION; + type = MSR_LINKTYPE_STATION; break; case NL80211_IFTYPE_AP: - val8 |= MSR_LINKTYPE_AP; + type = MSR_LINKTYPE_AP; break; default: - goto out; + return; + } + + switch (port_num) { + case 0: + val8 = rtl8xxxu_read8(priv, REG_MSR) & 0x0c; + val8 |= type; + break; + case 1: + val8 = rtl8xxxu_read8(priv, REG_MSR) & 0x03; + val8 |= type << 2; + break; + default: + return; } rtl8xxxu_write8(priv, REG_MSR, val8); -out: - return; } static void @@ -4236,7 +4244,6 @@ static int rtl8xxxu_init_device(struct ieee80211_hw *hw) } rtl8xxxu_set_mac(priv); - rtl8xxxu_set_linktype(priv, NL80211_IFTYPE_STATION); /* * Configure initial WMAC settings @@ -4964,7 +4971,7 @@ rtl8xxxu_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (changed & BSS_CHANGED_ASSOC) { dev_dbg(dev, "Changed ASSOC: %i!\n", vif->cfg.assoc); - rtl8xxxu_set_linktype(priv, vif->type); + rtl8xxxu_set_linktype(priv, vif->type, 0); if (vif->cfg.assoc) { u32 ramask; @@ -6610,7 +6617,7 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw, ret = -EOPNOTSUPP; } - rtl8xxxu_set_linktype(priv, vif->type); + rtl8xxxu_set_linktype(priv, vif->type, 0); ether_addr_copy(priv->mac_addr, vif->addr); rtl8xxxu_set_mac(priv); -- 2.39.2