Skip to contentSkip to conversation

wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common

PATCH In review Bitterblue Smith 4 participants 30 messages Mar 12, 2024 – Sep 16, 2024 Realtek wireless driver (rtlwifi family)

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Tested only with RTL8192DU.

---
 drivers/net/wireless/realtek/rtlwifi/Kconfig  |    6 +
 drivers/net/wireless/realtek/rtlwifi/Makefile |    1 +
 .../realtek/rtlwifi/rtl8192d/Makefile         |   11 +
 .../rtlwifi/{rtl8192de => rtl8192d}/def.h     |    0
 .../realtek/rtlwifi/rtl8192d/dm_common.c      |  417 ++++++
 .../realtek/rtlwifi/rtl8192d/dm_common.h      |   98 ++
 .../realtek/rtlwifi/rtl8192d/fw_common.c      |  370 +++++
 .../realtek/rtlwifi/rtl8192d/fw_common.h      |   51 +
 .../realtek/rtlwifi/rtl8192d/hw_common.c      | 1191 +++++++++++++++++
 .../realtek/rtlwifi/rtl8192d/hw_common.h      |   24 +
 .../wireless/realtek/rtlwifi/rtl8192d/main.c  |    9 +
 .../realtek/rtlwifi/rtl8192d/phy_common.c     |  817 +++++++++++
 .../realtek/rtlwifi/rtl8192d/phy_common.h     |   90 ++
 .../rtlwifi/{rtl8192de => rtl8192d}/reg.h     |    0
 .../realtek/rtlwifi/rtl8192d/rf_common.c      |  380 ++++++
 .../realtek/rtlwifi/rtl8192d/rf_common.h      |   13 +
 .../realtek/rtlwifi/rtl8192d/trx_common.c     |  522 ++++++++
 .../realtek/rtlwifi/rtl8192d/trx_common.h     |  442 ++++++
 .../wireless/realtek/rtlwifi/rtl8192de/dm.c   |  410 +-----
 .../wireless/realtek/rtlwifi/rtl8192de/dm.h   |   91 +-
 .../wireless/realtek/rtlwifi/rtl8192de/fw.c   |  370 +----
 .../wireless/realtek/rtlwifi/rtl8192de/fw.h   |   37 -
 .../wireless/realtek/rtlwifi/rtl8192de/hw.c   | 1166 +---------------
 .../wireless/realtek/rtlwifi/rtl8192de/hw.h   |   11 -
 .../wireless/realtek/rtlwifi/rtl8192de/led.c  |    2 +-
 .../wireless/realtek/rtlwifi/rtl8192de/phy.c  |  895 +------------
 .../wireless/realtek/rtlwifi/rtl8192de/phy.h  |   57 -
 .../wireless/realtek/rtlwifi/rtl8192de/rf.c   |  375 +-----
 .../wireless/realtek/rtlwifi/rtl8192de/rf.h   |    5 -
 .../wireless/realtek/rtlwifi/rtl8192de/sw.c   |   10 +-
 .../wireless/realtek/rtlwifi/rtl8192de/trx.c  |  515 +------
 .../wireless/realtek/rtlwifi/rtl8192de/trx.h  |  433 ------
 32 files changed, 4540 insertions(+), 4279 deletions(-)
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/Makefile
 rename drivers/net/wireless/realtek/rtlwifi/{rtl8192de => rtl8192d}/def.h (100%)
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/dm_common.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/dm_common.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/main.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h
 rename drivers/net/wireless/realtek/rtlwifi/{rtl8192de => rtl8192d}/reg.h (100%)
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/rf_common.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/rf_common.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/trx_common.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192d/trx_common.h
drivers/net/wireless/realtek/rtlwifi/Kconfig +6 -0
index 9f6a4e35543c..2319eaa8845a 100644
@@ -37,6 +37,7 @@ config RTL8192SE
 config RTL8192DE
 	tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter"
 	depends on PCI
+	select RTL8192D_COMMON
 	select RTLWIFI
 	select RTLWIFI_PCI
 	help
@@ -142,6 +143,11 @@ config RTL8192C_COMMON
 	depends on RTL8192CE || RTL8192CU
 	default y
 
+config RTL8192D_COMMON
+	tristate
+	depends on RTL8192DE
+	default y
+
 config RTL8723_COMMON
 	tristate
 	depends on RTL8723AE || RTL8723BE
drivers/net/wireless/realtek/rtlwifi/Makefile +1 -0
index 09c30e428375..423981b148df 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_RTL8192C_COMMON)	+= rtl8192c/
 obj-$(CONFIG_RTL8192CE)		+= rtl8192ce/
 obj-$(CONFIG_RTL8192CU)		+= rtl8192cu/
 obj-$(CONFIG_RTL8192SE)		+= rtl8192se/
+obj-$(CONFIG_RTL8192D_COMMON)	+= rtl8192d/
 obj-$(CONFIG_RTL8192DE)		+= rtl8192de/
 obj-$(CONFIG_RTL8723AE)		+= rtl8723ae/
 obj-$(CONFIG_RTL8723BE)		+= rtl8723be/
drivers/net/wireless/realtek/rtlwifi/rtl8192d/Makefile new file +11 -0
new file mode 100644
index 000000000000..beebdfa3f7ff
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+rtl8192d-common-objs :=		\
+		dm_common.o \
+		fw_common.o \
+		hw_common.o \
+		main.o \
+		phy_common.o \
+		rf_common.o \
+		trx_common.o
+
+obj-$(CONFIG_RTL8192D_COMMON) += rtl8192d-common.o
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h renamed from drivers/net/wireless/realtek/rtlwifi/rtl8192de/def.h +0 -0
similarity index 100%
rename from drivers/net/wireless/realtek/rtlwifi/rtl8192de/def.h
rename to drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h
drivers/net/wireless/realtek/rtlwifi/rtl8192d/dm_common.c new file +417 -0

417 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/dm_common.h new file +98 -0

98 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c new file +370 -0

370 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.h new file +51 -0

51 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c new file +1191 -0

1,191 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.h new file +24 -0
new file mode 100644
index 000000000000..12b915f15291
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#ifndef __RTL92DE_HW_COMMON_H__
+#define __RTL92DE_HW_COMMON_H__
+
+void rtl92de_stop_tx_beacon(struct ieee80211_hw *hw);
+void rtl92de_resume_tx_beacon(struct ieee80211_hw *hw);
+void rtl92d_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
+void rtl92d_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
+bool rtl92de_llt_write(struct ieee80211_hw *hw, u32 address, u32 data);
+void rtl92de_enable_hw_security_config(struct ieee80211_hw *hw);
+void rtl92de_set_qos(struct ieee80211_hw *hw, int aci);
+void rtl92de_read_eeprom_info(struct ieee80211_hw *hw);
+void rtl92de_update_hal_rate_tbl(struct ieee80211_hw *hw,
+				 struct ieee80211_sta *sta,
+				 u8 rssi_level, bool update_bw);
+void rtl92de_update_channel_access_setting(struct ieee80211_hw *hw);
+bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid);
+void rtl92de_set_key(struct ieee80211_hw *hw, u32 key_index,
+		     u8 *p_macaddr, bool is_group, u8 enc_algo,
+		     bool is_wepkey, bool clear_all);
+
+#endif
drivers/net/wireless/realtek/rtlwifi/rtl8192d/main.c new file +9 -0
new file mode 100644
index 000000000000..75f7e260a296
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#include "../wifi.h"
+#include <linux/module.h>
+
+MODULE_AUTHOR("Realtek WlanFAE	<[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Realtek 8192D 802.11an common routines");
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c new file +817 -0

804 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h new file +90 -0

90 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h renamed from drivers/net/wireless/realtek/rtlwifi/rtl8192de/reg.h +0 -0
similarity index 100%
rename from drivers/net/wireless/realtek/rtlwifi/rtl8192de/reg.h
rename to drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h
drivers/net/wireless/realtek/rtlwifi/rtl8192d/rf_common.c new file +380 -0

380 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/rf_common.h new file +13 -0
new file mode 100644
index 000000000000..c243ec08369b

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192d/trx_common.c new file +522 -0

522 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/trx_common.h new file +442 -0

442 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/dm.c +8 -402

410 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/dm.h +2 -89

91 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.c +10 -360

370 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/fw.h +0 -37
index 7f0a17c1a9ea..9e1385ac17b1 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.c +17 -1149

1,166 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/hw.h +0 -11
index ea495216d394..bda4a1a7c91d 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192de/led.c +1 -1
index 4bd708570992..33aede56c81b 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +46 -849

895 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.h +0 -57

57 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/rf.c +3 -372

375 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/rf.h +0 -5
index 4e646cc9ebc0..c097d90cc99c 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c +7 -3
index afd685ed460a..e87cc7f45414 100644

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.c +4 -511

515 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192de/trx.h +0 -433

433 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.2

Part of the diff is not shown here. View the raw message.

#1 lore raw

PATCH 2/3 wifi: rtlwifi: Adjust rtl8192d-common for USB

A few of the shared functions need small changes for the USB driver.

Also, add a few macros to wifi.h and initialise rtlhal.interfaceindex for USB devices.

---
 .../wireless/realtek/rtlwifi/rtl8192d/def.h   |   2 +
 .../realtek/rtlwifi/rtl8192d/fw_common.c      |  19 +++
 .../realtek/rtlwifi/rtl8192d/hw_common.c      |  46 ++++--
 .../realtek/rtlwifi/rtl8192d/phy_common.c     |  26 ++-
 .../realtek/rtlwifi/rtl8192d/phy_common.h     |   6 +
 .../wireless/realtek/rtlwifi/rtl8192d/reg.h   | 156 +++++++++++++++---
 drivers/net/wireless/realtek/rtlwifi/usb.c    |   3 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h   |   5 +
 8 files changed, 222 insertions(+), 41 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +2 -0
index 21726d9b4aef..ee45f51fcf71 100644
@@ -116,6 +116,8 @@ enum version_8192d {
 #define IS_92D_E_CUT(version)		((IS_92D(version)) ?		\
 				 ((GET_CVID_CUT_VERSION(version) ==	\
 				 CHIP_92D_E_CUT) ? true : false) : false)
+#define IS_NORMAL_CHIP(version)	\
+	((version & NORMAL_CHIP) ? true : false)
 
 enum rf_optype {
 	RF_OP_BY_SW_3WIRE = 0,
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +19 -0
index e333275c51c3..ac48bd9dcc9f 100644
@@ -94,9 +94,22 @@ EXPORT_SYMBOL_GPL(rtl92d_fw_free_to_go);
 void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
 	u8 u1b_tmp;
 	u8 delay = 100;
 
+	if (rtlhal->interface == INTF_USB) {
+		delay *= 60;
+
+		rtl_write_byte(rtlpriv, REG_FSIMR, 0);
+
+		/* We need to disable other HRCV INT to influence 8051 reset. */
+		rtl_write_byte(rtlpriv, REG_FWIMR, 0x20);
+
+		/* Close mask to prevent incorrect FW write operation. */
+		rtl_write_byte(rtlpriv, REG_FTIMR, 0);
+	}
+
 	/* Set (REG_HMETFR + 3) to  0x20 is reset 8051 */
 	rtl_write_byte(rtlpriv, REG_HMETFR + 3, 0x20);
 	u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
@@ -107,6 +120,12 @@ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
 		udelay(50);
 		u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
 	}
+
+	if (rtlhal->interface == INTF_USB) {
+		if ((u1b_tmp & BIT(2)) && delay == 0)
+			rtl_write_byte(rtlpriv, REG_FWIMR, 0);
+	}
+
 	WARN_ONCE((delay <= 0), "rtl8192de: 8051 reset failed!\n");
 	rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
 		"=====> 8051 reset success (%d)\n", delay);
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +33 -13

88 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +19 -7
index 487628ac491b..1e39940a3ba7 100644
@@ -81,11 +81,13 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
 	rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
 		"regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
 		regaddr, rfpath, bitmask);
-	spin_lock(&rtlpriv->locks.rf_lock);
+	if (rtlpriv->rtlhal.interface == INTF_PCI)
+		spin_lock(&rtlpriv->locks.rf_lock);
 	original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr);
 	bitshift = calculate_bit_shift(bitmask);
 	readback_value = (original_value & bitmask) >> bitshift;
-	spin_unlock(&rtlpriv->locks.rf_lock);
+	if (rtlpriv->rtlhal.interface == INTF_PCI)
+		spin_unlock(&rtlpriv->locks.rf_lock);
 	rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
 		"regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
 		regaddr, rfpath, bitmask, original_value);
@@ -105,7 +107,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
 		regaddr, bitmask, data, rfpath);
 	if (bitmask == 0)
 		return;
-	spin_lock(&rtlpriv->locks.rf_lock);
+	if (rtlpriv->rtlhal.interface == INTF_PCI)
+		spin_lock(&rtlpriv->locks.rf_lock);
 	if (rtlphy->rf_mode != RF_OP_BY_FW) {
 		if (bitmask != RFREG_OFFSET_MASK) {
 			original_value = _rtl92d_phy_rf_serial_read(hw,
@@ -116,7 +119,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
 		}
 		_rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data);
 	}
-	spin_unlock(&rtlpriv->locks.rf_lock);
+	if (rtlpriv->rtlhal.interface == INTF_PCI)
+		spin_unlock(&rtlpriv->locks.rf_lock);
 	rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
 		"regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
 		regaddr, bitmask, data, rfpath);
@@ -642,6 +646,8 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
 	case IO_CMD_PAUSE_DM_BY_SCAN:
 		rtlphy->initgain_backup.xaagccore1 = de_digtable->cur_igvalue;
 		de_digtable->cur_igvalue = 0x37;
+		if (rtlpriv->rtlhal.interface == INTF_USB)
+			de_digtable->cur_igvalue = 0x17;
 		rtl92d_dm_write_dig(hw);
 		break;
 	default:
@@ -698,22 +704,28 @@ void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	u8 offset = REG_MAC_PHY_CTRL_NORMAL;
+	u8 temp = 0xf0;
+
+	if (rtlhal->interface == INTF_USB) {
+		temp = rtl_read_byte(rtlpriv, offset);
+		temp &= ~(BIT(0) | BIT(1) | BIT(2));
+	}
 
 	switch (rtlhal->macphymode) {
 	case DUALMAC_DUALPHY:
 		rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
 			"MacPhyMode: DUALMAC_DUALPHY\n");
-		rtl_write_byte(rtlpriv, offset, 0xF3);
+		rtl_write_byte(rtlpriv, offset, temp | BIT(0) | BIT(1));
 		break;
 	case SINGLEMAC_SINGLEPHY:
 		rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
 			"MacPhyMode: SINGLEMAC_SINGLEPHY\n");
-		rtl_write_byte(rtlpriv, offset, 0xF4);
+		rtl_write_byte(rtlpriv, offset, temp | BIT(2));
 		break;
 	case DUALMAC_SINGLEPHY:
 		rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
 			"MacPhyMode: DUALMAC_SINGLEPHY\n");
-		rtl_write_byte(rtlpriv, offset, 0xF1);
+		rtl_write_byte(rtlpriv, offset, temp | BIT(0));
 		break;
 	}
 }
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +6 -0
index 071776d05eb9..5649a11f4405 100644
@@ -41,6 +41,9 @@ static inline void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
+	if (rtlpriv->rtlhal.interface == INTF_USB)
+		return;
+
 	if (rtlpriv->rtlhal.interfaceindex == 1)
 		spin_lock_irqsave(&rtlpriv->locks.cck_and_rw_pagea_lock, *flag);
 }
