wifi: rtw89: usb: read serial_number and uuid via sysfs
Subsystems (2)
Ping-Ke Shih
maintainerv2 cover wifi: rtw89: usb: read serial_number and uuid via sysfs
As what we learned in RFC v1, add sysfs entries
- /sys/class/ieee80211/phy0/rtw89_usb/serial_number
- /sys/class/ieee80211/phy0/rtw89_usb/uuid
These entries only present if specific USB device is in use. We add a quirk as a flag for this.
Above info is fully documented in Documentation/ABI/testing/sysfs-class-ieee80211-rtw89
v2:
- add specific sysfs entries in /sys/class/ieee80211/phy0/rtw89_usb/
* serial_number and uuid
- add Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 to describe ABI
- add sysfs entries by quirk according to specific device ID
- include patch 1/2 which does quirk infrastructure by device ID
v1 (RFC):
- https://lore.kernel.org/linux-wireless/[email protected]/
Johnson Tsai (2):
wifi: rtw89: add dev_id_quirks to driver_info for per-device quirk
control
wifi: rtw89: usb: add serial_number and uuid sysfs attributes for
0x28de:0x2432
.../ABI/testing/sysfs-class-ieee80211-rtw89 | 24 ++++++++ drivers/net/wireless/realtek/rtw89/core.c | 9 ++- drivers/net/wireless/realtek/rtw89/core.h | 10 +++- drivers/net/wireless/realtek/rtw89/pci.c | 3 +- .../net/wireless/realtek/rtw89/rtw8851be.c | 1 + .../net/wireless/realtek/rtw89/rtw8851bu.c | 1 + .../net/wireless/realtek/rtw89/rtw8852ae.c | 1 + .../net/wireless/realtek/rtw89/rtw8852au.c | 1 + .../net/wireless/realtek/rtw89/rtw8852be.c | 1 + .../net/wireless/realtek/rtw89/rtw8852bte.c | 1 + .../net/wireless/realtek/rtw89/rtw8852bu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852c.c | 10 ++++ drivers/net/wireless/realtek/rtw89/rtw8852c.h | 6 +- .../net/wireless/realtek/rtw89/rtw8852ce.c | 1 + .../net/wireless/realtek/rtw89/rtw8852cu.c | 13 +++- .../net/wireless/realtek/rtw89/rtw8922ae.c | 2 + .../net/wireless/realtek/rtw89/rtw8922au.c | 1 + .../net/wireless/realtek/rtw89/rtw8922de.c | 2 + drivers/net/wireless/realtek/rtw89/usb.c | 60 ++++++++++++++++++- 19 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-ieee80211-rtw89
base-commit: 6b964941bbfe6e0f18b1a5e008486dbb62df440a
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v2 1/2 wifi: rtw89: add dev_id_quirks to driver_info for per-device quirk control
From: Johnson Tsai <[email protected]>
Add a dev_id_quirks field to rtw89_driver_info so that per-device (VID/PID) quirks can be expressed independently of chip-level default_quirks. Apply the bitmap in rtw89_alloc_ieee80211_hw() so both USB and PCI probes benefit automatically.
All existing driver_info structs initialize dev_id_quirks to 0; no behavior change.
--- drivers/net/wireless/realtek/rtw89/core.c | 9 +++++++-- drivers/net/wireless/realtek/rtw89/core.h | 4 ++-- drivers/net/wireless/realtek/rtw89/pci.c | 3 +-- drivers/net/wireless/realtek/rtw89/rtw8851be.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8851bu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852ae.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852au.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852be.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852bte.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852bu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852ce.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8852cu.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8922ae.c | 2 ++ drivers/net/wireless/realtek/rtw89/rtw8922au.c | 1 + drivers/net/wireless/realtek/rtw89/rtw8922de.c | 2 ++ drivers/net/wireless/realtek/rtw89/usb.c | 3 +-- 16 files changed, 25 insertions(+), 8 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +7 -2
@@ -7532,9 +7532,11 @@ EXPORT_SYMBOL(rtw89_core_unregister);struct rtw89_dev *rtw89_alloc_ieee80211_hw (struct device *device,u32 bus_data_size, -const struct rtw89_chip_info *chip, -const struct rtw89_chip_variant *variant) +const struct rtw89_driver_info *info) { +const unsigned long *dev_id_quirks = &info->dev_id_quirks; +const struct rtw89_chip_variant *variant = info->variant; +const struct rtw89_chip_info *chip = info->chip;struct rtw89_fw_info early_fw = {};const struct firmware *firmware;struct ieee80211_hw *hw;
@@ -7600,6 +7602,9 @@ struct rtw89_dev *rtw89_alloc_ieee80211_hw(struct device *device, rtwdev->fw.fw_format = fw_format; rtwdev->support_mlo = support_mlo; +bitmap_or (rtwdev->quirks, rtwdev->quirks, dev_id_quirks, +NUM_OF_RTW89_QUIRKS ); +rtw89_debug (rtwdev,RTW89_DBG_CHAN ,"probe driver %s chanctx\n" , no_chanctx ?"without" :"with" ); rtw89_debug(rtwdev, RTW89_DBG_CHAN, "probe driver %s MLO cap\n",
drivers/net/wireless/realtek/rtw89/core.h +2 -2
@@ -4800,6 +4800,7 @@ struct rtw89_driver_info {const struct rtw89_chip_info *chip;const struct rtw89_chip_variant *variant;const struct dmi_system_id *quirks; +unsigned long dev_id_quirks;/* bitmap of rtw89_quirks */ union rtw89_bus_info bus; };
@@ -8126,8 +8127,7 @@ int rtw89_core_register(struct rtw89_dev *rtwdev);void rtw89_core_unregister (struct rtw89_dev *rtwdev);struct rtw89_dev *rtw89_alloc_ieee80211_hw (struct device *device,u32 bus_data_size, -const struct rtw89_chip_info *chip, -const struct rtw89_chip_variant *variant); +const struct rtw89_driver_info *info);void rtw89_free_ieee80211_hw (struct rtw89_dev *rtwdev);u8 rtw89_acquire_mac_id (struct rtw89_dev *rtwdev);void rtw89_release_mac_id (struct rtw89_dev *rtwdev,u8 mac_id);
drivers/net/wireless/realtek/rtw89/pci.c +1 -2
@@ -4772,8 +4772,7 @@ int rtw89_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) info = (const struct rtw89_driver_info *)id->driver_data; rtwdev =rtw89_alloc_ieee80211_hw (&pdev->dev, -sizeof (struct rtw89_pci ), - info->chip, info->variant); +sizeof (struct rtw89_pci ), info);if (!rtwdev) {dev_err (&pdev->dev,"failed to allocate hw\n" );return -ENOMEM ;
drivers/net/wireless/realtek/rtw89/rtw8851be.c +1 -0
@@ -73,6 +73,7 @@ static const struct rtw89_driver_info rtw89_8851be_info = { .chip = &rtw8851b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8851b_pci_info, },
drivers/net/wireless/realtek/rtw89/rtw8851bu.c +1 -0
@@ -31,6 +31,7 @@ static const struct rtw89_driver_info rtw89_8851bu_info = { .chip = &rtw8851b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .usb = &rtw8851b_usb_info, }
drivers/net/wireless/realtek/rtw89/rtw8852ae.c +1 -0
@@ -71,6 +71,7 @@ static const struct rtw89_driver_info rtw89_8852ae_info = { .chip = &rtw8852a_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8852a_pci_info, },
drivers/net/wireless/realtek/rtw89/rtw8852au.c +1 -0
@@ -33,6 +33,7 @@ static const struct rtw89_driver_info rtw89_8852au_info = { .chip = &rtw8852a_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .usb = &rtw8852a_usb_info, }
drivers/net/wireless/realtek/rtw89/rtw8852be.c +1 -0
@@ -73,6 +73,7 @@ static const struct rtw89_driver_info rtw89_8852be_info = { .chip = &rtw8852b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8852b_pci_info, },
drivers/net/wireless/realtek/rtw89/rtw8852bte.c +1 -0
@@ -79,6 +79,7 @@ static const struct rtw89_driver_info rtw89_8852bte_info = { .chip = &rtw8852bt_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8852bt_pci_info, },
drivers/net/wireless/realtek/rtw89/rtw8852bu.c +1 -0
@@ -31,6 +31,7 @@ static const struct rtw89_driver_info rtw89_8852bu_info = { .chip = &rtw8852b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .usb = &rtw8852b_usb_info, }
drivers/net/wireless/realtek/rtw89/rtw8852ce.c +1 -0
@@ -102,6 +102,7 @@ static const struct rtw89_driver_info rtw89_8852ce_info = { .chip = &rtw8852c_chip_info, .variant = NULL, .quirks = rtw8852c_pci_quirks, + .dev_id_quirks = 0, .bus = { .pci = &rtw8852c_pci_info, },
drivers/net/wireless/realtek/rtw89/rtw8852cu.c +1 -0
@@ -33,6 +33,7 @@ static const struct rtw89_driver_info rtw89_8852cu_info = { .chip = &rtw8852c_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .usb = &rtw8852c_usb_info, },
drivers/net/wireless/realtek/rtw89/rtw8922ae.c +2 -0
@@ -77,6 +77,7 @@ static const struct rtw89_driver_info rtw89_8922ae_info = { .chip = &rtw8922a_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8922a_pci_info, },
@@ -86,6 +87,7 @@ static const struct rtw89_driver_info rtw89_8922ae_vs_info = { .chip = &rtw8922a_chip_info, .variant = &rtw8922ae_vs_variant, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8922a_pci_info, },
drivers/net/wireless/realtek/rtw89/rtw8922au.c +1 -0
@@ -32,6 +32,7 @@ static const struct rtw89_driver_info rtw89_8922au_info = { .chip = &rtw8922a_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .usb = &rtw8922a_usb_info, },
drivers/net/wireless/realtek/rtw89/rtw8922de.c +2 -0
@@ -73,6 +73,7 @@ static const struct rtw89_driver_info rtw89_8922de_vs_info = { .chip = &rtw8922d_chip_info, .variant = &rtw8922de_vs_variant, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8922d_pci_info, },
@@ -82,6 +83,7 @@ static const struct rtw89_driver_info rtw89_8922de_info = { .chip = &rtw8922d_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0, .bus = { .pci = &rtw8922d_pci_info, },
drivers/net/wireless/realtek/rtw89/usb.c +1 -2
@@ -1070,8 +1070,7 @@ int rtw89_usb_probe(struct usb_interface *intf, info = (const struct rtw89_driver_info *)id->driver_info; rtwdev =rtw89_alloc_ieee80211_hw (&intf->dev, -sizeof (struct rtw89_usb ), - info->chip, info->variant); +sizeof (struct rtw89_usb ), info);if (!rtwdev) {dev_err (&intf->dev,"failed to allocate hw\n" );return -ENOMEM ;
Signature · 1 line
2.25.1
Ping-Ke Shih
maintainerPATCH v2 2/2 wifi: rtw89: usb: add serial_number and uuid sysfs attributes for 0x28de:0x2432
In reply to Ping-Ke ShihFrom: Johnson Tsai <[email protected]>
Expose the device's Serial Number (SN) and UUID from EFUSE via two read-only sysfs attributes, serial_number and uuid, on the ieee80211 phy device under the rtw89_usb attribute group.
This hardware identification information is essential for user-space applications to uniquely identify, track, and manage specific Wi-Fi adapters. For example, in automated factory provisioning or device management systems, user-space tools rely on the EFUSE serial number and UUID to bind configurations to specific physical adapters. Currently, standard wireless APIs do not expose this low-level hardware information, making these sysfs nodes the only viable solution for user space to extract this data.
The attributes are gated behind a new RTW89_QUIRK_HW_INFO_SYSFS quirk, enabled only for the VID 0x28de / PID 0x2432 device via the dev_id_quirks field in rtw89_driver_info.
Example usage from user-space:
$ cat /sys/class/ieee80211/phy0/rtw89_usb/serial_number 3642000123 $ cat /sys/class/ieee80211/phy0/rtw89_usb/uuid aaec2b7c-0a55-4727-8de0-b30febccbbaa
--- .../ABI/testing/sysfs-class-ieee80211-rtw89 | 24 ++++++++ drivers/net/wireless/realtek/rtw89/core.h | 6 ++ drivers/net/wireless/realtek/rtw89/rtw8852c.c | 10 ++++ drivers/net/wireless/realtek/rtw89/rtw8852c.h | 6 +- .../net/wireless/realtek/rtw89/rtw8852cu.c | 12 +++- drivers/net/wireless/realtek/rtw89/usb.c | 57 +++++++++++++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-ieee80211-rtw89
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +24 -0
@@ -0,0 +1,24 @@ +What: /sys/class/ieee80211/phyX/rtw89_usb/serial_number +Date: May 2026 +Contact: Johnson Tsai <[email protected]>, [email protected] +Description: (Read) Serial number burned into EFUSE of the RTL8852CU-based + USB Wi-Fi adapter. Only present on devices that set the + RTW89_QUIRK_HW_INFO_SYSFS quirk (currently VID 0x28de / + PID 0x2432). + + Format: %10phN (5 raw bytes printed as 10 lowercase hex + digits, no separators). + + Example: 3642000123 + +What: /sys/class/ieee80211/phyX/rtw89_usb/uuid +Date: May 2026 +Contact: Johnson Tsai <[email protected]>, [email protected] +Description: (Read) UUID burned into EFUSE of the RTL8852CU-based USB Wi-Fi + adapter. Only present on devices that set the + RTW89_QUIRK_HW_INFO_SYSFS quirk (currently VID 0x28de / + PID 0x2432). + + Format: %pUb (RFC 4122 UUID in lowercase with hyphens). + + Example: aaec2b7c-0a55-4727-8de0-b30febccbbaa
drivers/net/wireless/realtek/rtw89/core.h +6 -0
@@ -3615,6 +3615,9 @@ struct rtw89_sta_link { u32 data_tx_cnt_lmt:6; }; +#define RTW89_EFUSE_SN_LEN 5 +#define RTW89_EFUSE_UUID_LEN 16 +struct rtw89_efuse {bool valid;bool power_k_valid;
@@ -3625,6 +3628,8 @@ struct rtw89_efuse {u8 adc_td;u8 bt_setting_2;u8 bt_setting_3; +u8 sn[RTW89_EFUSE_SN_LEN ]; +u8 uuid[RTW89_EFUSE_UUID_LEN ]; };struct rtw89_phy_rate_pattern {
@@ -5373,6 +5378,7 @@ enum rtw89_quirks {RTW89_QUIRK_PCI_BER ,RTW89_QUIRK_THERMAL_PROT_120C ,RTW89_QUIRK_THERMAL_PROT_110C , +RTW89_QUIRK_HW_INFO_SYSFS , NUM_OF_RTW89_QUIRKS, };
drivers/net/wireless/realtek/rtw89/rtw8852c.c +10 -0
@@ -621,6 +621,15 @@ static void rtw8852c_efuse_parsing_gain_offset(struct rtw89_dev *rtwdev, gain->offset_valid = valid; } +static void rtw8852c_efuse_copy_sn_uuid_usb (struct rtw89_dev *rtwdev, +const struct rtw8852c_efuse *map) +{ +struct rtw89_efuse *efuse = &rtwdev->efuse; + +memcpy (efuse->sn, map->u.sn,sizeof (efuse->sn)); +memcpy (efuse->uuid, map->u.uuid,sizeof (efuse->uuid)); +} +static int rtw8852c_read_efuse (struct rtw89_dev *rtwdev,u8 *log_map,enum rtw89_efuse_block block) {
@@ -640,6 +649,7 @@ static int rtw8852c_read_efuse(struct rtw89_dev *rtwdev, u8 *log_map,break ;case RTW89_HCI_TYPE_USB :ether_addr_copy (efuse->addr, map->u.mac_addr); +rtw8852c_efuse_copy_sn_uuid_usb (rtwdev, map);break ;default :return -ENOTSUPP ;
drivers/net/wireless/realtek/rtw89/rtw8852c.h +5 -1
@@ -13,7 +13,11 @@struct rtw8852c_u_efuse {u8 rsvd[0x88 ];u8 mac_addr[ETH_ALEN ]; -}; +u8 rsvd1[8 ]; +u8 sn[RTW89_EFUSE_SN_LEN ]; +u8 rsvd2[29 ]; +u8 uuid[RTW89_EFUSE_UUID_LEN ]; +} __packed;struct rtw8852c_e_efuse {u8 mac_addr[ETH_ALEN ];
drivers/net/wireless/realtek/rtw89/rtw8852cu.c +11 -1
@@ -39,6 +39,16 @@ static const struct rtw89_driver_info rtw89_8852cu_info = { }, }; +static const struct rtw89_driver_info rtw89_8852cu_valve_info = { + .chip = &rtw8852c_chip_info, + .variant =NULL , + .quirks =NULL , + .dev_id_quirks =BIT (RTW89_QUIRK_HW_INFO_SYSFS ), + .bus = { + .usb = &rtw8852c_usb_info, + }, +}; +static const struct usb_device_id rtw_8852cu_id_table[] = { {USB_DEVICE_AND_INTERFACE_INFO (0x0411 ,0x03a6 ,0xff ,0xff ,0xff ), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info },
@@ -53,7 +63,7 @@ static const struct usb_device_id rtw_8852cu_id_table[] = { { USB_DEVICE_AND_INTERFACE_INFO(0x0db0, 0x991d, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x28de, 0x2432, 0xff, 0xff, 0xff), - .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, + .driver_info = (kernel_ulong_t)&rtw89_8852cu_valve_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x8206, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x35b2, 0x0502, 0xff, 0xff, 0xff),
drivers/net/wireless/realtek/rtw89/usb.c +57 -0
75 lines not on this page · raw message
Signature · 1 line
2.25.1
Greg KH
maintainerRe: [PATCH v2 rtw-next 1/2] wifi: rtw89: add dev_id_quirks to driver_info for per-device quirk control
In reply to Ping-Ke Shihdrivers/net/wireless/realtek/rtw89/rtw8851be.c static const struct rtw89_driver_info rtw89_8851be_info = { · line 76
Quoted 7 lines · Ping-Ke Shih
drivers/net/wireless/realtek/rtw89/rtw8851be.c +1
-0@@ -73,6 +73,7 @@ static const struct rtw89_driver_info rtw89_8851be_info = { .chip = &rtw8851b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0,
Why are you manually adding a "= 0" for these when that's the default? No need to do so, only do it when it is set to something, right?
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH v2 rtw-next 2/2] wifi: rtw89: usb: add serial_number and uuid sysfs attributes for 0x28de:0x2432
In reply to Ping-Ke ShihQuoted 219 lines · Ping-Ke Shih
From: Johnson Tsai <[email protected]>
Expose the device's Serial Number (SN) and UUID from EFUSE via two read-only sysfs attributes,
serial_numberanduuid, on the ieee80211 phy device under thertw89_usbattribute group.This hardware identification information is essential for user-space applications to uniquely identify, track, and manage specific Wi-Fi adapters. For example, in automated factory provisioning or device management systems, user-space tools rely on the EFUSE serial number and UUID to bind configurations to specific physical adapters. Currently, standard wireless APIs do not expose this low-level hardware information, making these sysfs nodes the only viable solution for user space to extract this data.
The attributes are gated behind a new
RTW89_QUIRK_HW_INFO_SYSFSquirk, enabled only for the VID0x28de/ PID0x2432device via thedev_id_quirksfield inrtw89_driver_info.Example usage from user-space:
$ cat /sys/class/ieee80211/phy0/rtw89_usb/serial_number 3642000123 $ cat /sys/class/ieee80211/phy0/rtw89_usb/uuid aaec2b7c-0a55-4727-8de0-b30febccbbaaCc Elliot Saba <[email protected]>Cc Charles Lohr <[email protected]>Signed-off-by Johnson Tsai <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>--- .../ABI/testing/sysfs-class-ieee80211-rtw89 | 24 ++++++++ drivers/net/wireless/realtek/rtw89/core.h | 6 ++ drivers/net/wireless/realtek/rtw89/rtw8852c.c | 10 ++++ drivers/net/wireless/realtek/rtw89/rtw8852c.h | 6 +- .../net/wireless/realtek/rtw89/rtw8852cu.c | 12 +++- drivers/net/wireless/realtek/rtw89/usb.c | 57 +++++++++++++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-class-ieee80211-rtw89Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +24
-0@@ -0,0 +1,24 @@ +What: /sys/class/ieee80211/phyX/rtw89_usb/serial_number +Date: May 2026 +Contact: Johnson Tsai <[email protected]>, [email protected] +Description: (Read) Serial number burned into EFUSE of the RTL8852CU-based + USB Wi-Fi adapter. Only present on devices that set the + RTW89_QUIRK_HW_INFO_SYSFS quirk (currently VID 0x28de / + PID 0x2432). + + Format: %10phN (5 raw bytes printed as 10 lowercase hex + digits, no separators). + + Example: 3642000123 + +What: /sys/class/ieee80211/phyX/rtw89_usb/uuid +Date: May 2026 +Contact: Johnson Tsai <[email protected]>, [email protected] +Description: (Read) UUID burned into EFUSE of the RTL8852CU-based USB Wi-Fi + adapter. Only present on devices that set the + RTW89_QUIRK_HW_INFO_SYSFS quirk (currently VID 0x28de / + PID 0x2432). + + Format: %pUb (RFC 4122 UUID in lowercase with hyphens). + + Example: aaec2b7c-0a55-4727-8de0-b30febccbbaadrivers/net/wireless/realtek/rtw89/core.h +6
-0@@ -3615,6 +3615,9 @@ struct rtw89_sta_link { u32 data_tx_cnt_lmt:6; }; +#define RTW89_EFUSE_SN_LEN 5 +#define RTW89_EFUSE_UUID_LEN 16 +struct rtw89_efuse {bool valid;bool power_k_valid;@@ -3625,6 +3628,8 @@ struct rtw89_efuse {u8 adc_td;u8 bt_setting_2;u8 bt_setting_3; +u8 sn[RTW89_EFUSE_SN_LEN ]; +u8 uuid[RTW89_EFUSE_UUID_LEN ]; };struct rtw89_phy_rate_pattern {@@ -5373,6 +5378,7 @@ enum rtw89_quirks {RTW89_QUIRK_PCI_BER ,RTW89_QUIRK_THERMAL_PROT_120C ,RTW89_QUIRK_THERMAL_PROT_110C , +RTW89_QUIRK_HW_INFO_SYSFS , NUM_OF_RTW89_QUIRKS, };drivers/net/wireless/realtek/rtw89/rtw8852c.c +10
-0@@ -621,6 +621,15 @@ static void rtw8852c_efuse_parsing_gain_offset(struct rtw89_dev *rtwdev, gain->offset_valid = valid; } +static void rtw8852c_efuse_copy_sn_uuid_usb (struct rtw89_dev *rtwdev, +const struct rtw8852c_efuse *map) +{ +struct rtw89_efuse *efuse = &rtwdev->efuse; + +memcpy (efuse->sn, map->u.sn,sizeof (efuse->sn)); +memcpy (efuse->uuid, map->u.uuid,sizeof (efuse->uuid)); +} +static int rtw8852c_read_efuse (struct rtw89_dev *rtwdev,u8 *log_map,enum rtw89_efuse_block block) {@@ -640,6 +649,7 @@ static int rtw8852c_read_efuse(struct rtw89_dev *rtwdev, u8 *log_map,break ;case RTW89_HCI_TYPE_USB :ether_addr_copy (efuse->addr, map->u.mac_addr); +rtw8852c_efuse_copy_sn_uuid_usb (rtwdev, map);break ;default :return -ENOTSUPP ;drivers/net/wireless/realtek/rtw89/rtw8852c.h +5
-1@@ -13,7 +13,11 @@struct rtw8852c_u_efuse {u8 rsvd[0x88 ];u8 mac_addr[ETH_ALEN ]; -}; +u8 rsvd1[8 ]; +u8 sn[RTW89_EFUSE_SN_LEN ]; +u8 rsvd2[29 ]; +u8 uuid[RTW89_EFUSE_UUID_LEN ]; +} __packed;struct rtw8852c_e_efuse {u8 mac_addr[ETH_ALEN ];drivers/net/wireless/realtek/rtw89/rtw8852cu.c +11
-1@@ -39,6 +39,16 @@ static const struct rtw89_driver_info rtw89_8852cu_info = { }, }; +static const struct rtw89_driver_info rtw89_8852cu_valve_info = { + .chip = &rtw8852c_chip_info, + .variant =NULL , + .quirks =NULL , + .dev_id_quirks =BIT (RTW89_QUIRK_HW_INFO_SYSFS ), + .bus = { + .usb = &rtw8852c_usb_info, + }, +}; +static const struct usb_device_id rtw_8852cu_id_table[] = { {USB_DEVICE_AND_INTERFACE_INFO (0x0411 ,0x03a6 ,0xff ,0xff ,0xff ), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info },@@ -53,7 +63,7 @@ static const struct usb_device_id rtw_8852cu_id_table[] = { { USB_DEVICE_AND_INTERFACE_INFO(0x0db0, 0x991d, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x28de, 0x2432, 0xff, 0xff, 0xff), - .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, + .driver_info = (kernel_ulong_t)&rtw89_8852cu_valve_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x2c7c, 0x8206, 0xff, 0xff, 0xff), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x35b2, 0x0502, 0xff, 0xff, 0xff),drivers/net/wireless/realtek/rtw89/usb.c +36
-0@@ -1059,6 +1059,61 @@ static void rtw89_usb_intf_deinit(struct rtw89_dev *rtwdev,usb_set_intfdata (intf,NULL ); } +static ssize_t serial_number_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ + struct wiphy *wiphy = container_of(dev, struct wiphy, dev); +struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy); +struct rtw89_dev *rtwdev = hw->priv; +struct rtw89_efuse *efuse = &rtwdev->efuse; + +return sysfs_emit (buf,"%*phN\n" , + (int )sizeof (efuse->sn), efuse->sn); +} +static DEVICE_ATTR_RO (serial_number); + +static ssize_t uuid_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ + struct wiphy *wiphy = container_of(dev, struct wiphy, dev); +struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy); +struct rtw89_dev *rtwdev = hw->priv; +struct rtw89_efuse *efuse = &rtwdev->efuse; + +return sysfs_emit (buf,"%pUb\n" , efuse->uuid); +} +static DEVICE_ATTR_RO (uuid); + +static struct attribute *rtw89_usb_attrs[] = { + &dev_attr_serial_number.attr, + &dev_attr_uuid.attr, +NULL , +}; + +static const struct attribute_group rtw89_usb_group = { + .name ="rtw89_usb" , + .attrs = rtw89_usb_attrs, +}; +__ATTRIBUTE_GROUPS (rtw89_usb);
drivers/net/wireless/realtek/rtw89/usb.c static void rtw89_usb_intf_deinit(struct rtw89_dev *rtwdev, · line 1107
Quoted 10 lines
drivers/net/wireless/realtek/rtw89/usb.c +10
-0+ +static void rtw89_usb_sysfs_create (struct rtw89_dev *rtwdev) +{ +int ret; + +if (!test_bit (RTW89_QUIRK_HW_INFO_SYSFS , rtwdev->quirks)) +return ; + + ret =sysfs_create_groups (&rtwdev->hw->wiphy->dev.kobj, + rtw89_usb_groups);
You just raced with userspace and lost, please use the is_visable callback instead, and make this the default group attributes.
thanks,
greg k-h
Ping-Ke Shih
maintainerRE: [PATCH v2 rtw-next 1/2] wifi: rtw89: add dev_id_quirks to driver_info for per-device quirk control
In reply to Greg KHQuoted 11 lines · Greg KH
drivers/net/wireless/realtek/rtw89/rtw8851be.c static const struct rtw89_driver_info rtw89_8851be_info = { · line 76
Quoted 7 lines · Ping-Ke Shih
drivers/net/wireless/realtek/rtw89/rtw8851be.c +1
-0@@ -73,6 +73,7 @@ static const struct rtw89_driver_info rtw89_8851be_info = { .chip = &rtw8851b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0,Why are you manually adding a "= 0" for these when that's the default? No need to do so, only do it when it is set to something, right?
I'd ask authors spending a little time to fill these default values because Realtek WiFi chips have many specific attributes for many chips, and somehow it gets messed. For example,
- miss to fill value for a certain chip
(people might only force on one chip he wants to fix)
- for some cases, it should set 0 explicitly as the value
(such as a threshold value of hardware register)
- messed up the order of attributes
People add a field along the existing field across all chips. If a field is omitted, somehow people might add the field at wrong place.
- simply coding rule
People might forget why, so I'd have a simple rule for them.
I encountered these cases when I processed earlier Realtek WiFi drivers (rtlwifi, rtl8xxxu, rtw88), so I'd explicitly fill values to avoid them.
Thanks
Ping-Ke
RE: [PATCH v2 rtw-next 2/2] wifi: rtw89: usb: add serial_number and uuid sysfs attributes for 0x28de:0x2432
In reply to Greg KHQuoted 234 lines · Greg KH
Quoted 15 lines · Ping-Ke Shih
From: Johnson Tsai <[email protected]>
Expose the device's Serial Number (SN) and UUID from EFUSE via two read-only sysfs attributes,
serial_numberanduuid, on the ieee80211 phy device under thertw89_usbattribute group.This hardware identification information is essential for user-space applications to uniquely identify, track, and manage specific Wi-Fi adapters. For example, in automated factory provisioning or device management systems, user-space tools rely on the EFUSE serial number and UUID to bind configurations to specific physical adapters. Currently, standard wireless APIs do not expose this low-level hardware information, making these sysfs nodes the only viable solution for user space to extract this data.
Quoted 1 line
The attributes are gated behind a new
RTW89_QUIRK_HW_INFO_SYSFSquirk,
Quoted 30 lines
enabled only for the VID
0x28de/ PID0x2432device via thedev_id_quirksfield inrtw89_driver_info.Example usage from user-space:
$ cat /sys/class/ieee80211/phy0/rtw89_usb/serial_number 3642000123 $ cat /sys/class/ieee80211/phy0/rtw89_usb/uuid aaec2b7c-0a55-4727-8de0-b30febccbbaaCc Elliot Saba <[email protected]>Cc Charles Lohr <[email protected]>Signed-off-by Johnson Tsai <[email protected]>Signed-off-by Ping-Ke Shih <[email protected]>--- .../ABI/testing/sysfs-class-ieee80211-rtw89 | 24 ++++++++ drivers/net/wireless/realtek/rtw89/core.h | 6 ++ drivers/net/wireless/realtek/rtw89/rtw8852c.c | 10 ++++ drivers/net/wireless/realtek/rtw89/rtw8852c.h | 6 +- .../net/wireless/realtek/rtw89/rtw8852cu.c | 12 +++- drivers/net/wireless/realtek/rtw89/usb.c | 57 +++++++++++++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode100644
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +0
-0Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 line 3
Quoted 3 lines
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +3
-0@@ -0,0 +1,24 @@ +What: /sys/class/ieee80211/phyX/rtw89_usb/serial_number +Date: May 2026 +Contact: Johnson Tsai <[email protected]>, linux-Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 line 4
Quoted 1 line
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +1
-0+Description: (Read) Serial number burned into EFUSE of the RTL8852CU-based
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89
Quoted 12 lines
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +12
-0+ USB Wi-Fi adapter. Only present on devices that set the + RTW89_QUIRK_HW_INFO_SYSFS quirk (currently VID 0x28de / + PID 0x2432). + + Format: %10phN (5 raw bytes printed as 10 lowercase hex + digits, no separators). + + Example: 3642000123 + +What: /sys/class/ieee80211/phyX/rtw89_usb/uuid +Date: May 2026 +Contact: Johnson Tsai <[email protected]>, linux-Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 line 17
Quoted 1 line
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +1
-0+Description: (Read) UUID burned into EFUSE of the RTL8852CU-based USBWi-Fi
drivers/net/wireless/realtek/rtw89/rtw8852c.c static void
Quoted 45 lines
Documentation/ABI/testing/sysfs-class-ieee80211-rtw89 new file +7
-0+ adapter. Only present on devices that set the + RTW89_QUIRK_HW_INFO_SYSFS quirk (currently VID 0x28de / + PID 0x2432). + + Format: %pUb (RFC 4122 UUID in lowercase with hyphens). + + Example: aaec2b7c-0a55-4727-8de0-b30febccbbaadrivers/net/wireless/realtek/rtw89/core.h +6
-0@@ -3615,6 +3615,9 @@ struct rtw89_sta_link { u32 data_tx_cnt_lmt:6; }; +#define RTW89_EFUSE_SN_LEN 5 +#define RTW89_EFUSE_UUID_LEN 16 +struct rtw89_efuse {bool valid;bool power_k_valid;@@ -3625,6 +3628,8 @@ struct rtw89_efuse {u8 adc_td;u8 bt_setting_2;u8 bt_setting_3; +u8 sn[RTW89_EFUSE_SN_LEN ]; +u8 uuid[RTW89_EFUSE_UUID_LEN ]; };struct rtw89_phy_rate_pattern {@@ -5373,6 +5378,7 @@ enum rtw89_quirks {RTW89_QUIRK_PCI_BER ,RTW89_QUIRK_THERMAL_PROT_120C ,RTW89_QUIRK_THERMAL_PROT_110C , +RTW89_QUIRK_HW_INFO_SYSFS , NUM_OF_RTW89_QUIRKS, };drivers/net/wireless/realtek/rtw89/rtw8852c.c +0
-0@@ -621,6 +621,15 @@ static voidrtw8852c_efuse_parsing_gain_offset(struct
rtw89_dev*rtwdev,Quoted 4 lines
drivers/net/wireless/realtek/rtw89/rtw8852c.c +1
-0gain->offset_valid = valid; } +static void rtw8852c_efuse_copy_sn_uuid_usb(struct rtw89_dev *rtwdev,drivers/net/wireless/realtek/rtw89/rtw8852c.c static void rtw8852c_efuse_parsing_gain_offset(struct rtw89_dev *rtwdev,
Quoted 10 lines
drivers/net/wireless/realtek/rtw89/rtw8852c.c +7
-1+const struct rtw8852c_efuse +*map) { +struct rtw89_efuse *efuse = &rtwdev->efuse; + +memcpy (efuse->sn, map->u.sn,sizeof (efuse->sn)); +memcpy (efuse->uuid, map->u.uuid,sizeof (efuse->uuid)); } +static int rtw8852c_read_efuse (struct rtw89_dev *rtwdev,u8 *log_map, enum rtw89_efuse_block block) { @@ -640,6 +649,7 @@ static int rtw8852c_read_efuse(struct rtw89_dev*rtwdev, u8
*log_map,drivers/net/wireless/realtek/rtw89/rtw8852cu.c static const struct rtw89_driver_info
Quoted 31 lines
drivers/net/wireless/realtek/rtw89/rtw8852c.c +1
-0break ;case RTW89_HCI_TYPE_USB :ether_addr_copy (efuse->addr, map->u.mac_addr); +rtw8852c_efuse_copy_sn_uuid_usb (rtwdev, map);break ;default :return -ENOTSUPP ;drivers/net/wireless/realtek/rtw89/rtw8852c.h +5
-1@@ -13,7 +13,11 @@struct rtw8852c_u_efuse {u8 rsvd[0x88 ];u8 mac_addr[ETH_ALEN ]; -}; +u8 rsvd1[8 ]; +u8 sn[RTW89_EFUSE_SN_LEN ]; +u8 rsvd2[29 ]; +u8 uuid[RTW89_EFUSE_UUID_LEN ]; +} __packed;struct rtw8852c_e_efuse {u8 mac_addr[ETH_ALEN ];drivers/net/wireless/realtek/rtw89/rtw8852cu.c +0
-0@@ -39,6 +39,16 @@ static const struct rtw89_driver_info
rtw89_8852cu_info= {drivers/net/wireless/realtek/rtw89/usb.c static void rtw89_usb_intf_deinit(struct
Quoted 31 lines
drivers/net/wireless/realtek/rtw89/rtw8852cu.c +12
-1}, }; +static const struct rtw89_driver_info rtw89_8852cu_valve_info = { + .chip = &rtw8852c_chip_info, + .variant =NULL , + .quirks =NULL , + .dev_id_quirks =BIT (RTW89_QUIRK_HW_INFO_SYSFS ), + .bus = { + .usb = &rtw8852c_usb_info, + }, +}; +static const struct usb_device_id rtw_8852cu_id_table[] = { {USB_DEVICE_AND_INTERFACE_INFO (0x0411 ,0x03a6 ,0xff ,0xff ,0xff ), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, @@ -53,7 +63,7 @@ static const struct usb_device_id rtw_8852cu_id_table[] = { {USB_DEVICE_AND_INTERFACE_INFO (0x0db0 ,0x991d ,0xff ,0xff ,0xff ), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, {USB_DEVICE_AND_INTERFACE_INFO (0x28de ,0x2432 ,0xff ,0xff ,0xff ), - .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, + .driver_info = (kernel_ulong_t)&rtw89_8852cu_valve_info }, {USB_DEVICE_AND_INTERFACE_INFO (0x2c7c ,0x8206 ,0xff ,0xff ,0xff ), .driver_info = (kernel_ulong_t)&rtw89_8852cu_info }, { USB_DEVICE_AND_INTERFACE_INFO(0x35b2, 0x0502, 0xff, 0xff,
0xff), diff --gita/drivers/net/wireless/realtek/rtw89/usb.cb/drivers/net/wireless/realtek/rtw89/usb.c
index88d7ec200837..7e23d0a32025100644drivers/net/wireless/realtek/rtw89/usb.c +0
-0@@ -1059,6 +1059,61 @@ static void rtw89_usb_intf_deinit(struct
rtw89_dev*rtwdev,Quoted 40 lines
drivers/net/wireless/realtek/rtw89/usb.c +37
-0usb_set_intfdata (intf,NULL ); } +static ssize_t serial_number_show (struct device *dev, +struct device_attribute *attr,char +*buf) { + struct wiphy *wiphy = container_of(dev, struct wiphy, dev); +struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy); +struct rtw89_dev *rtwdev = hw->priv; +struct rtw89_efuse *efuse = &rtwdev->efuse; + +return sysfs_emit (buf,"%*phN\n" , + (int )sizeof (efuse->sn), efuse->sn); }static +DEVICE_ATTR_RO (serial_number); + +static ssize_t uuid_show (struct device *dev, +struct device_attribute *attr,char *buf) { + struct wiphy *wiphy = container_of(dev, struct wiphy, dev); +struct ieee80211_hw *hw =wiphy_to_ieee80211_hw (wiphy); +struct rtw89_dev *rtwdev = hw->priv; +struct rtw89_efuse *efuse = &rtwdev->efuse; + +return sysfs_emit (buf,"%pUb\n" , efuse->uuid); }static +DEVICE_ATTR_RO (uuid); + +static struct attribute *rtw89_usb_attrs[] = { + &dev_attr_serial_number.attr, + &dev_attr_uuid.attr, +NULL , +}; + +static const struct attribute_group rtw89_usb_group = { + .name ="rtw89_usb" , + .attrs = rtw89_usb_attrs, +}; +__ATTRIBUTE_GROUPS (rtw89_usb); + +static void rtw89_usb_sysfs_create (struct rtw89_dev *rtwdev) { +int ret; +
Quoted 8 lines
drivers/net/wireless/realtek/rtw89/usb.c static void rtw89_usb_intf_deinit(struct rtw89_dev *rtwdev, · line 1107
Quoted 5 lines
drivers/net/wireless/realtek/rtw89/usb.c +5
-0+if (!test_bit (RTW89_QUIRK_HW_INFO_SYSFS , rtwdev->quirks)) +return ; + + ret =sysfs_create_groups (&rtwdev->hw->wiphy->dev.kobj, + rtw89_usb_groups);You just raced with userspace and lost, please use the
is_visablecallback instead, and make this the default group attributes.
Thanks for the explanation.
I see the problem now. The user space sysfs path remains identical, but the timing and mechanism are different. Using dev.kobj requires manual creation/removal outside the hardware lifecycle, whereas setting dev.groups will automatically handle creation/removal within the same hardware lifecycle to avoid the race condition.
I will remove the manual sysfs creation and switch to default group attributes in v3.
Specifically, the visibility of the entire group will be managed via the macro:
/* Control the visibility of the entire attribute group */ .is_visible = SYSFS_GROUP_VISIBLE(rtw89_usb),
And the group will be attached to the wiphy device default groups before registration:
/* Attach the attribute group to the wiphy device */
rtwdev->hw->wiphy->dev.groups = rtw89_usb_groups;Thanks,
Johnson
RE: [PATCH v2 rtw-next 1/2] wifi: rtw89: add dev_id_quirks to driver_info for per-device quirk control
In reply to Ping-Ke ShihQuoted 27 lines · Ping-Ke Shih
Quoted 4 lines · Greg KH
drivers/net/wireless/realtek/rtw89/rtw8851be.c static const struct rtw89_driver_info
Quoted 3 lines · Ping-Ke Shih
drivers/net/wireless/realtek/rtw89/rtw8851be.c +0
-0@@ -73,6 +73,7 @@ static const struct rtw89_driver_info
rtw89_8851be_info= {Quoted 7 lines
drivers/net/wireless/realtek/rtw89/rtw8851be.c static const struct rtw89_driver_info rtw89_8851be_info = { · line 76
Quoted 4 lines
drivers/net/wireless/realtek/rtw89/rtw8851be.c +1
-0.chip = &rtw8851b_chip_info, .variant = NULL, .quirks = NULL, + .dev_id_quirks = 0,Why are you manually adding a "= 0" for these when that's the default? No need to do so, only do it when it is set to something, right?
I'd ask authors spending a little time to fill these default values because Realtek WiFi chips have many specific attributes for many chips, and somehow it gets messed. For example,
- miss to fill value for a certain chip
(people might only force on one chip he wants to fix)
- for some cases, it should set 0 explicitly as the value
(such as a threshold value of hardware register)
- messed up the order of attributes
People add a field along the existing field across all chips. If a field is omitted, somehow people might add the field at wrong place.
- simply coding rule
People might forget why, so I'd have a simple rule for them.
Quoted 3 lines
I encountered these cases when I processed earlier Realtek WiFi drivers (rtlwifi, rtl8xxxu, rtw88), so I'd explicitly fill values to avoid them.
Just a gentle follow-up on Ping-Ke's explanation regarding the explicit "= 0" initialization.
If there are no further concerns on this, I will keep the current approach for this part and send out the v3 patch.
Thanks,
Johnson