From: Martin Kaistra <martin.kaistra@linutronix.de>
To: linux-wireless@vger.kernel.org
Cc: Jes Sorensen <Jes.Sorensen@gmail.com>,
Kalle Valo <kvalo@kernel.org>, Ping-Ke Shih <pkshih@realtek.com>,
Bitterblue Smith <rtl8821cerfe2@gmail.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH v3 06/18] wifi: rtl8xxxu: Allow creating interface in AP mode
Date: Thu, 27 Apr 2023 11:09:10 +0200 [thread overview]
Message-ID: <20230427090922.165088-7-martin.kaistra@linutronix.de> (raw)
In-Reply-To: <20230427090922.165088-1-martin.kaistra@linutronix.de>
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 <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
---
.../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
next prev parent reply other threads:[~2023-04-27 9:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 9:09 [PATCH v3 00/18] wifi: rtl8xxxu: Add AP mode support for 8188f Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 01/18] wifi: rtl8xxxu: Add start_ap() callback Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 02/18] wifi: rtl8xxxu: Select correct queue for beacon frames Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 03/18] wifi: rtl8xxxu: Add beacon functions Martin Kaistra
2023-04-28 0:38 ` Ping-Ke Shih
2023-04-28 6:59 ` Martin Kaistra
2023-04-28 8:11 ` Ping-Ke Shih
2023-04-27 9:09 ` [PATCH v3 04/18] wifi: rtl8xxxu: Add set_tim() callback Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 05/18] wifi: rtl8xxxu: Allow setting rts threshold to -1 Martin Kaistra
2023-04-27 9:09 ` Martin Kaistra [this message]
2023-04-27 9:09 ` [PATCH v3 07/18] wifi: rtl8xxxu: Actually use macid in rtl8xxxu_gen2_report_connect Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 08/18] wifi: rtl8xxxu: Add parameter role to report_connect Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 09/18] wifi: rtl8xxxu: Add parameter force to rtl8xxxu_refresh_rate_mask Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 10/18] wifi: rtl8xxxu: Add sta_add() and sta_remove() callbacks Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 11/18] wifi: rtl8xxxu: Put the macid in txdesc Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 12/18] wifi: rtl8xxxu: Add parameter macid to update_rate_mask Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 13/18] wifi: rtl8xxxu: Enable hw seq for mgmt/non-QoS data frames Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 14/18] wifi: rtl8xxxu: Clean up filter configuration Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 15/18] wifi: rtl8xxxu: Remove usage of ieee80211_get_tx_rate() Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 16/18] wifi: rtl8xxxu: Remove usage of tx_info->control.rates[0].flags Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 17/18] wifi: rtl8xxxu: Declare AP mode support for 8188f Martin Kaistra
2023-04-27 9:09 ` [PATCH v3 18/18] wifi: rtl8xxxu: Set maximum number of supported stations Martin Kaistra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230427090922.165088-7-martin.kaistra@linutronix.de \
--to=martin.kaistra@linutronix.de \
--cc=Jes.Sorensen@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=pkshih@realtek.com \
--cc=rtl8821cerfe2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).