@@ -50,6 +53,9 @@ static inline void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
+	if (rtlpriv->rtlhal.interface == INTF_USB)
+		return;
+
 	if (rtlpriv->rtlhal.interfaceindex == 1)
 		spin_unlock_irqrestore(&rtlpriv->locks.cck_and_rw_pagea_lock,
 			*flag);
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +135 -21

246 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/usb.c +3 -0
index 6e8c87a2fae4..2ea72d9e3957 100644
@@ -979,6 +979,9 @@ int rtl_usb_probe(struct usb_interface *intf,
 	usb_priv->dev.intf = intf;
 	usb_priv->dev.udev = udev;
 	usb_set_intfdata(intf, hw);
+	/* For dual MAC RTL8192DU, which has two interfaces. */
+	rtlpriv->rtlhal.interfaceindex =
+		intf->altsetting[0].desc.bInterfaceNumber;
 	/* init cfg & intf_ops */
 	rtlpriv->rtlhal.interface = INTF_USB;
 	rtlpriv->cfg = rtl_hal_cfg;
drivers/net/wireless/realtek/rtlwifi/wifi.h +5 -0
index 9fabf597cfd6..c45463744f16 100644
@@ -20,6 +20,7 @@
 #define	MASKBYTE1				0xff00
 #define	MASKBYTE2				0xff0000
 #define	MASKBYTE3				0xff000000
+#define	MASKH3BYTES				0xffffff00
 #define	MASKHWORD				0xffff0000
 #define	MASKLWORD				0x0000ffff
 #define	MASKDWORD				0xffffffff
@@ -48,6 +49,10 @@
 #define	MASK20BITS				0xfffff
 #define RFREG_OFFSET_MASK			0xfffff
 
+/* For dual MAC RTL8192DU */
+#define	MAC0_ACCESS_PHY1			0x4000
+#define	MAC1_ACCESS_PHY0			0x2000
+
 #define RF_CHANGE_BY_INIT			0
 #define RF_CHANGE_BY_IPS			BIT(28)
 #define RF_CHANGE_BY_PS				BIT(29)
Signature · 1 line
2.43.2
maintainer
#2 lore raw

Re: [PATCH 2/3] wifi: rtlwifi: Adjust rtl8192d-common for USB

Quoted 5 lines · Bitterblue Smith

A few of the shared functions need small changes for the USB driver.

Also, add a few macros to wifi.h and initialise rtlhal.interfaceindex for USB devices.

Please run checkpatch.pl that reports
"total: 0 errors, 11 warnings, 27 checks, 8045 lines checked"
I think these are newly introduced by this patch.

Quoted 19 lines
---
 .../wireless/realtek/rtlwifi/rtl8192d/def.h   |   2 +
 .../realtek/rtlwifi/rtl8192d/fw_common.c      |  19 +++
 .../realtek/rtlwifi/rtl8192d/hw_common.c      |  46 ++++--
 .../realtek/rtlwifi/rtl8192d/phy_common.c     |  26 ++-
 .../realtek/rtlwifi/rtl8192d/phy_common.h     |   6 +
 .../wireless/realtek/rtlwifi/rtl8192d/reg.h   | 156 +++++++++++++++---
 drivers/net/wireless/realtek/rtlwifi/usb.c    |   3 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h   |   5 +
 8 files changed, 222 insertions(+), 41 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +0 -0
index 21726d9b4aef..ee45f51fcf71 100644

drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h enum version_8192d { · line 120

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +2 -0
@@ -116,6 +116,8 @@ enum version_8192d {
 #define IS_92D_E_CUT(version)          ((IS_92D(version)) ?            \
                                 ((GET_CVID_CUT_VERSION(version) ==     \
                                 CHIP_92D_E_CUT) ? true : false) : false)
+#define IS_NORMAL_CHIP(version)        \
+       ((version & NORMAL_CHIP) ? true : false)

#define IS_NORMAL_CHIP(version) !!(version & NORMAL_CHIP)

Quoted 9 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +0 -0
 enum rf_optype {
        RF_OP_BY_SW_3WIRE = 0,
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +0 -0
index e333275c51c3..ac48bd9dcc9f 100644

drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c EXPORT_SYMBOL_GPL(rtl92d_fw_free_to_go); · line 102

Quoted 9 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +3 -0
@@ -94,9 +94,22 @@ EXPORT_SYMBOL_GPL(rtl92d_fw_free_to_go);
 void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
+       struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
        u8 u1b_tmp;
        u8 delay = 100;
 
+       if (rtlhal->interface == INTF_USB) {
+               delay *= 60;

Out of curiosity, how did you decide this factor 60?

Let's define a name such as RTL_USB_DELAY_FACTOR to be clear.

Quoted 14 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +10 -0
+
+               rtl_write_byte(rtlpriv, REG_FSIMR, 0);
+
+               /* We need to disable other HRCV INT to influence 8051 reset. */
+               rtl_write_byte(rtlpriv, REG_FWIMR, 0x20);
+
+               /* Close mask to prevent incorrect FW write operation. */
+               rtl_write_byte(rtlpriv, REG_FTIMR, 0);
+       }
+
        /* Set (REG_HMETFR + 3) to  0x20 is reset 8051 */
        rtl_write_byte(rtlpriv, REG_HMETFR + 3, 0x20);
        u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);

drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c void rtl92d_firmware_selfreset(struct ieee80211_hw *hw) · line 125

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +3 -0
@@ -107,6 +120,12 @@ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
                udelay(50);
                u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
        }
+
+       if (rtlhal->interface == INTF_USB) {
+               if ((u1b_tmp & BIT(2)) && delay == 0)

#define BIT_FEN_CPUEN BIT(10)

Because BIT(2) of REG_SYS_FUNC_EN + 1 is BIT(10)

Quoted 42 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +3 -0
+                       rtl_write_byte(rtlpriv, REG_FWIMR, 0);
+       }
+
        WARN_ONCE((delay <= 0), "rtl8192de: 8051 reset failed!\n");
        rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
                "=====> 8051 reset success (%d)\n", delay);
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +8 -4
index ada08f82adff..b9bc2fdde5e2 100644
@@ -622,9 +622,14 @@ static void _rtl92de_read_macphymode_from_prom(struct ieee80211_hw *hw,
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       u8 macphy_crvalue = content[EEPROM_MAC_FUNCTION];
+       bool is_single_mac = true;
 
-       if (macphy_crvalue & BIT(3)) {
+       if (rtlhal->interface == INTF_PCI)
+               is_single_mac = !!(content[EEPROM_MAC_FUNCTION] & BIT(3));
+       else if (rtlhal->interface == INTF_USB)
+               is_single_mac = !(content[EEPROM_ENDPOINT_SETTING] & BIT(0));
+
+       if (is_single_mac) {
                rtlhal->macphymode = SINGLEMAC_SINGLEPHY;
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode SINGLEMAC_SINGLEPHY\n");
@@ -663,6 +668,7 @@ static void _rtl92de_efuse_update_chip_version(struct ieee80211_hw *hw)
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, "D-CUT!!!\n");
                break;
        case 0xCC33:
+       case 0x33CC:
                chipver |= CHIP_92D_E_CUT;
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, "E-CUT!!!\n");
                break;
@@ -679,14 +685,22 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
-                       EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR_MAC0_92D,

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) · line 695

Quoted 10 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +8 -2
-                       EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
-                       COUNTRY_CODE_WORLD_WIDE_13};
+       int params_pci[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+                           EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR_MAC0_92D,
+                           EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+                           COUNTRY_CODE_WORLD_WIDE_13};
+       int params_usb[] = {RTL8190_EEPROM_ID, EEPROM_VID_USB, EEPROM_PID_USB,
+                           EEPROM_VID_USB, EEPROM_PID_USB, EEPROM_MAC_ADDR_MAC0_92DU,
+                           EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+                           COUNTRY_CODE_WORLD_WIDE_13};

static const int params_xxx[], and the const should propagate into rtl_get_hwinfo().

Quoted 21 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +5 -1
+       int *params = params_pci;
        int i;
        u16 usvalue;
        u8 *hwinfo;
 
+       if (rtlhal->interface == INTF_USB)
+               params = params_usb;
+
        hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
        if (!hwinfo)
                return;
@@ -858,7 +872,7 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
                                                        1 : 0;
        enum wireless_mode wirelessmode = 0;
        bool shortgi = false;
-       u32 value[2];
+       u8 rate_mask[5];
        u8 macid = 0;
        u8 mimo_ps = IEEE80211_SMPS_OFF;
 

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, · line 984

Quoted 7 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +2 -2
@@ -966,12 +980,17 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
                break;
        }
 
-       value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28);
-       value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
+       *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
+                                    (ratr_index << 28);

'u32' is weird to me. Shouldn't it be __le32?
But I prefer a struct of rate_mask.

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, · line 989

Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +4 -3
+       rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
        rtl_dbg(rtlpriv, COMP_RATR, DBG_DMESG,
-               "ratr_bitmap :%x value0:%x value1:%x\n",
-               ratr_bitmap, value[0], value[1]);
-       rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *) value);
+       "Rate_index:%x, ratr_val:%x, %5phC\n",
+               ratr_index, ratr_bitmap, rate_mask);
+       memcpy(rtlpriv->rate_mask, rate_mask, 5);

5 ==> sizeof(rtlpriv->rate_mask)

Quoted 23 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +6 -1
+       /* rtl92d_fill_h2c_cmd() does USB I/O and will result in a
+        * "scheduled while atomic" if called directly
+        */
+       schedule_work(&rtlpriv->works.fill_h2c_cmd);
        if (macid != 0)
                sta_entry->ratr_index = ratr_index;
 }
@@ -1015,7 +1034,8 @@ bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
        bool actuallyset = false;
        unsigned long flag;
 
-       if (rtlpci->being_init_adapter)
+       if (rtlpriv->rtlhal.interface == INTF_PCI &&
+           rtlpci->being_init_adapter)
                return false;
        if (ppsc->swrf_processing)
                return false;
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +0 -0
index 487628ac491b..1e39940a3ba7 100644

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, · line 85

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +2 -1
@@ -81,11 +81,13 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
                "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
                regaddr, rfpath, bitmask);
-       spin_lock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_lock(&rtlpriv->locks.rf_lock);

Does it mean USB never read/write RF registers simultaneously? How can you ensure that?

Quoted 39 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +8 -3
        original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr);
        bitshift = calculate_bit_shift(bitmask);
        readback_value = (original_value & bitmask) >> bitshift;
-       spin_unlock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_unlock(&rtlpriv->locks.rf_lock);
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
                "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
                regaddr, rfpath, bitmask, original_value);
@@ -105,7 +107,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
                regaddr, bitmask, data, rfpath);
        if (bitmask == 0)
                return;
-       spin_lock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_lock(&rtlpriv->locks.rf_lock);
        if (rtlphy->rf_mode != RF_OP_BY_FW) {
                if (bitmask != RFREG_OFFSET_MASK) {
                        original_value = _rtl92d_phy_rf_serial_read(hw,
@@ -116,7 +119,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
                }
                _rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data);
        }
-       spin_unlock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_unlock(&rtlpriv->locks.rf_lock);
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
                "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
                regaddr, bitmask, data, rfpath);
@@ -642,6 +646,8 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
        case IO_CMD_PAUSE_DM_BY_SCAN:
                rtlphy->initgain_backup.xaagccore1 = de_digtable->cur_igvalue;
                de_digtable->cur_igvalue = 0x37;
+               if (rtlpriv->rtlhal.interface == INTF_USB)
+                       de_digtable->cur_igvalue = 0x17;
                rtl92d_dm_write_dig(hw);
                break;
        default:

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw) · line 707

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +1 -0
@@ -698,22 +704,28 @@ void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw)
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
        u8 offset = REG_MAC_PHY_CTRL_NORMAL;
+       u8 temp = 0xf0;

'tmp' instead. Or 'phy_ctrl', or 'ctrl' would be clear.

Quoted 43 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +8 -3
+
+       if (rtlhal->interface == INTF_USB) {
+               temp = rtl_read_byte(rtlpriv, offset);
+               temp &= ~(BIT(0) | BIT(1) | BIT(2));
+       }
 
        switch (rtlhal->macphymode) {
        case DUALMAC_DUALPHY:
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode: DUALMAC_DUALPHY\n");
-               rtl_write_byte(rtlpriv, offset, 0xF3);
+               rtl_write_byte(rtlpriv, offset, temp | BIT(0) | BIT(1));
                break;
        case SINGLEMAC_SINGLEPHY:
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode: SINGLEMAC_SINGLEPHY\n");
-               rtl_write_byte(rtlpriv, offset, 0xF4);
+               rtl_write_byte(rtlpriv, offset, temp | BIT(2));
                break;
        case DUALMAC_SINGLEPHY:
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode: DUALMAC_SINGLEPHY\n");
-               rtl_write_byte(rtlpriv, offset, 0xF1);
+               rtl_write_byte(rtlpriv, offset, temp | BIT(0));
                break;
        }
 }
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +3 -0
index 071776d05eb9..5649a11f4405 100644
@@ -41,6 +41,9 @@ static inline void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
 
+       if (rtlpriv->rtlhal.interface == INTF_USB)
+               return;
+
        if (rtlpriv->rtlhal.interfaceindex == 1)
                spin_lock_irqsave(&rtlpriv->locks.cck_and_rw_pagea_lock, *flag);
 }

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h static inline void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw, · line 58

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +3 -0
@@ -50,6 +53,9 @@ static inline void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
 
+       if (rtlpriv->rtlhal.interface == INTF_USB)
+               return;
+

Why USB doesn't need the lock? I guess USB could be "scheduled while atomic", but this lock is to ensure read/write as expected.

If you have explanation, please add them to commit message.

Quoted 9 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +0 -0
        if (rtlpriv->rtlhal.interfaceindex == 1)
                spin_unlock_irqrestore(&rtlpriv->locks.cck_and_rw_pagea_lock,
                        *flag);
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +0 -0
index 2783d7e7b227..1f2daf779539 100644

[...]

drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h

Quoted 2 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +2 -0
+
+#define _TXDMA_HIQ_MAP(x)                      (((x) & 0x3) << 14)

GENMASK(15, 14) ?

drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h line 959

Quoted 11 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +11 -0
+#define _TXDMA_MGQ_MAP(x)                      (((x) & 0x3) << 12)
+#define _TXDMA_BKQ_MAP(x)                      (((x) & 0x3) << 10)
+#define _TXDMA_BEQ_MAP(x)                      (((x) & 0x3) <<  8)
+#define _TXDMA_VIQ_MAP(x)                      (((x) & 0x3) <<  6)
+#define _TXDMA_VOQ_MAP(x)                      (((x) & 0x3) <<  4)
+
+#define QUEUE_LOW                              1
+#define QUEUE_NORMAL                           2
+#define QUEUE_HIGH                             3
+
+#define _HPQ(x)                                        ((x) & 0xFF)

#define HPQ_MASK GENMASK(7, 0)
u32_get_bits(x, HPQ_MASK) ?

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +5 -0
+#define _LPQ(x)                                        (((x) & 0xFF) << 8)
+#define _PUBQ(x)                               (((x) & 0xFF) << 16)
+#define _NPQ(x)                                        ((x) & 0xFF)
+#define LD_RQPN                                        BIT(31)
+

