Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp355914rwr; Thu, 27 Apr 2023 02:12:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5W4+sqf7qmskLNOm4UtTS8Z2PSJDjDHTGaH56NElKUqpLonMPuM2VpwLP/2cOXkCQQC4oh X-Received: by 2002:a17:902:9b87:b0:1a6:3c64:513c with SMTP id y7-20020a1709029b8700b001a63c64513cmr654644plp.37.1682586762392; Thu, 27 Apr 2023 02:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682586762; cv=none; d=google.com; s=arc-20160816; b=nuzKGdaexo22Nvvn1CTXdM7FqFmfrHY8Wg83g2ls1zJnk+MmDOYL0F9DJIkR0j9xAR lnKjYPTPTb+KIdFiSQEG4USiccVONrE64NBmh46kOP7711vI+BRKXC/gIAhN7rlDaKrb AnIzaPmVWQjsnCygfmqJxUC/y9yfuxrvF2BslowBLaFG/YaB9TUhikoJbV/U1SiV58vr qyYvVhHivZSLqyCRdKJXVgRPnPWc5W8p2OG67uT5P02wNYOZiwsq7Bn1j7NwVY1tj0MJ 69w/7tjtf9puJ9YYwr1QFnhEqPz//4G0RFCGzSiHFYWRaKBi98aTkYU5XV3M7xDHtCiT 7ihw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=/qEIdZgEWODvORA5x7w7raVhWzerggi1+VYTX8qIa1A=; b=x8Z7I2/ZEShbVAaVSnTViJJD62mQZISY43HBnpp/jkuVU5NCO+ZjkjRZTkeJ1mVd7j cThs5LJHHxA+OYJ1wD3o6j1PEZtfglnRjs566tjZIBDhMvK+xfyHVJX8Jw/wfeK/8Isk LFEuutC7aqmXfZ/8m6iCBi+4KzyymiDebSS+ArqiEBaVoCjUu+8oalsKc4noP+98hFZ8 KG4V1IrB8w/qkK6ZItfUBhPd09hpZFJxMHCrlhiFzafNhk/8me9m62371QC2UebJKWH8 9Bpc2miJNc+EIHJFhsftNLIUVURu1t7AD4wqgEcUtLIC49TeCRHQB3cgCMSbtLe4nvgr /cDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hek1MPHF; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a170902bd0800b001a6dc4a98f7si6044533pls.365.2023.04.27.02.12.33; Thu, 27 Apr 2023 02:12:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hek1MPHF; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243329AbjD0JKP (ORCPT + 62 others); Thu, 27 Apr 2023 05:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243366AbjD0JJx (ORCPT ); Thu, 27 Apr 2023 05:09:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C5C6E50 for ; Thu, 27 Apr 2023 02:09:52 -0700 (PDT) From: Martin Kaistra DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1682586585; 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=/qEIdZgEWODvORA5x7w7raVhWzerggi1+VYTX8qIa1A=; b=hek1MPHFIe16pN1x2pDh7LL8JYkq5krsrIAkFLjUdiJSrmU4H9qs8duZf+b10Fk7zhfJ15 BBxU7NIWSQHf35ry/XDa+DQCA98uj7KLf0WMfBZybLz+KGI+HJFsKeMDw2zGzVleKUKVvE vetsJJoC4IN3BH0u10SSH/AqdLYsOe80H1KhAwB5uxUpBNxa1zEIWlp51X01K1iPBmzcBU Pl3eV7RtMVyA7PttHHrxAR6otSidxGlgbMuKK0IwszApgQUHkwe7jYn+GdehKF0NvQ3Sez 8YlzShupLbUlj+xLJTcCDAm/8oXcG4aL1OIVzRCA9rpB7Oz0ILl69f9W0r5vtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1682586585; 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=/qEIdZgEWODvORA5x7w7raVhWzerggi1+VYTX8qIa1A=; b=daRCIEpU8OHwH/Zqu9Jc6F+iaZaoLk1YdGcjPdoe1s0URtE9Ot+MrRCc0pZAzNHltAIpVh 8qkIYz9bOAQu+yAQ== To: linux-wireless@vger.kernel.org Cc: Jes Sorensen , Kalle Valo , Ping-Ke Shih , Bitterblue Smith , Sebastian Andrzej Siewior Subject: [PATCH v3 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode Date: Thu, 27 Apr 2023 11:09:10 +0200 Message-Id: <20230427090922.165088-7-martin.kaistra@linutronix.de> In-Reply-To: <20230427090922.165088-1-martin.kaistra@linutronix.de> References: <20230427090922.165088-1-martin.kaistra@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use the sequence from the vendor driver for setting up the beacon related registers. Also set the MAC address register here, in case the MAC address for the new interface should be different from what was set in rtl8xxxu_init_device(). This happens for example with the hostapd config option "bssid". Signed-off-by: Martin Kaistra Reviewed-by: Ping-Ke Shih --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 31 ++++++++++++++++--- .../wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index a44bd5038ad24..b8e5003c55e9e 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -6470,18 +6470,39 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw, int ret; u8 val8; + if (!priv->vif) + priv->vif = vif; + else + return -EOPNOTSUPP; + switch (vif->type) { case NL80211_IFTYPE_STATION: - if (!priv->vif) - priv->vif = vif; - else - return -EOPNOTSUPP; rtl8xxxu_stop_tx_beacon(priv); val8 = rtl8xxxu_read8(priv, REG_BEACON_CTRL); val8 |= BEACON_ATIM | BEACON_FUNCTION_ENABLE | BEACON_DISABLE_TSF_UPDATE; rtl8xxxu_write8(priv, REG_BEACON_CTRL, val8); + ret = 0; + break; + case NL80211_IFTYPE_AP: + rtl8xxxu_write8(priv, REG_BEACON_CTRL, + BEACON_DISABLE_TSF_UPDATE | BEACON_CTRL_MBSSID); + rtl8xxxu_write8(priv, REG_ATIMWND, 0x0c); /* 12ms */ + rtl8xxxu_write16(priv, REG_TSFTR_SYN_OFFSET, 0x7fff); /* ~32ms */ + rtl8xxxu_write8(priv, REG_DUAL_TSF_RST, DUAL_TSF_RESET_TSF0); + + /* enable BCN0 function */ + rtl8xxxu_write8(priv, REG_BEACON_CTRL, + BEACON_DISABLE_TSF_UPDATE | + BEACON_FUNCTION_ENABLE | BEACON_CTRL_MBSSID | + BEACON_CTRL_TX_BEACON_RPT); + + /* select BCN on port 0 */ + val8 = rtl8xxxu_read8(priv, REG_CCK_CHECK); + val8 &= ~BIT_BCN_PORT_SEL; + rtl8xxxu_write8(priv, REG_CCK_CHECK, val8); + ret = 0; break; default: @@ -6489,6 +6510,8 @@ static int rtl8xxxu_add_interface(struct ieee80211_hw *hw, } rtl8xxxu_set_linktype(priv, vif->type); + ether_addr_copy(priv->mac_addr, vif->addr); + rtl8xxxu_set_mac(priv); return ret; } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h index ad285e4ac0ec4..8571d5129f327 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h @@ -575,6 +575,8 @@ #define REG_ARFR1 0x0448 #define REG_ARFR2 0x044c #define REG_ARFR3 0x0450 +#define REG_CCK_CHECK 0x0454 +#define BIT_BCN_PORT_SEL BIT(5) #define REG_AMPDU_MAX_TIME_8723B 0x0456 #define REG_AGGLEN_LMT 0x0458 #define REG_AMPDU_MIN_SPACE 0x045c -- 2.30.2