Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp139109rdh; Mon, 18 Dec 2023 06:38:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7D5isEIOLHzKdo9WPk54Xyhi4O74ckZSTpcZ3SvfZd90W+zY/PF7aJdCWv/02UUfkJORQ X-Received: by 2002:a05:6102:4709:b0:464:9345:fa9b with SMTP id ei9-20020a056102470900b004649345fa9bmr10357517vsb.34.1702910327742; Mon, 18 Dec 2023 06:38:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702910327; cv=none; d=google.com; s=arc-20160816; b=w3yFcs9QIZKxQm8gKrknKDyOyrKWBXRiZbqv7k2b7qgVJN6pAgtLcVsAU3GLiqodsV zdFCYnqC5h8N31Dh2YtBziwRbCc4ut1ix0da4g/lcmMcNki2l79I2iZ5OEQKN9urgZiT 5iOdJucJ7fx8wfpUNtXskbf5xdl+xr2MLaQoytvQTYjmXZn3uoJj17Xr8ddmt8/qOAod Nq8Q/9ueayOCURl8vUUl+q05yPROtBYhqlqOMv9KZw9DGbEQUFikTXYINjwOkaQQrwbJ Vn9YjGmiJGTk3o2nI/dA1ziwJ9WHSe0E1ePrGlNflHwGP1MzSUA1sWm/MJzjY3UxJU3F JbZg== 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=N5kEICenyd2aan/48bm9RsqR2/tJuqTwqvQasfll+Ao=; fh=KsoNWtazjfstHns8t6UZ1pulwZL69aEO39vRs0LPvyo=; b=jVt8flwpVxYDPDszppPjL9O9cXFLMaYrU57iv6rychr0YDTapwmCCio2+Efj3ZU1Fn G0C5KnQzdytfI6l5GX101K5rdPq4eaL9S+3DSp5hjBzilj/MGdTOLfuK3z8IRLap8Qaz H2Kbz9cA2xV7SmHzk7r1u/1WQqTXTa+0FxN3Fec1mt8qZrnsDQmyJwqOAKUKz+DNzMml 5sZHm+2SasN9w2mSSOZG4iWCfWxQl5lDYjlz1FosViPvuf2Gb4dPnFaxyIyHOfqzcy7K EaV8wIPOtXetsZo0FIVsZA4qnVy+9sTt6L3sJdwnURaWHG/OazmgOMTSLZV5mXoDFIAR C21g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QXm2Cvhe; dkim=neutral (no key) header.i=@linutronix.de header.b=8mkHCakv; spf=pass (google.com: domain of linux-wireless+bounces-930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-930-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n23-20020a67f117000000b00466a5e22f2dsi101481vsk.674.2023.12.18.06.38.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:38:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QXm2Cvhe; dkim=neutral (no key) header.i=@linutronix.de header.b=8mkHCakv; spf=pass (google.com: domain of linux-wireless+bounces-930-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-930-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7B5141C24565 for ; Mon, 18 Dec 2023 14:38:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCACF498A4; Mon, 18 Dec 2023 14:37:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QXm2Cvhe"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="8mkHCakv" 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 C443042042 for ; Mon, 18 Dec 2023 14:37:15 +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=1702910230; 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=N5kEICenyd2aan/48bm9RsqR2/tJuqTwqvQasfll+Ao=; b=QXm2Cvhe5fNPMf1gNfz4blI2D4fPOX4QPRBF8WRQY97WOOcg6A0HeQrqEMZcctyMcU4M91 TSezvA/F810gB7iZ+0w9m6DnAAiOV2BCO9k6qpkroQOXuy7NkmGtPfO9ppbX8mcAF3F2vz jIyQ4b4FWAyMpn52RzS4yLnIjraYQjschrCTd09NmdZ9G9vi18WXsb9xOEUB9iuOOGeDcd E8aOtlmgyWwxtjO5VZuyLrk/wV6XTX3qVIhAwgSJmWus9Aio1P7Qh28wPjdk/aYgO+NFyV hGrqaRKxfSgpEUv3S/kAxu1URxI7HBBEyjqGenZJru1SDz2kwBAy/4RHL5RIvQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702910230; 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=N5kEICenyd2aan/48bm9RsqR2/tJuqTwqvQasfll+Ao=; b=8mkHCakvvmxJLhrK+K1rnnFwLXFdoDwwKNf/y8ZK8U9l55N2fX8ZZZloIU0Bd7KT6C3eAs Bh0O6Gcr6HcVpZDg== To: linux-wireless@vger.kernel.org Cc: Jes Sorensen , Kalle Valo , Ping-Ke Shih , Bitterblue Smith , Sebastian Andrzej Siewior Subject: [PATCH 19/20] wifi: rtl8xxxu: make supporting AP mode only on port 0 transparent Date: Mon, 18 Dec 2023 15:36:44 +0100 Message-Id: <20231218143645.433356-20-martin.kaistra@linutronix.de> In-Reply-To: <20231218143645.433356-1-martin.kaistra@linutronix.de> References: <20231218143645.433356-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 When the driver is used for concurrent mode, both virtual interfaces can be set to station or AP mode, though only one can be in AP mode at the same time. In order to keep the code simple, use only hw port 0 for AP mode. When an interface is added in AP mode which would be assigned to port 1, use a switch_port function to transparently swap the mapping between virtual interface and hw port. Signed-off-by: Martin Kaistra --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 84 ++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 88730791091a7..595f447874f4d 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -6613,6 +6613,84 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) return ret; } +static void rtl8xxxu_switch_ports(struct rtl8xxxu_priv *priv) +{ + u8 macid[ETH_ALEN], bssid[ETH_ALEN], macid_1[ETH_ALEN], bssid_1[ETH_ALEN]; + u8 msr, bcn_ctrl, bcn_ctrl_1, atimwnd[2], atimwnd_1[2]; + struct rtl8xxxu_vif *rtlvif; + struct ieee80211_vif *vif; + u8 tsftr[8], tsftr_1[8]; + int i; + + msr = rtl8xxxu_read8(priv, REG_MSR); + bcn_ctrl = rtl8xxxu_read8(priv, REG_BEACON_CTRL); + bcn_ctrl_1 = rtl8xxxu_read8(priv, REG_BEACON_CTRL_1); + + for (i = 0; i < ARRAY_SIZE(atimwnd); i++) + atimwnd[i] = rtl8xxxu_read8(priv, REG_ATIMWND + i); + for (i = 0; i < ARRAY_SIZE(atimwnd_1); i++) + atimwnd_1[i] = rtl8xxxu_read8(priv, REG_ATIMWND_1 + i); + + for (i = 0; i < ARRAY_SIZE(tsftr); i++) + tsftr[i] = rtl8xxxu_read8(priv, REG_TSFTR + i); + for (i = 0; i < ARRAY_SIZE(tsftr); i++) + tsftr_1[i] = rtl8xxxu_read8(priv, REG_TSFTR1 + i); + + for (i = 0; i < ARRAY_SIZE(macid); i++) + macid[i] = rtl8xxxu_read8(priv, REG_MACID + i); + + for (i = 0; i < ARRAY_SIZE(bssid); i++) + bssid[i] = rtl8xxxu_read8(priv, REG_BSSID + i); + + for (i = 0; i < ARRAY_SIZE(macid_1); i++) + macid_1[i] = rtl8xxxu_read8(priv, REG_MACID1 + i); + + for (i = 0; i < ARRAY_SIZE(bssid_1); i++) + bssid_1[i] = rtl8xxxu_read8(priv, REG_BSSID1 + i); + + /* disable bcn function, disable update TSF */ + rtl8xxxu_write8(priv, REG_BEACON_CTRL, (bcn_ctrl & + (~BEACON_FUNCTION_ENABLE)) | BEACON_DISABLE_TSF_UPDATE); + rtl8xxxu_write8(priv, REG_BEACON_CTRL_1, (bcn_ctrl_1 & + (~BEACON_FUNCTION_ENABLE)) | BEACON_DISABLE_TSF_UPDATE); + + /* switch msr */ + msr = (msr & 0xf0) | ((msr & 0x03) << 2) | ((msr & 0x0c) >> 2); + rtl8xxxu_write8(priv, REG_MSR, msr); + + /* write port0 */ + rtl8xxxu_write8(priv, REG_BEACON_CTRL, bcn_ctrl_1 & ~BEACON_FUNCTION_ENABLE); + for (i = 0; i < ARRAY_SIZE(atimwnd_1); i++) + rtl8xxxu_write8(priv, REG_ATIMWND + i, atimwnd_1[i]); + for (i = 0; i < ARRAY_SIZE(tsftr_1); i++) + rtl8xxxu_write8(priv, REG_TSFTR + i, tsftr_1[i]); + for (i = 0; i < ARRAY_SIZE(macid_1); i++) + rtl8xxxu_write8(priv, REG_MACID + i, macid_1[i]); + for (i = 0; i < ARRAY_SIZE(bssid_1); i++) + rtl8xxxu_write8(priv, REG_BSSID + i, bssid_1[i]); + + /* write port1 */ + rtl8xxxu_write8(priv, REG_BEACON_CTRL_1, bcn_ctrl & ~BEACON_FUNCTION_ENABLE); + for (i = 0; i < ARRAY_SIZE(atimwnd); i++) + rtl8xxxu_write8(priv, REG_ATIMWND_1 + i, atimwnd[i]); + for (i = 0; i < ARRAY_SIZE(tsftr); i++) + rtl8xxxu_write8(priv, REG_TSFTR1 + i, tsftr[i]); + for (i = 0; i < ARRAY_SIZE(macid); i++) + rtl8xxxu_write8(priv, REG_MACID1 + i, macid[i]); + for (i = 0; i < ARRAY_SIZE(bssid); i++) + rtl8xxxu_write8(priv, REG_BSSID1 + i, bssid[i]); + + /* write bcn ctl */ + rtl8xxxu_write8(priv, REG_BEACON_CTRL, bcn_ctrl_1); + rtl8xxxu_write8(priv, REG_BEACON_CTRL_1, bcn_ctrl); + + vif = priv->vifs[0]; + priv->vifs[0] = priv->vifs[1]; + priv->vifs[1] = vif; + rtlvif = (struct rtl8xxxu_vif *)priv->vifs[1]->drv_priv; + rtlvif->port_num = 1; +} + static int rtl8xxxu_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -6640,8 +6718,10 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw, } break; case NL80211_IFTYPE_AP: - if (port_num == 1) - return -EOPNOTSUPP; + if (port_num == 1) { + rtl8xxxu_switch_ports(priv); + port_num = 0; + } rtl8xxxu_write8(priv, REG_BEACON_CTRL, BEACON_DISABLE_TSF_UPDATE | BEACON_CTRL_MBSSID); -- 2.39.2