[...]

drivers/net/wireless/realtek/rtlwifi/usb.c int rtl_usb_probe(struct usb_interface *intf, · line 984

Quoted 12 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +3 -0
index 6e8c87a2fae4..2ea72d9e3957 100644
@@ -979,6 +979,9 @@ int rtl_usb_probe(struct usb_interface *intf,
        usb_priv->dev.intf = intf;
        usb_priv->dev.udev = udev;
        usb_set_intfdata(intf, hw);
+       /* For dual MAC RTL8192DU, which has two interfaces. */
+       rtlpriv->rtlhal.interfaceindex =
+               intf->altsetting[0].desc.bInterfaceNumber;

So, you will see two USB adapters when you plug 8192DU?

Quoted 29 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +0 -0
        /* init cfg & intf_ops */
        rtlpriv->rtlhal.interface = INTF_USB;
        rtlpriv->cfg = rtl_hal_cfg;
drivers/net/wireless/realtek/rtlwifi/wifi.h +5 -1
index 9fabf597cfd6..c45463744f16 100644
@@ -20,6 +20,7 @@
 #define        MASKBYTE1                               0xff00
 #define        MASKBYTE2                               0xff0000
 #define        MASKBYTE3                               0xff000000
+#define        MASKH3BYTES                             0xffffff00
 #define        MASKHWORD                               0xffff0000
 #define        MASKLWORD                               0x0000ffff
 #define        MASKDWORD                               0xffffffff
@@ -48,6 +49,10 @@
 #define        MASK20BITS                              0xfffff
 #define RFREG_OFFSET_MASK                      0xfffff
 
+/* For dual MAC RTL8192DU */
+#define        MAC0_ACCESS_PHY1                        0x4000
+#define        MAC1_ACCESS_PHY0                        0x2000
+
 #define RF_CHANGE_BY_INIT                      0
 #define RF_CHANGE_BY_IPS                       BIT(28)
 #define RF_CHANGE_BY_PS                                BIT(29)
--

2.43.2

#3 lore raw

Re: [PATCH 2/3] wifi: rtlwifi: Adjust rtl8192d-common for USB

Quoted 56 lines · Ping-Ke Shih
Quoted 5 lines · Bitterblue Smith

A few of the shared functions need small changes for the USB driver.

Also, add a few macros to wifi.h and initialise rtlhal.interfaceindex for USB devices.

Please run checkpatch.pl that reports
"total: 0 errors, 11 warnings, 27 checks, 8045 lines checked"
I think these are newly introduced by this patch.

Quoted 19 lines
---
 .../wireless/realtek/rtlwifi/rtl8192d/def.h   |   2 +
 .../realtek/rtlwifi/rtl8192d/fw_common.c      |  19 +++
 .../realtek/rtlwifi/rtl8192d/hw_common.c      |  46 ++++--
 .../realtek/rtlwifi/rtl8192d/phy_common.c     |  26 ++-
 .../realtek/rtlwifi/rtl8192d/phy_common.h     |   6 +
 .../wireless/realtek/rtlwifi/rtl8192d/reg.h   | 156 +++++++++++++++---
 drivers/net/wireless/realtek/rtlwifi/usb.c    |   3 +
 drivers/net/wireless/realtek/rtlwifi/wifi.h   |   5 +
 8 files changed, 222 insertions(+), 41 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +0 -0
index 21726d9b4aef..ee45f51fcf71 100644

drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h enum version_8192d { · line 120

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +2 -0
@@ -116,6 +116,8 @@ enum version_8192d {
 #define IS_92D_E_CUT(version)          ((IS_92D(version)) ?            \
                                 ((GET_CVID_CUT_VERSION(version) ==     \
                                 CHIP_92D_E_CUT) ? true : false) : false)
+#define IS_NORMAL_CHIP(version)        \
+       ((version & NORMAL_CHIP) ? true : false)

#define IS_NORMAL_CHIP(version) !!(version & NORMAL_CHIP)

Quoted 16 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/def.h +0 -0
 enum rf_optype {
        RF_OP_BY_SW_3WIRE = 0,
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +1 -0
index e333275c51c3..ac48bd9dcc9f 100644
@@ -94,9 +94,22 @@ EXPORT_SYMBOL_GPL(rtl92d_fw_free_to_go);
 void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
+       struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
        u8 u1b_tmp;
        u8 delay = 100;
 
Quoted 5 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c EXPORT_SYMBOL_GPL(rtl92d_fw_free_to_go); · line 102

Quoted 2 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +2 -0
+       if (rtlhal->interface == INTF_USB) {
+               delay *= 60;

Out of curiosity, how did you decide this factor 60?

Just because the out-of-tree driver uses a delay of 300 ms:
https://github.com/lwfinger/rtl8192du/blob/2c5450dd3783e1085f09a8c7a632318c7d0f1d39/hal/rtl8192d_hal_init.c#L329-L346

rtl8192de uses 100 * 0.05 ms. Multiplying by 60 gives 300 ms.

Quoted 107 lines

Let's define a name such as RTL_USB_DELAY_FACTOR to be clear.

Quoted 14 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +10 -0
+
+               rtl_write_byte(rtlpriv, REG_FSIMR, 0);
+
+               /* We need to disable other HRCV INT to influence 8051 reset. */
+               rtl_write_byte(rtlpriv, REG_FWIMR, 0x20);
+
+               /* Close mask to prevent incorrect FW write operation. */
+               rtl_write_byte(rtlpriv, REG_FTIMR, 0);
+       }
+
        /* Set (REG_HMETFR + 3) to  0x20 is reset 8051 */
        rtl_write_byte(rtlpriv, REG_HMETFR + 3, 0x20);
        u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);

drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c void rtl92d_firmware_selfreset(struct ieee80211_hw *hw) · line 125

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +3 -0
@@ -107,6 +120,12 @@ void rtl92d_firmware_selfreset(struct ieee80211_hw *hw)
                udelay(50);
                u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
        }
+
+       if (rtlhal->interface == INTF_USB) {
+               if ((u1b_tmp & BIT(2)) && delay == 0)

#define BIT_FEN_CPUEN BIT(10)

Because BIT(2) of REG_SYS_FUNC_EN + 1 is BIT(10)

Quoted 42 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/fw_common.c +3 -0
+                       rtl_write_byte(rtlpriv, REG_FWIMR, 0);
+       }
+
        WARN_ONCE((delay <= 0), "rtl8192de: 8051 reset failed!\n");
        rtl_dbg(rtlpriv, COMP_FW, DBG_DMESG,
                "=====> 8051 reset success (%d)\n", delay);
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +8 -4
index ada08f82adff..b9bc2fdde5e2 100644
@@ -622,9 +622,14 @@ static void _rtl92de_read_macphymode_from_prom(struct ieee80211_hw *hw,
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       u8 macphy_crvalue = content[EEPROM_MAC_FUNCTION];
+       bool is_single_mac = true;
 
-       if (macphy_crvalue & BIT(3)) {
+       if (rtlhal->interface == INTF_PCI)
+               is_single_mac = !!(content[EEPROM_MAC_FUNCTION] & BIT(3));
+       else if (rtlhal->interface == INTF_USB)
+               is_single_mac = !(content[EEPROM_ENDPOINT_SETTING] & BIT(0));
+
+       if (is_single_mac) {
                rtlhal->macphymode = SINGLEMAC_SINGLEPHY;
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode SINGLEMAC_SINGLEPHY\n");
@@ -663,6 +668,7 @@ static void _rtl92de_efuse_update_chip_version(struct ieee80211_hw *hw)
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, "D-CUT!!!\n");
                break;
        case 0xCC33:
+       case 0x33CC:
                chipver |= CHIP_92D_E_CUT;
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, "E-CUT!!!\n");
                break;
@@ -679,14 +685,22 @@ static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw)
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
-       int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
-                       EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR_MAC0_92D,

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) · line 695

Quoted 10 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +8 -2
-                       EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
-                       COUNTRY_CODE_WORLD_WIDE_13};
+       int params_pci[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
+                           EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR_MAC0_92D,
+                           EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+                           COUNTRY_CODE_WORLD_WIDE_13};
+       int params_usb[] = {RTL8190_EEPROM_ID, EEPROM_VID_USB, EEPROM_PID_USB,
+                           EEPROM_VID_USB, EEPROM_PID_USB, EEPROM_MAC_ADDR_MAC0_92DU,
+                           EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
+                           COUNTRY_CODE_WORLD_WIDE_13};

static const int params_xxx[], and the const should propagate into rtl_get_hwinfo().

Quoted 24 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +5 -1
+       int *params = params_pci;
        int i;
        u16 usvalue;
        u8 *hwinfo;
 
+       if (rtlhal->interface == INTF_USB)
+               params = params_usb;
+
        hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
        if (!hwinfo)
                return;
@@ -858,7 +872,7 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
                                                        1 : 0;
        enum wireless_mode wirelessmode = 0;
        bool shortgi = false;
-       u32 value[2];
+       u8 rate_mask[5];
        u8 macid = 0;
        u8 mimo_ps = IEEE80211_SMPS_OFF;
 
@@ -966,12 +980,17 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
                break;
        }
 
Quoted 8 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, · line 984

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +2 -2
-       value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28);
-       value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
+       *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
+                                    (ratr_index << 28);

'u32' is weird to me. Shouldn't it be __le32?
But I prefer a struct of rate_mask.

I don't like this either, but it was easy to copy from rtl8192cu.

Something like this?

#define RAID_MASK GENMASK(31, 28)
#define RATE_MASK_MASK GENMASK(27, 0)
#define SHORT_GI_MASK BIT(5)
#define MACID_MASK GENMASK(4, 0)

struct rtl92d_rate_mask {
	__le32 rate_mask_and_raid;
	u8 macid_and_short_gi;
} __packed;
Quoted 35 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, · line 989

Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +4 -3
+       rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
        rtl_dbg(rtlpriv, COMP_RATR, DBG_DMESG,
-               "ratr_bitmap :%x value0:%x value1:%x\n",
-               ratr_bitmap, value[0], value[1]);
-       rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *) value);
+       "Rate_index:%x, ratr_val:%x, %5phC\n",
+               ratr_index, ratr_bitmap, rate_mask);
+       memcpy(rtlpriv->rate_mask, rate_mask, 5);

5 ==> sizeof(rtlpriv->rate_mask)

Quoted 24 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +6 -1
+       /* rtl92d_fill_h2c_cmd() does USB I/O and will result in a
+        * "scheduled while atomic" if called directly
+        */
+       schedule_work(&rtlpriv->works.fill_h2c_cmd);
        if (macid != 0)
                sta_entry->ratr_index = ratr_index;
 }
@@ -1015,7 +1034,8 @@ bool rtl92de_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
        bool actuallyset = false;
        unsigned long flag;
 
-       if (rtlpci->being_init_adapter)
+       if (rtlpriv->rtlhal.interface == INTF_PCI &&
+           rtlpci->being_init_adapter)
                return false;
        if (ppsc->swrf_processing)
                return false;
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +0 -0
index 487628ac491b..1e39940a3ba7 100644
@@ -81,11 +81,13 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
Quoted 9 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, · line 85

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +2 -1
                "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
                regaddr, rfpath, bitmask);
-       spin_lock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_lock(&rtlpriv->locks.rf_lock);

Does it mean USB never read/write RF registers simultaneously? How can you ensure that?

I don't know. It seems to work fine. The out-of-tree driver doesn't have locks here:
https://github.com/lwfinger/rtl8192du/blob/2c5450dd3783e1085f09a8c7a632318c7d0f1d39/hal/rtl8192d_phycfg.c#L637

rtl8xxxu and rtl8192cu don't have locks either.

Quoted 92 lines
Quoted 39 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +8 -3
        original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr);
        bitshift = calculate_bit_shift(bitmask);
        readback_value = (original_value & bitmask) >> bitshift;
-       spin_unlock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_unlock(&rtlpriv->locks.rf_lock);
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
                "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
                regaddr, rfpath, bitmask, original_value);
@@ -105,7 +107,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
                regaddr, bitmask, data, rfpath);
        if (bitmask == 0)
                return;
-       spin_lock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_lock(&rtlpriv->locks.rf_lock);
        if (rtlphy->rf_mode != RF_OP_BY_FW) {
                if (bitmask != RFREG_OFFSET_MASK) {
                        original_value = _rtl92d_phy_rf_serial_read(hw,
@@ -116,7 +119,8 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
                }
                _rtl92d_phy_rf_serial_write(hw, rfpath, regaddr, data);
        }
-       spin_unlock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_unlock(&rtlpriv->locks.rf_lock);
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
                "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
                regaddr, bitmask, data, rfpath);
@@ -642,6 +646,8 @@ static void rtl92d_phy_set_io(struct ieee80211_hw *hw)
        case IO_CMD_PAUSE_DM_BY_SCAN:
                rtlphy->initgain_backup.xaagccore1 = de_digtable->cur_igvalue;
                de_digtable->cur_igvalue = 0x37;
+               if (rtlpriv->rtlhal.interface == INTF_USB)
+                       de_digtable->cur_igvalue = 0x17;
                rtl92d_dm_write_dig(hw);
                break;
        default:

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw) · line 707

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +1 -0
@@ -698,22 +704,28 @@ void rtl92d_phy_config_macphymode(struct ieee80211_hw *hw)
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
        u8 offset = REG_MAC_PHY_CTRL_NORMAL;
+       u8 temp = 0xf0;

'tmp' instead. Or 'phy_ctrl', or 'ctrl' would be clear.

Quoted 46 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +8 -3
+
+       if (rtlhal->interface == INTF_USB) {
+               temp = rtl_read_byte(rtlpriv, offset);
+               temp &= ~(BIT(0) | BIT(1) | BIT(2));
+       }
 
        switch (rtlhal->macphymode) {
        case DUALMAC_DUALPHY:
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode: DUALMAC_DUALPHY\n");
-               rtl_write_byte(rtlpriv, offset, 0xF3);
+               rtl_write_byte(rtlpriv, offset, temp | BIT(0) | BIT(1));
                break;
        case SINGLEMAC_SINGLEPHY:
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode: SINGLEMAC_SINGLEPHY\n");
-               rtl_write_byte(rtlpriv, offset, 0xF4);
+               rtl_write_byte(rtlpriv, offset, temp | BIT(2));
                break;
        case DUALMAC_SINGLEPHY:
                rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD,
                        "MacPhyMode: DUALMAC_SINGLEPHY\n");
-               rtl_write_byte(rtlpriv, offset, 0xF1);
+               rtl_write_byte(rtlpriv, offset, temp | BIT(0));
                break;
        }
 }
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +3 -0
index 071776d05eb9..5649a11f4405 100644
@@ -41,6 +41,9 @@ static inline void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
 
+       if (rtlpriv->rtlhal.interface == INTF_USB)
+               return;
+
        if (rtlpriv->rtlhal.interfaceindex == 1)
                spin_lock_irqsave(&rtlpriv->locks.cck_and_rw_pagea_lock, *flag);
 }
@@ -50,6 +53,9 @@ static inline void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw,
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
 
Quoted 7 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h static inline void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw, · line 46

Quoted 3 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +3 -0
+       if (rtlpriv->rtlhal.interface == INTF_USB)
+               return;
+

Why USB doesn't need the lock? I guess USB could be "scheduled while atomic", but this lock is to ensure read/write as expected.

