Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp698806rdb; Fri, 22 Dec 2023 02:15:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzCzSLNgvUYnOzp5YnDy+X6oZdEKilNCLXxbD9iReZWrVo6A8tyo0LuRed3vqP1rgxg5yA X-Received: by 2002:a05:6e02:20cd:b0:35f:ca37:c4d5 with SMTP id 13-20020a056e0220cd00b0035fca37c4d5mr987333ilq.118.1703240131615; Fri, 22 Dec 2023 02:15:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703240131; cv=none; d=google.com; s=arc-20160816; b=ShJmyDiLHI4yplg/RT/teXTXRKkwFZNJze73v7HYRVE422qhszwa1GKR2PcDd4K8rM NUNfQkH14rQOHU8jOpVSJa7Go0mt2NF7JVrluDk7iFzVWVrir/UaGzRxRW6xjwQrIuWx BvkZCXhqq0/B87QNDBKoKjYYvxbN1OF+PH8FNEPaRjbN5TSOr9o6rU5dchXZsqyAtyo/ Arlz2a9NnfcxAVgbwIdlvzT3AcgfHz/SeK0SmJ7v9F3gv3AIiuDZta8TYhw7psywlbwz 3O5IsORukhSNGVe9aT7h1tY2J8tPjIX/Otshm/NQFE0L/keVLKrKN/XgvB9/gunZs/xo lWZA== 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=D5RbN3476vFsByenAkXm53+PXXSwV5ILbUOA3HdUX4oj1zL6FOEOyQ3FKVlMiOYLzG FAaNebXTPvu85K+MkkORb/tQ1M/HEQ48IPd4E0Y+R6GlWSzzneSVrqqx/08SYFeDJTs8 DGVznwXK6ynDHZhpC7fY8BoRCu3bzGh7WsQ5YgmNiizvHg/bB2U28aS8ZMhXboYRdKLo l3abLRWebRaUHYh9GLQO9GRh1CzAgrOrgbhHYJC+RxKPr6fQjTjzs9EU6DeF4cTWIt4X 8aXBShvKbiQap3GV8Cnj2VESPINza9NNy2Z72JsGY+S08Fz/oO8KgUZYmX/A5sfwLI5S sAtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="wPo/URiY"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-wireless+bounces-1225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1225-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id j32-20020a634a60000000b005cdfd75a16asi54599pgl.375.2023.12.22.02.15.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 02:15:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-1225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="wPo/URiY"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-wireless+bounces-1225-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1225-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 0D50DB2242D for ; Fri, 22 Dec 2023 10:14:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7EDDD13FF4; Fri, 22 Dec 2023 10:14:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="wPo/URiY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3b85BEWu" 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 286861173C for ; Fri, 22 Dec 2023 10:14:48 +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=1703240087; 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=wPo/URiYuHvNiI7FHeheV6vgtwd7EI62vBCHCVApOOsbFY0Slyv0wmefrvwrOEhK1u0sDT HYKPis8cBJTA+Cfx5MF+Z1AQ+IFWVyby/0gYRf6EI2PDt4nv+WwA7aABFNAC2/oCY0RHbs 3M1FIbFQYyWG9qF1WdeVBwihDViI1aZ3D2Jsh5p8i87cWLp3TULaV5a+do/V8bOfazRL+u TWaeUgDPO1Igc+zzJqSkovuWoi6J217e4U+t1L8gsEBPVk3wFjIQQSe+epkZOikkIeXkHl 3NCTg43gO8rbXj7g1VYCmSMJCrvjXTd8+P5E7Y3oKbt10HTnsDa6r+7+u55qkA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703240087; 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=3b85BEWu3tNqfk/iUijtDPtwomlqOyFJDhtZAfA0BDj5z93/maf0k8oq5ilxZ54w2QIt9Y tdfDqMyJq5+fcdDw== To: linux-wireless@vger.kernel.org Cc: Jes Sorensen , Kalle Valo , Ping-Ke Shih , Bitterblue Smith , Sebastian Andrzej Siewior Subject: [PATCH v3 03/21] wifi: rtl8xxxu: support setting linktype for both interfaces Date: Fri, 22 Dec 2023 11:14:24 +0100 Message-Id: <20231222101442.626837-4-martin.kaistra@linutronix.de> In-Reply-To: <20231222101442.626837-1-martin.kaistra@linutronix.de> References: <20231222101442.626837-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