I don't know. The calls to AcquireCCKAndRWPageAControl and ReleaseCCKAndRWPageAControl are commented out and their implementations are missing from the out-of-tree driver:
https://github.com/lwfinger/rtl8192du/blob/2c5450dd3783e1085f09a8c7a632318c7d0f1d39/hal/rtl8192d_phycfg.c#L2622-L2624

Quoted 47 lines

If you have explanation, please add them to commit message.

Quoted 9 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.h +0 -0
        if (rtlpriv->rtlhal.interfaceindex == 1)
                spin_unlock_irqrestore(&rtlpriv->locks.cck_and_rw_pagea_lock,
                        *flag);
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +0 -0
index 2783d7e7b227..1f2daf779539 100644

[...]

drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h

Quoted 2 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +2 -0
+
+#define _TXDMA_HIQ_MAP(x)                      (((x) & 0x3) << 14)

GENMASK(15, 14) ?

drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h line 959

Quoted 11 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +11 -0
+#define _TXDMA_MGQ_MAP(x)                      (((x) & 0x3) << 12)
+#define _TXDMA_BKQ_MAP(x)                      (((x) & 0x3) << 10)
+#define _TXDMA_BEQ_MAP(x)                      (((x) & 0x3) <<  8)
+#define _TXDMA_VIQ_MAP(x)                      (((x) & 0x3) <<  6)
+#define _TXDMA_VOQ_MAP(x)                      (((x) & 0x3) <<  4)
+
+#define QUEUE_LOW                              1
+#define QUEUE_NORMAL                           2
+#define QUEUE_HIGH                             3
+
+#define _HPQ(x)                                        ((x) & 0xFF)

#define HPQ_MASK GENMASK(7, 0)
u32_get_bits(x, HPQ_MASK) ?

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/reg.h +5 -0
+#define _LPQ(x)                                        (((x) & 0xFF) << 8)
+#define _PUBQ(x)                               (((x) & 0xFF) << 16)
+#define _NPQ(x)                                        ((x) & 0xFF)
+#define LD_RQPN                                        BIT(31)
+

[...]

Quoted 15 lines

drivers/net/wireless/realtek/rtlwifi/usb.c int rtl_usb_probe(struct usb_interface *intf, · line 984

Quoted 12 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +3 -0
index 6e8c87a2fae4..2ea72d9e3957 100644
@@ -979,6 +979,9 @@ int rtl_usb_probe(struct usb_interface *intf,
        usb_priv->dev.intf = intf;
        usb_priv->dev.udev = udev;
        usb_set_intfdata(intf, hw);
+       /* For dual MAC RTL8192DU, which has two interfaces. */
+       rtlpriv->rtlhal.interfaceindex =
+               intf->altsetting[0].desc.bInterfaceNumber;

So, you will see two USB adapters when you plug 8192DU?

When you plug the dual MAC version, lsusb will show one device, with two interfaces. rtl_usb_probe() is called twice. This is copied from linux-hardware.org:

Bus 003 Device 004: ID 0bda:8193 Realtek Semiconductor Corp. RTL8192DU 802.11an WLAN Adapter Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00

  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x8193 RTL8192DU 802.11an WLAN Adapter
  bcdDevice            0.00
  iManufacturer           1 Realtek
  iProduct                2 801.11n NIC
  iSerial                 3 ...
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x0037
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x89 EP 9 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x0a EP 10 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00

  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 

bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0000
(Bus Powered)

Mine is the single MAC version:

Bus 001 Device 007: ID 0bda:8194 Realtek Semiconductor Corp. 802.11n NIC Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00

  bDeviceClass            0 [unknown]
  bDeviceSubClass         0 [unknown]
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0bda Realtek Semiconductor Corp.
  idProduct          0x8194 802.11n NIC
  bcdDevice            0.00
  iManufacturer           1 Realtek
  iProduct                2 802.11n NIC
  iSerial                 3 00e04c000001
  bNumConfigurations      1

Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x002e
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 3

Quoted 30 lines
Quoted 30 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +0 -0
        /* init cfg & intf_ops */
        rtlpriv->rtlhal.interface = INTF_USB;
        rtlpriv->cfg = rtl_hal_cfg;
drivers/net/wireless/realtek/rtlwifi/wifi.h +5 -1
index 9fabf597cfd6..c45463744f16 100644
@@ -20,6 +20,7 @@
 #define        MASKBYTE1                               0xff00
 #define        MASKBYTE2                               0xff0000
 #define        MASKBYTE3                               0xff000000
+#define        MASKH3BYTES                             0xffffff00
 #define        MASKHWORD                               0xffff0000
 #define        MASKLWORD                               0x0000ffff
 #define        MASKDWORD                               0xffffffff
@@ -48,6 +49,10 @@
 #define        MASK20BITS                              0xfffff
 #define RFREG_OFFSET_MASK                      0xfffff
 
+/* For dual MAC RTL8192DU */
+#define        MAC0_ACCESS_PHY1                        0x4000
+#define        MAC1_ACCESS_PHY0                        0x2000
+
 #define RF_CHANGE_BY_INIT                      0
 #define RF_CHANGE_BY_IPS                       BIT(28)
 #define RF_CHANGE_BY_PS                                BIT(29)
--

2.43.2

maintainer
#4 lore raw

Re: [PATCH 2/3] wifi: rtlwifi: Adjust rtl8192d-common for USB

Quoted 26 lines · Bitterblue Smith
Quoted 6 lines · Ping-Ke Shih
Quoted 5 lines · Bitterblue Smith
(quoted diff) +0 -0
@@ -966,12 +980,17 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
                break;
        }
 
Quoted 8 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, · line 984

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +2 -2
-       value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28);
-       value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
+       *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
+                                    (ratr_index << 28);

'u32' is weird to me. Shouldn't it be __le32?
But I prefer a struct of rate_mask.

I don't like this either, but it was easy to copy from rtl8192cu.

Something like this?

#define RAID_MASK               GENMASK(31, 28)
#define RATE_MASK_MASK          GENMASK(27, 0)
#define SHORT_GI_MASK           BIT(5)
#define MACID_MASK              GENMASK(4, 0)
Quoted 4 lines
struct rtl92d_rate_mask {
        __le32 rate_mask_and_raid;
        u8 macid_and_short_gi;
} __packed;

Yes, something like that, but struct size should be 5.

Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +0 -0
index 487628ac491b..1e39940a3ba7 100644
@@ -81,11 +81,13 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path
 rfpath,
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
Quoted 9 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, · line 85

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +2 -1
                "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
                regaddr, rfpath, bitmask);
-       spin_lock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_lock(&rtlpriv->locks.rf_lock);

Does it mean USB never read/write RF registers simultaneously? How can you ensure that?

Quoted 5 lines

I don't know. It seems to work fine. The out-of-tree driver doesn't have locks here:
https://github.com/lwfinger/rtl8192du/blob/2c5450dd3783e1085f09a8c7a632318c7d0f1d39/hal/rtl8192d_phycfg.c#L637

rtl8xxxu and rtl8192cu don't have locks either.

Not sure if race condition is existing to read/write RF registers, but no idea to dig the problem. Maybe, current code has no problem though. At least, your newly changes don't affect original PCI behavior, right?

Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +0 -0
index 6e8c87a2fae4..2ea72d9e3957 100644
@@ -979,6 +979,9 @@ int rtl_usb_probe(struct usb_interface *intf,
Quoted 9 lines

drivers/net/wireless/realtek/rtlwifi/usb.c int rtl_usb_probe(struct usb_interface *intf, · line 984

Quoted 6 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +3 -0
        usb_priv->dev.intf = intf;
        usb_priv->dev.udev = udev;
        usb_set_intfdata(intf, hw);
+       /* For dual MAC RTL8192DU, which has two interfaces. */
+       rtlpriv->rtlhal.interfaceindex =
+               intf->altsetting[0].desc.bInterfaceNumber;

So, you will see two USB adapters when you plug 8192DU?

Quoted 6 lines

When you plug the dual MAC version, lsusb will show one device, with two interfaces. rtl_usb_probe() is called twice. This is copied from linux-hardware.org:

Mine is the single MAC version:

Does it mean you only tested single MAC version? But, your code will support two MAC version, right?

#5 lore raw

Re: [PATCH 2/3] wifi: rtlwifi: Adjust rtl8192d-common for USB

Quoted 56 lines · Ping-Ke Shih
Quoted 26 lines · Bitterblue Smith
Quoted 6 lines · Ping-Ke Shih
Quoted 5 lines · Bitterblue Smith
(quoted diff) +0 -0
@@ -966,12 +980,17 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw,
                break;
        }
 
Quoted 8 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, · line 984

Quoted 4 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/hw_common.c +2 -2
-       value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28);
-       value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
+       *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
+                                    (ratr_index << 28);

'u32' is weird to me. Shouldn't it be __le32?
But I prefer a struct of rate_mask.

I don't like this either, but it was easy to copy from rtl8192cu.

Something like this?

#define RAID_MASK               GENMASK(31, 28)
#define RATE_MASK_MASK          GENMASK(27, 0)
#define SHORT_GI_MASK           BIT(5)
#define MACID_MASK              GENMASK(4, 0)
Quoted 4 lines
struct rtl92d_rate_mask {
        __le32 rate_mask_and_raid;
        u8 macid_and_short_gi;
} __packed;

Yes, something like that, but struct size should be 5.

Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +0 -0
index 487628ac491b..1e39940a3ba7 100644
@@ -81,11 +81,13 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path
 rfpath,
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
Quoted 9 lines

drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath, · line 85

Quoted 5 lines
drivers/net/wireless/realtek/rtlwifi/rtl8192d/phy_common.c +2 -1
                "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
                regaddr, rfpath, bitmask);
-       spin_lock(&rtlpriv->locks.rf_lock);
+       if (rtlpriv->rtlhal.interface == INTF_PCI)
+               spin_lock(&rtlpriv->locks.rf_lock);

Does it mean USB never read/write RF registers simultaneously? How can you ensure that?

I don't know. It seems to work fine. The out-of-tree driver doesn't have locks here:
https://github.com/lwfinger/rtl8192du/blob/2c5450dd3783e1085f09a8c7a632318c7d0f1d39/hal/rtl8192d_phycfg.c#L637

Quoted 6 lines
Quoted 1 line

rtl8xxxu and rtl8192cu don't have locks either.

Not sure if race condition is existing to read/write RF registers, but no idea to dig the problem. Maybe, current code has no problem though. At least, your newly changes don't affect original PCI behavior, right?

Yes, the PCI driver should behave like before.

Quoted 21 lines
Quoted 21 lines
Quoted 16 lines

drivers/net/wireless/realtek/rtlwifi/usb.c int rtl_usb_probe(struct usb_interface *intf, · line 984

Quoted 13 lines
drivers/net/wireless/realtek/rtlwifi/usb.c +3 -0
index 6e8c87a2fae4..2ea72d9e3957 100644
@@ -979,6 +979,9 @@ int rtl_usb_probe(struct usb_interface *intf,
        usb_priv->dev.intf = intf;
        usb_priv->dev.udev = udev;
        usb_set_intfdata(intf, hw);
+       /* For dual MAC RTL8192DU, which has two interfaces. */
+       rtlpriv->rtlhal.interfaceindex =
+               intf->altsetting[0].desc.bInterfaceNumber;

So, you will see two USB adapters when you plug 8192DU?

When you plug the dual MAC version, lsusb will show one device, with two interfaces. rtl_usb_probe() is called twice. This is copied from linux-hardware.org:

Quoted 7 lines
Quoted 2 lines

Mine is the single MAC version:

Does it mean you only tested single MAC version? But, your code will support two MAC version, right?

Theoretically all the code for dual MAC is there. But I only tested the single MAC version, and Stefan also has the single MAC version.

#6 lore raw

PATCH 3/3 wifi: rtlwifi: Add new rtl8192du driver

In reply to Bitterblue Smith

The RTL8192DU is an older Wifi 4 dual band chip. It comes in two
flavours: single MAC single PHY (like most Realtek Wifi 4 USB devices), and dual MAC dual PHY.

The single MAC single PHY version is 2T2R and can work either in the 2.4 GHz band or the 5 GHz band.

The dual MAC dual PHY version has two USB interfaces and appears to the system as two separate 1T1R Wifi devices, one working in the 2.4 GHz band, the other in the 5 GHz band.

This was tested only with a single MAC single PHY device.

---

Should I split this into multiple patches, one for each new file, to make reviewing easier?

---
 drivers/net/wireless/realtek/rtlwifi/Kconfig  |   12 +
 drivers/net/wireless/realtek/rtlwifi/Makefile |    1 +
 .../realtek/rtlwifi/rtl8192du/Makefile        |   13 +
 .../wireless/realtek/rtlwifi/rtl8192du/dm.c   |  788 +++++
 .../wireless/realtek/rtlwifi/rtl8192du/dm.h   |   10 +
 .../wireless/realtek/rtlwifi/rtl8192du/fw.c   |  109 +
 .../wireless/realtek/rtlwifi/rtl8192du/fw.h   |    9 +
 .../wireless/realtek/rtlwifi/rtl8192du/hw.c   | 1238 +++++++
 .../wireless/realtek/rtlwifi/rtl8192du/hw.h   |   24 +
 .../wireless/realtek/rtlwifi/rtl8192du/led.c  |   10 +
 .../wireless/realtek/rtlwifi/rtl8192du/led.h  |    9 +
 .../wireless/realtek/rtlwifi/rtl8192du/phy.c  | 3064 +++++++++++++++++
 .../wireless/realtek/rtlwifi/rtl8192du/phy.h  |   32 +
 .../wireless/realtek/rtlwifi/rtl8192du/rf.c   |  236 ++
 .../wireless/realtek/rtlwifi/rtl8192du/rf.h   |   11 +
 .../wireless/realtek/rtlwifi/rtl8192du/sw.c   |  310 ++
 .../wireless/realtek/rtlwifi/rtl8192du/sw.h   |   12 +
 .../realtek/rtlwifi/rtl8192du/table.c         | 1675 +++++++++
 .../realtek/rtlwifi/rtl8192du/table.h         |   30 +
 .../wireless/realtek/rtlwifi/rtl8192du/trx.c  |  380 ++
 .../wireless/realtek/rtlwifi/rtl8192du/trx.h  |   60 +
 21 files changed, 8033 insertions(+)
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/Makefile
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/dm.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/dm.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/fw.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/fw.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/led.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/led.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/phy.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/phy.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/rf.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/rf.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/table.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/table.h
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.c
 create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.h
drivers/net/wireless/realtek/rtlwifi/Kconfig +12 -0
index 2319eaa8845a..67efdf10e936 100644
@@ -119,6 +119,18 @@ config RTL8192CU
 
 	If you choose to build it as a module, it will be called rtl8192cu
 
+config RTL8192DU
+	tristate "Realtek RTL8192DU USB Wireless Network Adapter"
+	depends on USB
+	select RTLWIFI
+	select RTLWIFI_USB
+	select RTL8192D_COMMON
+	help
+	This is the driver for Realtek RTL8192DU 802.11an USB
+	wireless network adapters.
+
+	If you choose to build it as a module, it will be called rtl8192du
+
 config RTLWIFI
 	tristate
 	select FW_LOADER
drivers/net/wireless/realtek/rtlwifi/Makefile +1 -0
index 423981b148df..9cf32277c7f1 100644
@@ -25,6 +25,7 @@ obj-$(CONFIG_RTL8192CU)		+= rtl8192cu/
 obj-$(CONFIG_RTL8192SE)		+= rtl8192se/
 obj-$(CONFIG_RTL8192D_COMMON)	+= rtl8192d/
 obj-$(CONFIG_RTL8192DE)		+= rtl8192de/
+obj-$(CONFIG_RTL8192DU)		+= rtl8192du/
 obj-$(CONFIG_RTL8723AE)		+= rtl8723ae/
 obj-$(CONFIG_RTL8723BE)		+= rtl8723be/
 obj-$(CONFIG_RTL8188EE)		+= rtl8188ee/
drivers/net/wireless/realtek/rtlwifi/rtl8192du/Makefile new file +13 -0
new file mode 100644
index 000000000000..569bfd3d5030
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0
+rtl8192du-objs :=		\
+		dm.o		\
+		fw.o		\
+		hw.o		\
+		led.o		\
+		phy.o		\
+		rf.o		\
+		sw.o		\
+		table.o		\
+		trx.o
+
+obj-$(CONFIG_RTL8192DU) += rtl8192du.o
drivers/net/wireless/realtek/rtlwifi/rtl8192du/dm.c new file +788 -0

788 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/dm.h new file +10 -0
new file mode 100644
index 000000000000..d036cf722384
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#ifndef	__RTL92C_DM_H__
+#define __RTL92C_DM_H__
+
+void rtl92du_dm_init(struct ieee80211_hw *hw);
+void rtl92du_dm_watchdog(struct ieee80211_hw *hw);
+
+#endif
drivers/net/wireless/realtek/rtlwifi/rtl8192du/fw.c new file +109 -0

109 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/fw.h new file +9 -0
new file mode 100644
index 000000000000..857431fe8952
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#ifndef __RTL92D__FW__H__
+#define __RTL92D__FW__H__
+
+int rtl92d_download_fw(struct ieee80211_hw *hw);
+
+#endif
drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.c new file +1238 -0

1,238 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/hw.h new file +24 -0
new file mode 100644
index 000000000000..731aa3b78d07
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#ifndef __RTL92DE_HW_H__
+#define __RTL92DE_HW_H__
+
+void rtl92du_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
+void rtl92du_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val);
+void rtl92du_read_chip_version(struct ieee80211_hw *hw);
+int rtl92du_hw_init(struct ieee80211_hw *hw);
+void rtl92du_card_disable(struct ieee80211_hw *hw);
+void rtl92de_enable_interrupt(struct ieee80211_hw *hw);
+void rtl92de_disable_interrupt(struct ieee80211_hw *hw);
+int rtl92de_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type);
+void rtl92de_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid);
+void rtl92de_set_beacon_related_registers(struct ieee80211_hw *hw);
+void rtl92de_set_beacon_interval(struct ieee80211_hw *hw);
+void rtl92de_update_interrupt_mask(struct ieee80211_hw *hw,
+				   u32 add_msr, u32 rm_msr);
+void rtl92de_suspend(struct ieee80211_hw *hw);
+void rtl92de_resume(struct ieee80211_hw *hw);
+void rtl92d_linked_set_reg(struct ieee80211_hw *hw);
+
+#endif
drivers/net/wireless/realtek/rtlwifi/rtl8192du/led.c new file +10 -0
new file mode 100644
index 000000000000..a2761f25e94e
@@ -0,0 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#include "../wifi.h"
+#include "led.h"
+
+void rtl92de_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction)
+{
+	/* The hardware has control. */
+}
drivers/net/wireless/realtek/rtlwifi/rtl8192du/led.h new file +9 -0
new file mode 100644
index 000000000000..b7f7a74d5261
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2009-2012  Realtek Corporation.*/
+
+#ifndef __RTL92CE_LED_H__
+#define __RTL92CE_LED_H__
+
+void rtl92de_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction);
+
+#endif
drivers/net/wireless/realtek/rtlwifi/rtl8192du/phy.c new file +3064 -0

765 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/phy.h new file +32 -0
new file mode 100644
index 000000000000..576b6fdf0e4a

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192du/rf.c new file +236 -0

236 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/rf.h new file +11 -0
new file mode 100644
index 000000000000..c097d90cc99c

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c new file +310 -0

310 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.h new file +12 -0
new file mode 100644
index 000000000000..364d9a471dc0

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192du/table.c new file +1675 -0

1,675 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/table.h new file +30 -0
new file mode 100644
index 000000000000..71d943158c5f

Lines of this file are not shown. View the raw message.

drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.c new file +380 -0

380 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/rtl8192du/trx.h new file +60 -0

60 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.2

Part of the diff is not shown here. View the raw message.

maintainer
#7 lore raw

Re: [PATCH 3/3] wifi: rtlwifi: Add new rtl8192du driver

Quoted 5 lines · Bitterblue Smith

The RTL8192DU is an older Wifi 4 dual band chip. It comes in two
flavours: single MAC single PHY (like most Realtek Wifi 4 USB devices), and dual MAC dual PHY.

Quoted 8 lines

The single MAC single PHY version is 2T2R and can work either in the 2.4 GHz band or the 5 GHz band.

The dual MAC dual PHY version has two USB interfaces and appears to the system as two separate 1T1R Wifi devices, one working in the 2.4 GHz band, the other in the 5 GHz band.

This was tested only with a single MAC single PHY device.

Please run checkpatch.pl that reports:
"total: 0 errors, 11 warnings, 27 checks, 8045 lines checked"

(Sorry, I wrongly posted above result on patch 2/3)

Quoted 22 lines

---

Should I split this into multiple patches, one for each new file, to make reviewing easier?

---
 drivers/net/wireless/realtek/rtlwifi/Kconfig  |   12 +
 drivers/net/wireless/realtek/rtlwifi/Makefile |    1 +
 .../realtek/rtlwifi/rtl8192du/Makefile        |   13 +
 .../wireless/realtek/rtlwifi/rtl8192du/dm.c   |  788 +++++
 .../wireless/realtek/rtlwifi/rtl8192du/dm.h   |   10 +
 .../wireless/realtek/rtlwifi/rtl8192du/fw.c   |  109 +
 .../wireless/realtek/rtlwifi/rtl8192du/fw.h   |    9 +
 .../wireless/realtek/rtlwifi/rtl8192du/hw.c   | 1238 +++++++
 .../wireless/realtek/rtlwifi/rtl8192du/hw.h   |   24 +
 .../wireless/realtek/rtlwifi/rtl8192du/led.c  |   10 +
 .../wireless/realtek/rtlwifi/rtl8192du/led.h  |    9 +
 .../wireless/realtek/rtlwifi/rtl8192du/phy.c  | 3064 +++++++++++++++++
 .../wireless/realtek/rtlwifi/rtl8192du/phy.h  |   32 +
 .../wireless/realtek/rtlwifi/rtl8192du/rf.c   |  236 ++
Quoted 8 lines
 .../wireless/realtek/rtlwifi/rtl8192du/rf.h   |   11 +
 .../wireless/realtek/rtlwifi/rtl8192du/sw.c   |  310 ++
 .../wireless/realtek/rtlwifi/rtl8192du/sw.h   |   12 +
 .../realtek/rtlwifi/rtl8192du/table.c         | 1675 +++++++++
 .../realtek/rtlwifi/rtl8192du/table.h         |   30 +
 .../wireless/realtek/rtlwifi/rtl8192du/trx.c  |  380 ++
 .../wireless/realtek/rtlwifi/rtl8192du/trx.h  |   60 +
 21 files changed, 8033 insertions(+)

Please split this patch to small ones. Like make dm.c/dm.h as a patch, hw.c/hw.h as another patch and etc. For smaller files such as led.c/led.h, it is fine to combine with others.

Though you have done 8192DU in rtlwifi, I still want to know how you decide to support 8192DU in rtlwifi instead of rtl8xxxu. IIRC most USB users of Realtek WiFi use rtl8xxxu.

Ping-Ke

#8 lore raw

Re: [PATCH 3/3] wifi: rtlwifi: Add new rtl8192du driver

Quoted 13 lines · Ping-Ke Shih
Quoted 12 lines · Bitterblue Smith

The RTL8192DU is an older Wifi 4 dual band chip. It comes in two
flavours: single MAC single PHY (like most Realtek Wifi 4 USB devices), and dual MAC dual PHY.

The single MAC single PHY version is 2T2R and can work either in the 2.4 GHz band or the 5 GHz band.

The dual MAC dual PHY version has two USB interfaces and appears to the system as two separate 1T1R Wifi devices, one working in the 2.4 GHz band, the other in the 5 GHz band.

Quoted 7 lines
Quoted 1 line

This was tested only with a single MAC single PHY device.

Please run checkpatch.pl that reports:
"total: 0 errors, 11 warnings, 27 checks, 8045 lines checked"

(Sorry, I wrongly posted above result on patch 2/3)>

I did run checkpatch, these are the things I decided to ignore. :) I will have another look.

Quoted 31 lines
Quoted 22 lines

---

Should I split this into multiple patches, one for each new file, to make reviewing easier?

---
 drivers/net/wireless/realtek/rtlwifi/Kconfig  |   12 +
 drivers/net/wireless/realtek/rtlwifi/Makefile |    1 +
 .../realtek/rtlwifi/rtl8192du/Makefile        |   13 +
 .../wireless/realtek/rtlwifi/rtl8192du/dm.c   |  788 +++++
 .../wireless/realtek/rtlwifi/rtl8192du/dm.h   |   10 +
 .../wireless/realtek/rtlwifi/rtl8192du/fw.c   |  109 +
 .../wireless/realtek/rtlwifi/rtl8192du/fw.h   |    9 +
 .../wireless/realtek/rtlwifi/rtl8192du/hw.c   | 1238 +++++++
 .../wireless/realtek/rtlwifi/rtl8192du/hw.h   |   24 +
 .../wireless/realtek/rtlwifi/rtl8192du/led.c  |   10 +
 .../wireless/realtek/rtlwifi/rtl8192du/led.h  |    9 +
 .../wireless/realtek/rtlwifi/rtl8192du/phy.c  | 3064 +++++++++++++++++
 .../wireless/realtek/rtlwifi/rtl8192du/phy.h  |   32 +
 .../wireless/realtek/rtlwifi/rtl8192du/rf.c   |  236 ++
Quoted 8 lines
 .../wireless/realtek/rtlwifi/rtl8192du/rf.h   |   11 +
 .../wireless/realtek/rtlwifi/rtl8192du/sw.c   |  310 ++
 .../wireless/realtek/rtlwifi/rtl8192du/sw.h   |   12 +
 .../realtek/rtlwifi/rtl8192du/table.c         | 1675 +++++++++
 .../realtek/rtlwifi/rtl8192du/table.h         |   30 +
 .../wireless/realtek/rtlwifi/rtl8192du/trx.c  |  380 ++
 .../wireless/realtek/rtlwifi/rtl8192du/trx.h  |   60 +
 21 files changed, 8033 insertions(+)
Quoted 4 lines

Please split this patch to small ones. Like make dm.c/dm.h as a patch, hw.c/hw.h as another patch and etc. For smaller files such as led.c/led.h, it is fine to combine with others.

Okay.

Quoted 7 lines

Though you have done 8192DU in rtlwifi, I still want to know how you decide to support 8192DU in rtlwifi instead of rtl8xxxu. IIRC most USB users of Realtek WiFi use rtl8xxxu.

Ping-Ke

Originally I worked on rtl8xxxu. I didn't like how many changes it needed to support this chip. And then the first test with rtl8xxxu produced no scan results. At that point I gave up and modified rtl8192de instead. (The first test with the modified rtl8192de also produced no scan results... but rtlwifi has a lot of debugging output, which helped.)

maintainer
#9 lore raw

Re: [PATCH 3/3] wifi: rtlwifi: Add new rtl8192du driver

Quoted 10 lines · Bitterblue Smith
Quoted 5 lines · Ping-Ke Shih

Please run checkpatch.pl that reports:
"total: 0 errors, 11 warnings, 27 checks, 8045 lines checked"

(Sorry, I wrongly posted above result on patch 2/3)>

I did run checkpatch, these are the things I decided to ignore. :)

Just remind you can check those warnings because I'm waiting for your v2 that splits this big patch, and yes we can ignore some of them.

maintainer
#11 lore raw
Quoted 7 lines · Bitterblue Smith

rtl92d_dm_check_txpower_tracking_thermal_meter() is actually unused in rtl8192de. Should I just delete it?

I don't remember why I made it static, but that introduced a warning.

I feel we can set rtlpriv->dm.txpower_tracking = false, and then uncomment /* rtl92d_dm_check_txpower_tracking_thermal_meter(hw); */

More, this function appears twice:

$ git grep rtl92d_dm_check_txpower_tracking_thermal_meter
rtl8192de/dm.c:static void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw)
rtl8192de/dm.c:         /* rtl92d_dm_check_txpower_tracking_thermal_meter(hw); */
rtl8192du/dm.c:void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw)
rtl8192du/dm.c:         rtl92d_dm_check_txpower_tracking_thermal_meter(hw);

I suppose you should move rtl92d_dm_check_txpower_tracking_thermal_meter() to dm_common.c.

Ping-Ke

#12 lore raw
Quoted 7 lines · Ping-Ke Shih
Quoted 5 lines · Bitterblue Smith

rtl92d_dm_check_txpower_tracking_thermal_meter() is actually unused in rtl8192de. Should I just delete it?

Quoted 7 lines
Quoted 2 lines

I don't remember why I made it static, but that introduced a warning.

I feel we can set rtlpriv->dm.txpower_tracking = false, and then uncomment /* rtl92d_dm_check_txpower_tracking_thermal_meter(hw); */

That sounds good.

Quoted 12 lines

More, this function appears twice:

$ git grep rtl92d_dm_check_txpower_tracking_thermal_meter
rtl8192de/dm.c:static void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw)
rtl8192de/dm.c:         /* rtl92d_dm_check_txpower_tracking_thermal_meter(hw); */
rtl8192du/dm.c:void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw)
rtl8192du/dm.c:         rtl92d_dm_check_txpower_tracking_thermal_meter(hw);

I suppose you should move rtl92d_dm_check_txpower_tracking_thermal_meter() to dm_common.c.

I didn't move the TX power tracking to dm_common.c because it calls two functions which are different in the PCI driver and the out-of-tree USB driver. (The USB driver is a few years newer.)

* rtl92d_phy_lc_calibrate()
* rtl92d_phy_iq_calibrate()

I suppose if rtl92d_dm_check_txpower_tracking_thermal_meter() takes two function pointers, it can be moved:

void rtl92d_dm_check_txpower_tracking_thermal_meter(struct ieee80211_hw *hw,

						    void (*lc_calibrate)(struct ieee80211_hw *hw),
						    void (*iq_calibrate)(struct ieee80211_hw *hw))

Or, struct rtl_hal_ops already has phy_lc_calibrate member. I could add phy_iq_calibrate too.

maintainer
#13 lore raw
In reply to Bitterblue Smith
Quoted 11 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Please run checkpatch.pl that reports
"total: 5 errors, 20 warnings, 67 checks, 9388 lines checked"

I know you just move them from a place to another, but let's fix them when touching.

Two unused warnings on channel_all and rtl92d_dm_check_txpower_tracking_thermal_meter (you also pointed it out)

Ping-Ke

#14 lore raw
Quoted 10 lines · Ping-Ke Shih
Quoted 9 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

Quoted 9 lines
Quoted 2 lines

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Please run checkpatch.pl that reports
"total: 5 errors, 20 warnings, 67 checks, 9388 lines checked"

I know you just move them from a place to another, but let's fix them when touching.

All right, I will make checkpatch less unhappy.

Quoted 6 lines

Two unused warnings on channel_all and rtl92d_dm_check_txpower_tracking_thermal_meter (you also pointed it out)

Quoted 1 line

Ping-Ke

Tested-by on v1 1/3
#15 lore raw
In reply to Bitterblue Smith

Hi

Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

[...]

Quoted 3 lines

Tested only with RTL8192DU.

I've successfully tested this series and its preparatory patch on my DeLock 88540,
https://www.delock.com/produkt/88540/merkmale.html?setLanguage=en

wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power
wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common
wifi: rtlwifi: Adjust rtl8192d-common for USB
wifi: rtlwifi: Add new rtl8192du driver

[   32.083987] usb 3-5: new high-speed USB device number 5 using xhci_hcd
[   32.212707] usb 3-5: New USB device found, idVendor=0bda, idProduct=8194, bcdDevice= 0.00
[   32.212722] usb 3-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   32.212727] usb 3-5: Product: 802.11n NIC
[   32.212732] usb 3-5: Manufacturer: Realtek
[   32.212735] usb 3-5: SerialNumber: 00e04c000001
[   32.362820] rtl_usb: rx_max_size 15360, rx_urb_num 8, in_ep 1
[   32.362836] rtl8192du: Inactive Power Save off (module option)
[   32.362839] rtl8192du: Driver for Realtek RTL8192DU WLAN interface
[   32.362840] rtl8192du: Loading firmware file rtlwifi/rtl8192dufw.bin
[   32.362952] ieee80211 phy1: Selected rate control algorithm 'rtl_rc'
[   32.364168] usbcore: registered new interface driver rtl8192du
[   32.372367] rtl8192du 3-5:1.0 wlxXXXXXXXXXXXX: renamed from wlan0
[...]
[  130.838250] wlxXXXXXXXXXXXX: authenticate with XX:XX:XX:XX:XX:XX (local address=XX:XX:XX:XX:XX:XX)
[  130.838256] wlxXXXXXXXXXXXX: send auth to XX:XX:XX:XX:XX:XX (try 1/3)
[  130.849611] wlxXXXXXXXXXXXX: authenticate with XX:XX:XX:XX:XX:XX (local address=XX:XX:XX:XX:XX:XX)
[  130.849621] wlxXXXXXXXXXXXX: send auth to XX:XX:XX:XX:XX:XX (try 1/3)
[  130.852150] wlxXXXXXXXXXXXX: authenticated
[  130.853287] wlxXXXXXXXXXXXX: associate with XX:XX:XX:XX:XX:XX (try 1/3)
[  130.860230] wlxXXXXXXXXXXXX: RX AssocResp from XX:XX:XX:XX:XX:XX (capab=0x1511 status=0 aid=3)
[  130.861618] wlxXXXXXXXXXXXX: associated
[  130.876995] wlxXXXXXXXXXXXX: Limiting TX power to 23 (23 - 0) dBm as advertised by XX:XX:XX:XX:XX:XX
# wpa_cli -i wlxXXXXXXXXXXXX status
bssid=XX:XX:XX:XX:XX:XX
freq=5260
ssid=XXX
id=4
id_str=XXX
mode=station
wifi_generation=4
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=SAE
pmf=2
mgmt_group_cipher=BIP
sae_group=19
sae_h2e=0
sae_pk=0
wpa_state=COMPLETED
p2p_device_address=XX:XX:XX:XX:XX:XX
address=XX:XX:XX:XX:XX:XX
uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXXX

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

MD5:
abccba1e9bb456eb81dfc88502a56300 /lib/firmware/rtlwifi/rtl8192dufw.bin

SHA256:
9b51f15642b7f2d41e8369d7df956f92333c09699d8a88039081a8bdc77242a1 /lib/firmware/rtlwifi/rtl8192dufw.bin

Regards
Stefan Lippers-Hollmann

maintainer
#16 lore raw
Quoted 11 lines · Stefan Lippers-Hollmann
Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

[...]

Quoted 3 lines

Tested only with RTL8192DU.

Thanks for the report. Could I know the throughput performance in your side? Just for a record.

Quoted 4 lines

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

I can do that after this patchset get merged.

Ping-Ke

#17 lore raw

Hi

Quoted 6 lines · Ping-Ke Shih
Quoted 5 lines · Stefan Lippers-Hollmann
Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

[...]

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Tested only with RTL8192DU.

Thanks for the report. Could I know the throughput performance in your side? Just for a record.

The performance is okay - the driver has been working reliably all day long (WPA2SAE and WPA2PSK/ CCMP, 2.4 GHz and 5 GHz, against an ipq8071a+qcn5024+qcn5054 AP running recent OpenWrt).

# wpa_cli -i wlxXXXXXXXXXXXX status
bssid=XX:XX:XX:XX:XX:XX
freq=5260
ssid=XXX
id=0
id_str=XXX
mode=station
wifi_generation=4
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=WPA2-PSK
wpa_state=COMPLETED
p2p_device_address=XX:XX:XX:XX:XX:XX
address=XX:XX:XX:XX:XX:XX
uuid=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
$ iperf3 -c 2a00:XXXX:XXXX:XXXX::XXXX:401
Connecting to host 2a00:XXXX:XXXX:XXXX::XXXX:401, port 5201
[  5] local 2a00:XXXX:XXXX:XXXX::XXXX:c046 port 33696 connected to 2a00:XXXX:XXXX:XXXX::XXXX:401 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  12.2 MBytes   103 Mbits/sec    0    442 KBytes
[  5]   1.00-2.00   sec  10.6 MBytes  89.1 Mbits/sec    0    498 KBytes
[  5]   2.00-3.00   sec  11.6 MBytes  97.5 Mbits/sec    0    582 KBytes
[  5]   3.00-4.00   sec  11.1 MBytes  93.3 Mbits/sec    0    587 KBytes
[  5]   4.00-5.00   sec  12.0 MBytes   101 Mbits/sec    0    660 KBytes
[  5]   5.00-6.00   sec  11.5 MBytes  96.5 Mbits/sec    0    694 KBytes
[  5]   6.00-7.00   sec  11.1 MBytes  93.3 Mbits/sec    0    694 KBytes
[  5]   7.00-8.00   sec  12.9 MBytes   108 Mbits/sec    0    694 KBytes
[  5]   8.00-9.00   sec  12.4 MBytes   104 Mbits/sec    0    694 KBytes
[  5]   9.00-10.00  sec  12.8 MBytes   107 Mbits/sec    0    694 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   118 MBytes  99.2 Mbits/sec    0             sender
[  5]   0.00-10.02  sec   115 MBytes  96.1 Mbits/sec                  receiver

iperf Done.

$ iperf3 -c 2a00:XXXX:XXXX:XXXX::XXXX:401 --reverse
Connecting to host 2a00:XXXX:XXXX:XXXX::XXXX:401, port 5201
Reverse mode, remote host 2a00:XXXX:XXXX:XXXX::XXXX:401 is sending
[  5] local 2a00:XXXX:XXXX:XXXX::XXXX:c046 port 57880 connected to 2a00:XXXX:XXXX:XXXX::XXXX:401 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  18.4 MBytes   154 Mbits/sec
[  5]   1.00-2.00   sec  20.5 MBytes   172 Mbits/sec
[  5]   2.00-3.00   sec  20.4 MBytes   171 Mbits/sec
[  5]   3.00-4.00   sec  19.9 MBytes   167 Mbits/sec
[  5]   4.00-5.00   sec  20.2 MBytes   170 Mbits/sec
[  5]   5.00-6.00   sec  21.1 MBytes   177 Mbits/sec
[  5]   6.00-7.00   sec  21.1 MBytes   177 Mbits/sec
[  5]   7.00-8.00   sec  20.9 MBytes   175 Mbits/sec
[  5]   8.00-9.00   sec  20.8 MBytes   174 Mbits/sec
[  5]   9.00-10.00  sec  20.9 MBytes   175 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.03  sec   207 MBytes   173 Mbits/sec    0             sender
[  5]   0.00-10.00  sec   204 MBytes   171 Mbits/sec                  receiver

iperf Done.

$ iperf3 -c 2a00:XXXX:XXXX:XXXX::XXXX:401 --bidir
Connecting to host 2a00:XXXX:XXXX:XXXX::XXXX:401, port 5201
[  5] local 2a00:XXXX:XXXX:XXXX::XXXX:c046 port 44960 connected to 2a00:XXXX:XXXX:XXXX::XXXX:401 port 5201
[  7] local 2a00:XXXX:XXXX:XXXX::XXXX:c046 port 44966 connected to 2a00:XXXX:XXXX:XXXX::XXXX:401 port 5201
[ ID][Role] Interval           Transfer     Bitrate         Retr  Cwnd
[  5][TX-C]   0.00-1.00   sec  8.25 MBytes  69.2 Mbits/sec    0    357 KBytes
[  7][RX-C]   0.00-1.00   sec  10.9 MBytes  91.2 Mbits/sec
[  5][TX-C]   1.00-2.00   sec  5.00 MBytes  41.9 Mbits/sec    0    547 KBytes
[  7][RX-C]   1.00-2.00   sec  15.2 MBytes   128 Mbits/sec
[  5][TX-C]   2.00-3.00   sec  2.50 MBytes  21.0 Mbits/sec    0    628 KBytes
[  7][RX-C]   2.00-3.00   sec  16.9 MBytes   142 Mbits/sec
[  5][TX-C]   3.00-4.00   sec  2.62 MBytes  22.0 Mbits/sec    0    674 KBytes
[  7][RX-C]   3.00-4.00   sec  17.6 MBytes   148 Mbits/sec
[  5][TX-C]   4.00-5.00   sec  2.88 MBytes  24.1 Mbits/sec    0    764 KBytes
[  7][RX-C]   4.00-5.00   sec  15.0 MBytes   126 Mbits/sec
[  5][TX-C]   5.00-6.00   sec  1.38 MBytes  11.5 Mbits/sec    0    848 KBytes
[  7][RX-C]   5.00-6.00   sec  11.2 MBytes  94.4 Mbits/sec
[  5][TX-C]   6.00-7.00   sec  1.50 MBytes  12.6 Mbits/sec    0    957 KBytes
[  7][RX-C]   6.00-7.00   sec  11.9 MBytes  99.6 Mbits/sec
[  5][TX-C]   7.00-8.00   sec  4.00 MBytes  33.6 Mbits/sec    0   1.09 MBytes
[  7][RX-C]   7.00-8.00   sec  11.9 MBytes  99.6 Mbits/sec
[  5][TX-C]   8.00-9.00   sec  1.75 MBytes  14.7 Mbits/sec    0   1.20 MBytes
[  7][RX-C]   8.00-9.00   sec  9.75 MBytes  81.8 Mbits/sec
[  5][TX-C]   9.00-10.00  sec  2.75 MBytes  23.1 Mbits/sec    0   1.31 MBytes
[  7][RX-C]   9.00-10.00  sec  10.6 MBytes  89.1 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID][Role] Interval           Transfer     Bitrate         Retr
[  5][TX-C]   0.00-10.00  sec  32.6 MBytes  27.4 Mbits/sec    0             sender
[  5][TX-C]   0.00-10.04  sec  29.4 MBytes  24.5 Mbits/sec                  receiver
[  7][RX-C]   0.00-10.00  sec   134 MBytes   113 Mbits/sec    0             sender
[  7][RX-C]   0.00-10.04  sec   131 MBytes   109 Mbits/sec                  receiver

iperf Done.

$ /sbin/iw dev wlxXXXXXXXXXXXX station dump
Station XX:XX:XX:XX:XX:XX (on wlxXXXXXXXXXXXX)
        inactive time:  0 ms
        rx bytes:       359255660
        rx packets:     241259
        tx bytes:       168308006
        tx packets:     190031
        tx retries:     0
        tx failed:      0
        beacon loss:    0
        rx drop misc:   4
        signal:         -22 dBm
        signal avg:     -22 dBm
        tx bitrate:     300.0 MBit/s MCS 15 40MHz short GI
        tx duration:    0 us
        rx bitrate:     270.0 MBit/s MCS 15 40MHz
        rx duration:    0 us
        authorized:     yes
        authenticated:  yes
        associated:     yes
        preamble:       long
        WMM/WME:        yes
        MFP:            no
        TDLS peer:      no
        DTIM period:    1
        beacon interval:100
        short slot time:yes
        connected time: 116 seconds
        associated at [boottime]:       8521.829s
        associated at:  1710309820764 ms
        current time:   1710309936171 ms
$ /sbin/iw phy phy1 info
Wiphy phy1
        wiphy index: 1
        max # scan SSIDs: 4
        max scan IEs length: 2257 bytes
        max # sched scan SSIDs: 0
        max # match sets: 0
        RTS threshold: 2347
        Retry short limit: 7
        Retry long limit: 4
        Coverage class: 0 (up to 0m)
        Device supports RSN-IBSS.
        Supported Ciphers:
                * WEP40 (00-0f-ac:1)
                * WEP104 (00-0f-ac:5)
                * TKIP (00-0f-ac:2)
                * CCMP-128 (00-0f-ac:4)
                * CCMP-256 (00-0f-ac:10)
                * GCMP-128 (00-0f-ac:8)
                * GCMP-256 (00-0f-ac:9)
                * CMAC (00-0f-ac:6)
                * CMAC-256 (00-0f-ac:13)
                * GMAC-128 (00-0f-ac:11)
                * GMAC-256 (00-0f-ac:12)
        Available Antennas: TX 0 RX 0
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
        Band 1:
                Capabilities: 0x186e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 7935 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 16 usec (0x07)
                HT Max RX data rate: 300 Mbps
                HT TX/RX MCS rate indexes supported: 0-15, 32
                Bitrates (non-HT):
                        * 1.0 Mbps
                        * 2.0 Mbps
                        * 5.5 Mbps
                        * 11.0 Mbps
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                Frequencies:
                        * 2412.0 MHz [1] (20.0 dBm)
                        * 2417.0 MHz [2] (20.0 dBm)
                        * 2422.0 MHz [3] (20.0 dBm)
                        * 2427.0 MHz [4] (20.0 dBm)
                        * 2432.0 MHz [5] (20.0 dBm)
                        * 2437.0 MHz [6] (20.0 dBm)
                        * 2442.0 MHz [7] (20.0 dBm)
                        * 2447.0 MHz [8] (20.0 dBm)
                        * 2452.0 MHz [9] (20.0 dBm)
                        * 2457.0 MHz [10] (20.0 dBm)
                        * 2462.0 MHz [11] (20.0 dBm)
                        * 2467.0 MHz [12] (20.0 dBm)
                        * 2472.0 MHz [13] (20.0 dBm)
                        * 2484.0 MHz [14] (disabled)
        Band 2:
                Capabilities: 0x186e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 7935 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 16 usec (0x07)
                HT Max RX data rate: 300 Mbps
                HT TX/RX MCS rate indexes supported: 0-15, 32
                Bitrates (non-HT):
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                Frequencies:
                        * 5180.0 MHz [36] (23.0 dBm)
                        * 5200.0 MHz [40] (23.0 dBm)
                        * 5220.0 MHz [44] (23.0 dBm)
                        * 5240.0 MHz [48] (23.0 dBm)
                        * 5260.0 MHz [52] (20.0 dBm) (no IR, radar detection)
                        * 5280.0 MHz [56] (20.0 dBm) (no IR, radar detection)
                        * 5300.0 MHz [60] (20.0 dBm) (no IR, radar detection)
                        * 5320.0 MHz [64] (20.0 dBm) (no IR, radar detection)
                        * 5500.0 MHz [100] (26.0 dBm) (no IR, radar detection)
                        * 5520.0 MHz [104] (26.0 dBm) (no IR, radar detection)
                        * 5540.0 MHz [108] (26.0 dBm) (no IR, radar detection)
                        * 5560.0 MHz [112] (26.0 dBm) (no IR, radar detection)
                        * 5580.0 MHz [116] (26.0 dBm) (no IR, radar detection)
                        * 5600.0 MHz [120] (26.0 dBm) (no IR, radar detection)
                        * 5620.0 MHz [124] (26.0 dBm) (no IR, radar detection)
                        * 5640.0 MHz [128] (26.0 dBm) (no IR, radar detection)
                        * 5660.0 MHz [132] (26.0 dBm) (no IR, radar detection)
                        * 5680.0 MHz [136] (26.0 dBm) (no IR, radar detection)
                        * 5700.0 MHz [140] (26.0 dBm) (no IR, radar detection)
                        * 5745.0 MHz [149] (13.0 dBm)
                        * 5765.0 MHz [153] (13.0 dBm)
                        * 5785.0 MHz [157] (13.0 dBm)
                        * 5805.0 MHz [161] (13.0 dBm)
                        * 5825.0 MHz [165] (13.0 dBm)
        Supported commands:
                 * new_interface
                 * set_interface
                 * new_key
                 * start_ap
                 * new_station
                 * new_mpath
                 * set_mesh_config
                 * set_bss
                 * authenticate
                 * associate
                 * deauthenticate
                 * disassociate
                 * join_ibss
                 * join_mesh
                 * remain_on_channel
                 * set_tx_bitrate_mask
                 * frame
                 * frame_wait_cancel
                 * set_wiphy_netns
                 * set_channel
                 * probe_client
                 * set_noack_map
                 * register_beacons
                 * start_p2p_device
                 * set_mcast_rate
                 * testmode
                 * connect
                 * disconnect
                 * set_qos_map
                 * set_multicast_to_unicast
        software interface modes (can always be added):
                 * AP/VLAN
                 * monitor
        interface combinations are not supported
        HT Capability overrides:
                 * MCS: ff ff ff ff ff ff ff ff ff ff
                 * maximum A-MSDU length
                 * supported channel width
                 * short GI for 40 MHz
                 * max A-MPDU length exponent
                 * min MPDU start spacing
        Device supports TX status socket option.
        Device supports HT-IBSS.
        Device supports SAE with AUTHENTICATE command
        Device supports low priority scan.
        Device supports scan flush.
        Device supports AP scan.
        Device supports per-vif TX power setting
        Driver supports full state transitions for AP/GO clients
        Driver supports a userspace MPM
        Device supports configuring vdev MAC-addr on create.
        max # scan plans: 1
        max scan plan interval: -1
        max scan plan iterations: 0
        Supported TX frame types:
                 * IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
        Supported RX frame types:
                 * IBSS: 0x40 0xb0 0xc0 0xd0
                 * managed: 0x40 0xb0 0xd0
                 * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * mesh point: 0xb0 0xc0 0xd0
                 * P2P-client: 0x40 0xd0
                 * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * P2P-device: 0x40 0xd0
        Supported extended features:
                * [ RRM ]: RRM
                * [ FILS_STA ]: STA FILS (Fast Initial Link Setup)
                * [ CONTROL_PORT_OVER_NL80211 ]: control port over nl80211
                * [ TXQS ]: FQ-CoDel-enabled intermediate TXQs
                * [ SCAN_RANDOM_SN ]: use random sequence numbers in scans
                * [ SCAN_MIN_PREQ_CONTENT ]: use probe request with only rate IEs in scans
                * [ CONTROL_PORT_NO_PREAUTH ]: disable pre-auth over nl80211 control port support
                * [ DEL_IBSS_STA ]: deletion of IBSS station support
                * [ SCAN_FREQ_KHZ ]: scan on kHz frequency support
                * [ CONTROL_PORT_OVER_NL80211_TX_STATUS ]: tx status for nl80211 control port support
                * [ POWERED_ADDR_CHANGE ]: can change MAC address while up
Quoted 5 lines
Quoted 3 lines

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

I can do that after this patchset get merged.

Great :)

Regards
Stefan Lippers-Hollmann

maintainer
#18 lore raw
Quoted 5 lines · Stefan Lippers-Hollmann

The performance is okay - the driver has been working reliably all day long (WPA2SAE and WPA2PSK/ CCMP, 2.4 GHz and 5 GHz, against an ipq8071a+qcn5024+qcn5054 AP running recent OpenWrt).

Thanks. Both PHY rate and throughput look good.

Bitterblue, Can you make a record in commit message of the last commit that enables 8192DU?

Ping-Ke

#19 lore raw
Quoted 7 lines · Ping-Ke Shih
Quoted 5 lines · Stefan Lippers-Hollmann

The performance is okay - the driver has been working reliably all day long (WPA2SAE and WPA2PSK/ CCMP, 2.4 GHz and 5 GHz, against an ipq8071a+qcn5024+qcn5054 AP running recent OpenWrt).

Quoted 7 lines

Thanks. Both PHY rate and throughput look good.

Bitterblue, Can you make a record in commit message of the last commit that enables 8192DU?

Ping-Ke

Sure, I will do that.

#20 lore raw
In reply to Ping-Ke Shih
Quoted 17 lines · Ping-Ke Shih
Quoted 11 lines · Stefan Lippers-Hollmann
Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

[...]

Quoted 3 lines

Tested only with RTL8192DU.

Thanks for the report. Could I know the throughput performance in your side? Just for a record.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

I can do that after this patchset get merged.

Ping-Ke

Should I send you the firmware like usual?

maintainer
#21 lore raw
Quoted 2 lines · Bitterblue Smith

Should I send you the firmware like usual?

If you can help making a patch to me privately, that would be very helpful.

#22 lore raw
In reply to Ping-Ke Shih

Hi

Quoted 5 lines · Ping-Ke Shih
Quoted 4 lines · Stefan Lippers-Hollmann
Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

[...]

Quoted 11 lines
Quoted 9 lines

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

MD5:
abccba1e9bb456eb81dfc88502a56300 /lib/firmware/rtlwifi/rtl8192dufw.bin

SHA256:
9b51f15642b7f2d41e8369d7df956f92333c09699d8a88039081a8bdc77242a1 /lib/firmware/rtlwifi/rtl8192dufw.bin

I can do that after this patchset get merged.

As kernel v6.11 premiering with rtl8192du (which works well) isn't that far away, I'll just drop a reminder about publishing the corresponding rtlwifi/rtl8192dufw.bin firmware image to linux-firmware.

Regards
Stefan Lippers-Hollmann

Post scriptum: Apologies if I missed a corresponding patch to
linux-firmware.git.

maintainer
#23 lore raw
Quoted 6 lines · Stefan Lippers-Hollmann
Quoted 5 lines · Ping-Ke Shih
Quoted 4 lines · Stefan Lippers-Hollmann
Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

Quoted 7 lines

[...]

Quoted 6 lines
Quoted 6 lines

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

MD5:
abccba1e9bb456eb81dfc88502a56300 /lib/firmware/rtlwifi/rtl8192dufw.bin

I found its version is 38 that is little bit older than [1] (version 39). Bitterblue has made a binary from [1] and I have verified the binary. I will send this firmware days later because my previous firmware is still under review.

Quoted 11 lines
Quoted 3 lines
Quoted 3 lines

SHA256:
9b51f15642b7f2d41e8369d7df956f92333c09699d8a88039081a8bdc77242a1

/lib/firmware/rtlwifi/rtl8192dufw.bin

Quoted 2 lines

I can do that after this patchset get merged.

As kernel v6.11 premiering with rtl8192du (which works well) isn't that far away, I'll just drop a reminder about publishing the corresponding rtlwifi/rtl8192dufw.bin firmware image to linux-firmware.

Thanks for the reminder. I have queued this firmware to my local tree.

[1] https://github.com/lwfinger/rtl8192du/blob/master/hal/Hal8192DUHWImg.c

#24 lore raw

Hi

Quoted 19 lines · Ping-Ke Shih
Quoted 6 lines · Stefan Lippers-Hollmann
Quoted 5 lines · Ping-Ke Shih
Quoted 4 lines · Stefan Lippers-Hollmann
Quoted 3 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

Quoted 7 lines

[...]

Quoted 6 lines
Quoted 6 lines

Using the firmware from https://github.com/lwfinger/rtl8192du/,
it would be great if someone could publish the necessary firmware to linux-firmware.

MD5:
abccba1e9bb456eb81dfc88502a56300 /lib/firmware/rtlwifi/rtl8192dufw.bin

I found its version is 38 that is little bit older than [1] (version 39). Bitterblue has made a binary from [1] and I have verified the binary. I will send this firmware days later because my previous firmware is still under review.

[...]

Quoted 1 line

[1] https://github.com/lwfinger/rtl8192du/blob/master/hal/Hal8192DUHWImg.c

Great, just a quick functionality check with this firmware (v39):

MD5:
18eb8791673dcc38b268ad19c92ba6a2 */lib/firmware/rtlwifi/rtl8192dufw.bin

SHA256:
710c4a28904b180e5a316a372e1038972102b2545909bc117c2455cf536e4490 */lib/firmware/rtlwifi/rtl8192dufw.bin

Connects and works fine with kernel v6.11, using WPA3SAE over 5 GHz.

[  202.941904] usb 3-5: new high-speed USB device number 5 using xhci_hcd
[  203.070437] usb 3-5: New USB device found, idVendor=0bda, idProduct=8194, bcdDevice= 0.00
[  203.070453] usb 3-5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  203.070460] usb 3-5: Product: 802.11n NIC
[  203.070464] usb 3-5: Manufacturer: Realtek
[  203.070468] usb 3-5: SerialNumber: 00e04c000001
[  203.220236] rtl_usb: rx_max_size 15360, rx_urb_num 8, in_ep 1
[  203.220248] rtl8192du: Driver for Realtek RTL8192DU WLAN interface
[  203.220249] rtl8192du: Loading firmware file rtlwifi/rtl8192dufw.bin
[  203.220324] ieee80211 phy1: Selected rate control algorithm 'rtl_rc'
[  203.220648] usbcore: registered new interface driver rtl8192du
[  203.227708] rtl8192du 3-5:1.0 wlxXXXlocalMACXXX: renamed from wlan0
[  230.852662] wlxXXXlocalMACXXX: authenticate with XXXAP1MACXXX (local address=XXXlocalMACXXX)
[  230.852670] wlxXXXlocalMACXXX: send auth to XXXAP1MACXXX (try 1/3)
[  230.870370] wlxXXXlocalMACXXX: authenticate with XXXAP1MACXXX (local address=XXXlocalMACXXX)
[  230.870381] wlxXXXlocalMACXXX: send auth to XXXAP1MACXXX (try 1/3)
[  230.873195] wlxXXXlocalMACXXX: authenticated
[  230.874472] wlxXXXlocalMACXXX: associate with XXXAP1MACXXX (try 1/3)
[  230.885511] wlxXXXlocalMACXXX: RX AssocResp from XXXAP1MACXXX (capab=0x1511 status=0 aid=2)
[  230.887245] wlxXXXlocalMACXXX: associated
[  230.897180] wlxXXXlocalMACXXX: Limiting TX power to 23 (23 - 0) dBm as advertised by XXXAP1MACXXX
[  240.889472] wlxXXXlocalMACXXX: deauthenticating from XXXAP1MACXXX by local choice (Reason: 3=DEAUTH_LEAVING)
[  244.386457] wlxXXXlocalMACXXX: authenticate with XXXAP2MACXXX (local address=XXXlocalMACXXX)
[  244.386470] wlxXXXlocalMACXXX: send auth to XXXAP2MACXXX (try 1/3)
[  244.397502] wlxXXXlocalMACXXX: authenticate with XXXAP2MACXXX (local address=XXXlocalMACXXX)
[  244.397515] wlxXXXlocalMACXXX: send auth to XXXAP2MACXXX (try 1/3)
[  244.399226] wlxXXXlocalMACXXX: authenticated
[  244.400306] wlxXXXlocalMACXXX: associate with XXXAP2MACXXX (try 1/3)
[  244.407420] wlxXXXlocalMACXXX: RX AssocResp from XXXAP2MACXXX (capab=0x1511 status=0 aid=3)
[  244.408977] wlxXXXlocalMACXXX: associated
[  244.461286] wlxXXXlocalMACXXX: Limiting TX power to 23 (23 - 0) dBm as advertised by XXXAP2MACXXX

(there is AP-side active bandsteering/ roaming at play)

# wpa_cli -i wlxXXXlocalMACXXX status
bssid=XXXAP2MACXXX
freq=5260
ssid=XXX
id=4
id_str=XXX
mode=station
wifi_generation=4
pairwise_cipher=CCMP
group_cipher=CCMP
key_mgmt=SAE
pmf=2
mgmt_group_cipher=BIP
sae_group=19
sae_h2e=0
sae_pk=0
wpa_state=COMPLETED
p2p_device_address=XXXlocalMACXXX
address=XXXlocalMACXXX
uuid=XXXUUIDXXX
$ iperf3 -c XXXremoteIPv6XXX
Connecting to host XXXremoteIPv6XXX, port 5201
[  5] local XXXlocalXXX port 45116 connected to XXXremoteIPv6XXX port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  13.9 MBytes   116 Mbits/sec    0    441 KBytes       
[  5]   1.00-2.00   sec  12.1 MBytes   102 Mbits/sec    0    471 KBytes       
[  5]   2.00-3.00   sec  11.4 MBytes  95.4 Mbits/sec    0    471 KBytes       
[  5]   3.00-4.00   sec  12.5 MBytes   105 Mbits/sec    0    604 KBytes       
[  5]   4.00-5.00   sec  11.1 MBytes  93.3 Mbits/sec    0    604 KBytes       
[  5]   5.00-6.00   sec  11.4 MBytes  95.4 Mbits/sec    0    604 KBytes       
[  5]   6.00-7.00   sec  11.9 MBytes  99.6 Mbits/sec    0    637 KBytes       
[  5]   7.00-8.00   sec  10.8 MBytes  90.2 Mbits/sec    0    637 KBytes       
[  5]   8.00-9.00   sec  11.8 MBytes  98.6 Mbits/sec    0    637 KBytes       
[  5]   9.00-10.00  sec  12.0 MBytes   101 Mbits/sec    0    722 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec   119 MBytes  99.6 Mbits/sec    0             sender
[  5]   0.00-10.02  sec   116 MBytes  97.2 Mbits/sec                  receiver

iperf Done.

$ iperf3 -c XXXremoteIPv6XXX --reverse
Connecting to host XXXremoteIPv6XXX, port 5201
Reverse mode, remote host XXXremoteIPv6XXX is sending
[  5] local XXXlocalXXX port 58256 connected to XXXremoteIPv6XXX port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  12.6 MBytes   106 Mbits/sec                  
[  5]   1.00-2.00   sec  13.6 MBytes   114 Mbits/sec                  
[  5]   2.00-3.00   sec  14.1 MBytes   118 Mbits/sec                  
[  5]   3.00-4.00   sec  14.0 MBytes   117 Mbits/sec                  
[  5]   4.00-5.00   sec  12.2 MBytes   103 Mbits/sec                  
[  5]   5.00-6.00   sec  14.2 MBytes   120 Mbits/sec                  
[  5]   6.00-7.00   sec  12.5 MBytes   105 Mbits/sec                  
[  5]   7.00-8.00   sec  12.5 MBytes   105 Mbits/sec                  
[  5]   8.00-9.00   sec  13.9 MBytes   116 Mbits/sec                  
[  5]   9.00-10.00  sec  14.1 MBytes   118 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.01  sec   138 MBytes   116 Mbits/sec    0             sender
[  5]   0.00-10.00  sec   134 MBytes   112 Mbits/sec                  receiver

iperf Done.

$ iperf3 -c XXXremoteIPv6XXX --bidir
Connecting to host XXXremoteIPv6XXX, port 5201
[  5] local XXXlocalXXX port 50634 connected to XXXremoteIPv6XXX port 5201
[  7] local XXXlocalXXX port 50646 connected to XXXremoteIPv6XXX port 5201
[ ID][Role] Interval           Transfer     Bitrate         Retr  Cwnd
[  5][TX-C]   0.00-1.00   sec  6.25 MBytes  52.4 Mbits/sec    0    300 KBytes       
[  7][RX-C]   0.00-1.00   sec  7.00 MBytes  58.7 Mbits/sec                  
[  5][TX-C]   1.00-2.00   sec  3.88 MBytes  32.5 Mbits/sec    0    414 KBytes       
[  7][RX-C]   1.00-2.00   sec  10.1 MBytes  84.9 Mbits/sec                  
[  5][TX-C]   2.00-3.00   sec  1.88 MBytes  15.7 Mbits/sec    0    464 KBytes       
[  7][RX-C]   2.00-3.00   sec  12.4 MBytes   104 Mbits/sec                  
[  5][TX-C]   3.00-4.00   sec  1.88 MBytes  15.7 Mbits/sec    0    487 KBytes       
[  7][RX-C]   3.00-4.00   sec  12.2 MBytes   103 Mbits/sec                  
[  5][TX-C]   4.00-5.00   sec  2.38 MBytes  19.9 Mbits/sec    0    582 KBytes       
[  7][RX-C]   4.00-5.00   sec  10.9 MBytes  91.2 Mbits/sec                  
[  5][TX-C]   5.00-6.00   sec  0.00 Bytes  0.00 bits/sec    0    602 KBytes       
[  7][RX-C]   5.00-6.00   sec  10.2 MBytes  86.0 Mbits/sec                  
[  5][TX-C]   6.00-7.00   sec  1.50 MBytes  12.6 Mbits/sec    0    661 KBytes       
[  7][RX-C]   6.00-7.00   sec  10.6 MBytes  89.1 Mbits/sec                  
[  5][TX-C]   7.00-8.00   sec  1.38 MBytes  11.5 Mbits/sec    0    728 KBytes       
[  7][RX-C]   7.00-8.00   sec  11.5 MBytes  96.5 Mbits/sec                  
[  5][TX-C]   8.00-9.00   sec  1.38 MBytes  11.5 Mbits/sec    0    777 KBytes       
[  7][RX-C]   8.00-9.00   sec  10.4 MBytes  87.0 Mbits/sec                  
[  5][TX-C]   9.00-10.00  sec  1.38 MBytes  11.5 Mbits/sec    2    593 KBytes       
[  7][RX-C]   9.00-10.00  sec  11.1 MBytes  93.1 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID][Role] Interval           Transfer     Bitrate         Retr
[  5][TX-C]   0.00-10.00  sec  21.9 MBytes  18.3 Mbits/sec    2             sender
[  5][TX-C]   0.00-10.02  sec  19.5 MBytes  16.3 Mbits/sec                  receiver
[  7][RX-C]   0.00-10.00  sec   110 MBytes  92.7 Mbits/sec    0             sender
[  7][RX-C]   0.00-10.02  sec   106 MBytes  89.2 Mbits/sec                  receiver

iperf Done.

# iw dev wlxXXXlocalMACXXX station dump
Station XXXAP2MACXXX (on wlxXXXlocalMACXXX)
        inactive time:  1 ms
        rx bytes:       819594565
        rx packets:     556734
        tx bytes:       379056249
        tx packets:     427613
        tx retries:     0
        tx failed:      0
        beacon loss:    0
        rx drop misc:   0
        signal:         10 dBm
        signal avg:     -66 dBm
        tx bitrate:     300.0 MBit/s MCS 15 40MHz short GI
        tx duration:    0 us
        rx bitrate:     243.0 MBit/s MCS 14 40MHz
        rx duration:    0 us
        authorized:     yes
        authenticated:  yes
        associated:     yes
        preamble:       long
        WMM/WME:        yes
        MFP:            yes
        TDLS peer:      no
        DTIM period:    3
        beacon interval:100
        short slot time:yes
        connected time: 556 seconds
        associated at [boottime]:       244.363s
        associated at:  1726480574210 ms
        current time:   1726481129874 ms
# iw phy phy1 info
Wiphy phy1
        wiphy index: 1
        max # scan SSIDs: 4
        max scan IEs length: 2257 bytes
        max # sched scan SSIDs: 0
        max # match sets: 0
        RTS threshold: 2347
        Retry short limit: 7
        Retry long limit: 4
        Coverage class: 0 (up to 0m)
        Device supports RSN-IBSS.
        Supported Ciphers:
                * WEP40 (00-0f-ac:1)
                * WEP104 (00-0f-ac:5)
                * TKIP (00-0f-ac:2)
                * CCMP-128 (00-0f-ac:4)
                * CCMP-256 (00-0f-ac:10)
                * GCMP-128 (00-0f-ac:8)
                * GCMP-256 (00-0f-ac:9)
                * CMAC (00-0f-ac:6)
                * CMAC-256 (00-0f-ac:13)
                * GMAC-128 (00-0f-ac:11)
                * GMAC-256 (00-0f-ac:12)
        Available Antennas: TX 0 RX 0
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
        Band 1:
                Capabilities: 0x186e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 7935 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 16 usec (0x07)
                HT Max RX data rate: 300 Mbps
                HT TX/RX MCS rate indexes supported: 0-15, 32
                Bitrates (non-HT):
                        * 1.0 Mbps
                        * 2.0 Mbps
                        * 5.5 Mbps
                        * 11.0 Mbps
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                Frequencies:
                        * 2412.0 MHz [1] (20.0 dBm)
                        * 2417.0 MHz [2] (20.0 dBm)
                        * 2422.0 MHz [3] (20.0 dBm)
                        * 2427.0 MHz [4] (20.0 dBm)
                        * 2432.0 MHz [5] (20.0 dBm)
                        * 2437.0 MHz [6] (20.0 dBm)
                        * 2442.0 MHz [7] (20.0 dBm)
                        * 2447.0 MHz [8] (20.0 dBm)
                        * 2452.0 MHz [9] (20.0 dBm)
                        * 2457.0 MHz [10] (20.0 dBm)
                        * 2462.0 MHz [11] (20.0 dBm)
                        * 2467.0 MHz [12] (20.0 dBm)
                        * 2472.0 MHz [13] (20.0 dBm)
                        * 2484.0 MHz [14] (disabled)
        Band 2:
                Capabilities: 0x186e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 7935 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 16 usec (0x07)
                HT Max RX data rate: 300 Mbps
                HT TX/RX MCS rate indexes supported: 0-15, 32
                Bitrates (non-HT):
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
                Frequencies:
                        * 5180.0 MHz [36] (23.0 dBm)
                        * 5200.0 MHz [40] (23.0 dBm)
                        * 5220.0 MHz [44] (23.0 dBm)
                        * 5240.0 MHz [48] (23.0 dBm)
                        * 5260.0 MHz [52] (20.0 dBm) (no IR, radar detection)
                        * 5280.0 MHz [56] (20.0 dBm) (no IR, radar detection)
                        * 5300.0 MHz [60] (20.0 dBm) (no IR, radar detection)
                        * 5320.0 MHz [64] (20.0 dBm) (no IR, radar detection)
                        * 5500.0 MHz [100] (26.0 dBm) (no IR, radar detection)
                        * 5520.0 MHz [104] (26.0 dBm) (no IR, radar detection)
                        * 5540.0 MHz [108] (26.0 dBm) (no IR, radar detection)
                        * 5560.0 MHz [112] (26.0 dBm) (no IR, radar detection)
                        * 5580.0 MHz [116] (26.0 dBm) (no IR, radar detection)
                        * 5600.0 MHz [120] (26.0 dBm) (no IR, radar detection)
                        * 5620.0 MHz [124] (26.0 dBm) (no IR, radar detection)
                        * 5640.0 MHz [128] (26.0 dBm) (no IR, radar detection)
                        * 5660.0 MHz [132] (26.0 dBm) (no IR, radar detection)
                        * 5680.0 MHz [136] (26.0 dBm) (no IR, radar detection)
                        * 5700.0 MHz [140] (26.0 dBm) (no IR, radar detection)
                        * 5745.0 MHz [149] (13.0 dBm)
                        * 5765.0 MHz [153] (13.0 dBm)
                        * 5785.0 MHz [157] (13.0 dBm)
                        * 5805.0 MHz [161] (13.0 dBm)
                        * 5825.0 MHz [165] (13.0 dBm)
        Supported commands:
                 * new_interface
                 * set_interface
                 * new_key
                 * start_ap
                 * new_station
                 * new_mpath
                 * set_mesh_config
                 * set_bss
                 * authenticate
                 * associate
                 * deauthenticate
                 * disassociate
                 * join_ibss
                 * join_mesh
                 * remain_on_channel
                 * set_tx_bitrate_mask
                 * frame
                 * frame_wait_cancel
                 * set_wiphy_netns
                 * set_channel
                 * probe_client
                 * set_noack_map
                 * register_beacons
                 * start_p2p_device
                 * set_mcast_rate
                 * testmode
                 * connect
                 * disconnect
                 * set_qos_map
                 * set_multicast_to_unicast
        software interface modes (can always be added):
                 * AP/VLAN
                 * monitor
        interface combinations are not supported
        HT Capability overrides:
                 * MCS: ff ff ff ff ff ff ff ff ff ff
                 * maximum A-MSDU length
                 * supported channel width
                 * short GI for 40 MHz
                 * max A-MPDU length exponent
                 * min MPDU start spacing
        Device supports TX status socket option.
        Device supports HT-IBSS.
        Device supports SAE with AUTHENTICATE command
        Device supports low priority scan.
        Device supports scan flush.
        Device supports AP scan.
        Device supports per-vif TX power setting
        Driver supports full state transitions for AP/GO clients
        Driver supports a userspace MPM
        Device supports configuring vdev MAC-addr on create.
        max # scan plans: 1
        max scan plan interval: -1
        max scan plan iterations: 0
        Supported TX frame types:
                 * IBSS: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * managed: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * mesh point: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-client: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-GO: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
                 * P2P-device: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
        Supported RX frame types:
                 * IBSS: 0x40 0xb0 0xc0 0xd0
                 * managed: 0x40 0xb0 0xd0
                 * AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * mesh point: 0xb0 0xc0 0xd0
                 * P2P-client: 0x40 0xd0
                 * P2P-GO: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
                 * P2P-device: 0x40 0xd0
        Supported extended features:
                * [ RRM ]: RRM
                * [ FILS_STA ]: STA FILS (Fast Initial Link Setup)
                * [ CONTROL_PORT_OVER_NL80211 ]: control port over nl80211
                * [ TXQS ]: FQ-CoDel-enabled intermediate TXQs
                * [ SCAN_RANDOM_SN ]: use random sequence numbers in scans
                * [ SCAN_MIN_PREQ_CONTENT ]: use probe request with only rate IEs in scans
                * [ CONTROL_PORT_NO_PREAUTH ]: disable pre-auth over nl80211 control port support
                * [ DEL_IBSS_STA ]: deletion of IBSS station support
                * [ SCAN_FREQ_KHZ ]: scan on kHz frequency support
                * [ CONTROL_PORT_OVER_NL80211_TX_STATUS ]: tx status for nl80211 control port support
                * [ POWERED_ADDR_CHANGE ]: can change MAC address while up

Regards
Stefan Lippers-Hollmann

#25 lore raw
In reply to Bitterblue Smith
Quoted 8 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

Quoted 6 lines

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Tested only with RTL8192DU.

A cover letter is would be really good to have.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#26 lore raw
Quoted 10 lines · Kalle Valo
Quoted 8 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

Quoted 9 lines
Quoted 6 lines

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Tested only with RTL8192DU.

A cover letter is would be really good to have.

I can add one. What should I write in it?

#27 lore raw
Quoted 14 lines · Bitterblue Smith
Quoted 13 lines · Kalle Valo
Quoted 11 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Tested only with RTL8192DU.

A cover letter is would be really good to have.

I can add one. What should I write in it?

Basically just a short (few sentences) introduction what the patchset adds and if there are problematic/broken/todo items, for example in this case that the firmware upload is pending. This info helps the reviewers and also having the cover letters makes the grouping in email applications better.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#28 lore raw
Quoted 22 lines · Kalle Valo
Quoted 20 lines · Bitterblue Smith
Quoted 18 lines · Kalle Valo
Quoted 8 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

Quoted 6 lines

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Tested only with RTL8192DU.

A cover letter is would be really good to have.

Quoted 7 lines
Quoted 1 line

I can add one. What should I write in it?

Basically just a short (few sentences) introduction what the patchset adds and if there are problematic/broken/todo items, for example in this case that the firmware upload is pending. This info helps the reviewers and also having the cover letters makes the grouping in email applications better.

Here's a very good example of a cover letter:

https://patchwork.kernel.org/project/linux-wireless/cover/[email protected]/

The only gripe I have is that the version change log should be in reverse order (v4, v3, v2 instead of v2, v3, v4) but that's just cosmetics.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#29 lore raw
Quoted 32 lines · Kalle Valo
Quoted 22 lines · Kalle Valo
Quoted 20 lines · Bitterblue Smith
Quoted 18 lines · Kalle Valo
Quoted 8 lines · Bitterblue Smith

Create the new module rtl8192d-common and move some code into it from rtl8192de. Now the rtl8192de driver (PCI) and the new rtl8192du driver (USB) can share some of the code.

This is mostly the code that required little effort to make it shareable. There are a few more functions which they could share, with some changes.

Quoted 6 lines

The only other changes in this patch should be adjusting whitespace and renaming some functions.

Tested only with RTL8192DU.

A cover letter is would be really good to have.

Quoted 7 lines
Quoted 1 line

I can add one. What should I write in it?

Basically just a short (few sentences) introduction what the patchset adds and if there are problematic/broken/todo items, for example in this case that the firmware upload is pending. This info helps the reviewers and also having the cover letters makes the grouping in email applications better.

Quoted 8 lines

Here's a very good example of a cover letter:

https://patchwork.kernel.org/project/linux-wireless/cover/[email protected]/

The only gripe I have is that the version change log should be in reverse order (v4, v3, v2 instead of v2, v3, v4) but that's just cosmetics.

Okay, I will send v2 with a cover letter.