realtekwifi8187: Add BSD urtw driver

Add urtw network driver from FreeBSD 15.
Supports RTL8187B/L USB IEEE 802.11b/g devices.
Adds support for the following USB wifi devices (from urtw man page):

Belkin F5D7050E
Linksys WUSB54GCv2
Netgear WG111v2
Netgear WG111v3
Safehome WLG-1500SMA5
Shuttle XPC Accessory PN20
Sitecom WL168v1
Sitecom WL168v4
SureCom EP-9001-g(2A)
TRENDnet TEW-424UB

This has been successfully tested with a WG111v2 54 Mbps Wireless [RealTek RTL8187L] usb dongle.

Change-Id: I90717292a03b1a92c4346ecd6c9b8f3e1470e0cd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10977
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Nathan Patrizi
2026-05-14 19:52:21 +00:00
committed by waddlesplash
parent 44db3b4909
commit 600d6fe7fc
8 changed files with 5106 additions and 0 deletions
+1
View File
@@ -327,6 +327,7 @@ SYSTEM_ADD_ONS_DRIVERS_NET += [ FFilterByBuildFeatures
marvell88w8335 marvell88w8335
ralinkwifi ralinkwifi
realtekwifi realtekwifi
realtekwifi8187
zydwifi1211 zydwifi1211
}@ # x86,x86_64,riscv64 }@ # x86,x86_64,riscv64
] ; ] ;
@@ -12,6 +12,7 @@ SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8335 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan marvell88w8363 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan ralinkwifi ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan realtekwifi ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan realtekwifi ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan realtekwifi8187 ;
SubInclude HAIKU_TOP src add-ons kernel drivers network wlan zydwifi1211 ; SubInclude HAIKU_TOP src add-ons kernel drivers network wlan zydwifi1211 ;
# OpenBSD drivers # OpenBSD drivers
@@ -0,0 +1,27 @@
SubDir HAIKU_TOP src add-ons kernel drivers network wlan realtekwifi8187 ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ;
UsePrivateHeaders net system ;
UsePrivateKernelHeaders ;
SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ]
-Wno-format -Wno-unused -Wno-uninitialized ;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dev usb wlan ] ;
KernelAddon realtekwifi8187 :
if_urtw.c
glue.c
:
freebsd_wlan.a
freebsd_usb.a
libfreebsd_network.a
;
ObjectHdrs [ FGristFiles if_urtw$(SUFOBJ) ]
: [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) libs compat freebsd_network ] ;
Includes [ FGristFiles if_urtw.c ]
: <src!libs!compat!freebsd_network>usbdevs.h ;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,432 @@
/*-
* Copyright (c) 2008 Weongyo Jeong <weongyo@FreeBSD.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define URTW_CONFIG_INDEX 0
#define URTW_IFACE_INDEX 0
/* for 8187 */
#define URTW_MAC0 0x0000 /* 1 byte */
#define URTW_MAC1 0x0001 /* 1 byte */
#define URTW_MAC2 0x0002 /* 1 byte */
#define URTW_MAC3 0x0003 /* 1 byte */
#define URTW_MAC4 0x0004 /* 1 byte */
#define URTW_MAC5 0x0005 /* 1 byte */
#define URTW_MAR 0x0008 /* 6 byte */
#define URTW_RXFIFO_CNT 0x0010 /* 1 byte */
#define URTW_TXFIFO_CNT 0x0012 /* 1 byte */
#define URTW_BQREQ 0x0013 /* 1 byte */
#define URTW_TSFT 0x0018 /* 6 byte */
#define URTW_TLPDA 0x0020 /* 4 byte */
#define URTW_TNPDA 0x0024 /* 4 byte */
#define URTW_THPDA 0x0028 /* 4 byte */
#define URTW_BRSR 0x002c /* 2 byte */
#define URTW_BRSR_MBR_8185 (0x0fff)
#define URTW_8187B_EIFS 0x002d /* 1 byte for 8187B */
#define URTW_BSSID 0x002e /* 6 byte */
#define URTW_BRSR_8187B 0x0034 /* 2 byte for 8187B */
#define URTW_RESP_RATE 0x0034 /* 1 byte for 8187L */
#define URTW_RESP_MAX_RATE_SHIFT (4)
#define URTW_RESP_MIN_RATE_SHIFT (0)
#define URTW_EIFS 0x0035 /* 1 byte */
#define URTW_CMD 0x0037 /* 1 byte */
#define URTW_CMD_TX_ENABLE (0x4)
#define URTW_CMD_RX_ENABLE (0x8)
#define URTW_CMD_RST (0x10)
#define URTW_INTR_MASK 0x003c /* 2 byte */
#define URTW_INTR_STATUS 0x003e /* 2 byte */
#define URTW_TX_CONF 0x0040 /* 4 byte */
#define URTW_TX_LOOPBACK_SHIFT (17)
#define URTW_TX_LOOPBACK_NONE (0 << URTW_TX_LOOPBACK_SHIFT)
#define URTW_TX_LOOPBACK_MAC (1 << URTW_TX_LOOPBACK_SHIFT)
#define URTW_TX_LOOPBACK_BASEBAND (2 << URTW_TX_LOOPBACK_SHIFT)
#define URTW_TX_LOOPBACK_CONTINUE (3 << URTW_TX_LOOPBACK_SHIFT)
#define URTW_TX_LOOPBACK_MASK (0x60000)
#define URTW_TX_DPRETRY_MASK (0xff00)
#define URTW_TX_RTSRETRY_MASK (0xff)
#define URTW_TX_DPRETRY_SHIFT (0)
#define URTW_TX_RTSRETRY_SHIFT (8)
#define URTW_TX_NOCRC (0x10000)
#define URTW_TX_MXDMA_MASK (0xe00000)
#define URTW_TX_MXDMA_1024 (6 << URTW_TX_MXDMA_SHIFT)
#define URTW_TX_MXDMA_2048 (7 << URTW_TX_MXDMA_SHIFT)
#define URTW_TX_MXDMA_SHIFT (21)
#define URTW_TX_DISCW (1 << 20)
#define URTW_TX_SWPLCPLEN (1 << 24)
#define URTW_TX_R8187vD (5 << 25)
#define URTW_TX_R8187vD_B (6 << 25)
#define URTW_TX_HWMASK (7 << 25)
#define URTW_TX_DISREQQSIZE (1 << 28)
#define URTW_TX_HW_SEQNUM (1 << 30)
#define URTW_TX_CWMIN (1U << 31)
#define URTW_TX_NOICV (0x80000)
#define URTW_RX 0x0044 /* 4 byte */
#define URTW_RX_9356SEL (1 << 6)
#define URTW_RX_FILTER_MASK \
(URTW_RX_FILTER_ALLMAC | URTW_RX_FILTER_NICMAC | URTW_RX_FILTER_MCAST | \
URTW_RX_FILTER_BCAST | URTW_RX_FILTER_CRCERR | URTW_RX_FILTER_ICVERR | \
URTW_RX_FILTER_DATA | URTW_RX_FILTER_CTL | URTW_RX_FILTER_MNG | \
(1 << 21) | \
URTW_RX_FILTER_PWR | URTW_RX_CHECK_BSSID)
#define URTW_RX_FILTER_ALLMAC (0x00000001)
#define URTW_RX_FILTER_NICMAC (0x00000002)
#define URTW_RX_FILTER_MCAST (0x00000004)
#define URTW_RX_FILTER_BCAST (0x00000008)
#define URTW_RX_FILTER_CRCERR (0x00000020)
#define URTW_RX_FILTER_ICVERR (0x00001000)
#define URTW_RX_FILTER_DATA (0x00040000)
#define URTW_RX_FILTER_CTL (0x00080000)
#define URTW_RX_FILTER_MNG (0x00100000)
#define URTW_RX_FILTER_PWR (0x00400000)
#define URTW_RX_CHECK_BSSID (0x00800000)
#define URTW_RX_FIFO_THRESHOLD_MASK ((1 << 13) | (1 << 14) | (1 << 15))
#define URTW_RX_FIFO_THRESHOLD_SHIFT (13)
#define URTW_RX_FIFO_THRESHOLD_128 (3)
#define URTW_RX_FIFO_THRESHOLD_256 (4)
#define URTW_RX_FIFO_THRESHOLD_512 (5)
#define URTW_RX_FIFO_THRESHOLD_1024 (6)
#define URTW_RX_FIFO_THRESHOLD_NONE (7 << URTW_RX_FIFO_THRESHOLD_SHIFT)
#define URTW_RX_AUTORESETPHY (1 << URTW_RX_AUTORESETPHY_SHIFT)
#define URTW_RX_AUTORESETPHY_SHIFT (28)
#define URTW_MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10))
#define URTW_MAX_RX_DMA_2048 (7 << URTW_MAX_RX_DMA_SHIFT)
#define URTW_MAX_RX_DMA_1024 (6)
#define URTW_MAX_RX_DMA_SHIFT (10)
#define URTW_RCR_ONLYERLPKT (1U << 31)
#define URTW_INT_TIMEOUT 0x0048 /* 4 byte */
#define URTW_INT_TBDA 0x004c /* 4 byte */
#define URTW_EPROM_CMD 0x0050 /* 1 byte */
#define URTW_EPROM_CMD_NORMAL (0x0)
#define URTW_EPROM_CMD_NORMAL_MODE \
(URTW_EPROM_CMD_NORMAL << URTW_EPROM_CMD_SHIFT)
#define URTW_EPROM_CMD_LOAD (0x1)
#define URTW_EPROM_CMD_PROGRAM (0x2)
#define URTW_EPROM_CMD_PROGRAM_MODE \
(URTW_EPROM_CMD_PROGRAM << URTW_EPROM_CMD_SHIFT)
#define URTW_EPROM_CMD_CONFIG (0x3)
#define URTW_EPROM_CMD_SHIFT (6)
#define URTW_EPROM_CMD_MASK ((1 << 7) | (1 << 6))
#define URTW_EPROM_READBIT (0x1)
#define URTW_EPROM_WRITEBIT (0x2)
#define URTW_EPROM_CK (0x4)
#define URTW_EPROM_CS (0x8)
#define URTW_CONFIG0 0x0051 /* 1 byte */
#define URTW_CONFIG1 0x0052 /* 1 byte */
#define URTW_CONFIG2 0x0053 /* 1 byte */
#define URTW_ANAPARAM 0x0054 /* 4 byte */
#define URTW_8225_ANAPARAM_ON (0xa0000a59)
#define URTW_8225_ANAPARAM_OFF (0xa00beb59)
#define URTW_8187B_8225_ANAPARAM_ON (0x45090658)
#define URTW_8187B_8225_ANAPARAM_OFF (0x55480658)
#define URTW_MSR 0x0058 /* 1 byte */
#define URTW_MSR_LINK_MASK ((1 << 2) | (1 << 3))
#define URTW_MSR_LINK_SHIFT (2)
#define URTW_MSR_LINK_NONE (0 << URTW_MSR_LINK_SHIFT)
#define URTW_MSR_LINK_ADHOC (1 << URTW_MSR_LINK_SHIFT)
#define URTW_MSR_LINK_STA (2 << URTW_MSR_LINK_SHIFT)
#define URTW_MSR_LINK_HOSTAP (3 << URTW_MSR_LINK_SHIFT)
#define URTW_MSR_LINK_ENEDCA (1 << 4)
#define URTW_CONFIG3 0x0059 /* 1 byte */
#define URTW_CONFIG3_ANAPARAM_WRITE (0x40)
#define URTW_CONFIG3_GNT_SELECT (0x80)
#define URTW_CONFIG3_ANAPARAM_W_SHIFT (6)
#define URTW_CONFIG4 0x005a /* 1 byte */
#define URTW_CONFIG4_VCOOFF (1 << 7)
#define URTW_TESTR 0x005b /* 1 byte */
#define URTW_PSR 0x005e /* 1 byte */
#define URTW_SECURITY 0x005f /* 1 byte */
#define URTW_ANAPARAM2 0x0060 /* 4 byte */
#define URTW_8225_ANAPARAM2_ON (0x860c7312)
#define URTW_8225_ANAPARAM2_OFF (0x840dec11)
#define URTW_8187B_8225_ANAPARAM2_ON (0x727f3f52)
#define URTW_8187B_8225_ANAPARAM2_OFF (0x72003f50)
#define URTW_BEACON_INTERVAL 0x0070 /* 2 byte */
#define URTW_ATIM_WND 0x0072 /* 2 byte */
#define URTW_BEACON_INTERVAL_TIME 0x0074 /* 2 byte */
#define URTW_ATIM_TR_ITV 0x0076 /* 2 byte */
#define URTW_PHY_DELAY 0x0078 /* 1 byte */
#define URTW_CARRIER_SCOUNT 0x0079 /* 1 byte */
#define URTW_PHY_MAGIC1 0x007c /* 1 byte */
#define URTW_PHY_MAGIC2 0x007d /* 1 byte */
#define URTW_PHY_MAGIC3 0x007e /* 1 byte */
#define URTW_PHY_MAGIC4 0x007f /* 1 byte */
#define URTW_RF_PINS_OUTPUT 0x0080 /* 2 byte */
#define URTW_RF_PINS_OUTPUT_MAGIC1 (0x3a0)
#define URTW_BB_HOST_BANG_CLK (1 << 1)
#define URTW_BB_HOST_BANG_EN (1 << 2)
#define URTW_BB_HOST_BANG_RW (1 << 3)
#define URTW_RF_PINS_ENABLE 0x0082 /* 2 byte */
#define URTW_RF_PINS_SELECT 0x0084 /* 2 byte */
#define URTW_ADDR_MAGIC1 0x0085 /* broken? */
#define URTW_RF_PINS_INPUT 0x0086 /* 2 byte */
#define URTW_RF_PINS_MAGIC1 (0xfff3)
#define URTW_RF_PINS_MAGIC2 (0xfff0)
#define URTW_RF_PINS_MAGIC3 (0x0007)
#define URTW_RF_PINS_MAGIC4 (0xf)
#define URTW_RF_PINS_MAGIC5 (0x0080)
#define URTW_RF_PARA 0x0088 /* 4 byte */
#define URTW_RF_TIMING 0x008c /* 4 byte */
#define URTW_GP_ENABLE 0x0090 /* 1 byte */
#define URTW_GP_ENABLE_DATA_MAGIC1 (0x1)
#define URTW_GPIO 0x0091 /* 1 byte */
#define URTW_GPIO_DATA_MAGIC1 (0x1)
#define URTW_HSSI_PARA 0x0094 /* 4 byte */
#define URTW_TX_AGC_CTL 0x009c /* 1 byte */
#define URTW_TX_AGC_CTL_PERPACKET_GAIN (0x1)
#define URTW_TX_AGC_CTL_PERPACKET_ANTSEL (0x2)
#define URTW_TX_AGC_CTL_FEEDBACK_ANT (0x4)
#define URTW_TX_GAIN_CCK 0x009d /* 1 byte */
#define URTW_TX_GAIN_OFDM 0x009e /* 1 byte */
#define URTW_TX_ANTENNA 0x009f /* 1 byte */
#define URTW_WPA_CONFIG 0x00b0 /* 1 byte */
#define URTW_SIFS 0x00b4 /* 1 byte */
#define URTW_DIFS 0x00b5 /* 1 byte */
#define URTW_SLOT 0x00b6 /* 1 byte */
#define URTW_CW_CONF 0x00bc /* 1 byte */
#define URTW_CW_CONF_PERPACKET_RETRY (0x2)
#define URTW_CW_CONF_PERPACKET_CW (0x1)
#define URTW_CW_VAL 0x00bd /* 1 byte */
#define URTW_RATE_FALLBACK 0x00be /* 1 byte */
#define URTW_RATE_FALLBACK_ENABLE (0x80)
#define URTW_ACM_CONTROL 0x00bf /* 1 byte */
#define URTW_CONFIG5 0x00d8 /* 1 byte */
#define URTW_TXDMA_POLLING 0x00d9 /* 1 byte */
#define URTW_CWR 0x00dc /* 2 byte */
#define URTW_RETRY_CTR 0x00de /* 1 byte */
#define URTW_INT_MIG 0x00e2 /* 2 byte */
#define URTW_RDSAR 0x00e4 /* 4 byte */
#define URTW_TID_AC_MAP 0x00e8 /* 2 byte */
#define URTW_ANAPARAM3 0x00ee /* 1 byte */
#define URTW_8187B_8225_ANAPARAM3_ON (0x0)
#define URTW_8187B_8225_ANAPARAM3_OFF (0x0)
#define URTW_8187B_AC_VO 0x00f0 /* 4 byte for 8187B */
#define URTW_FEMR 0x00f4 /* 2 byte */
#define URTW_8187B_AC_VI 0x00f4 /* 4 byte for 8187B */
#define URTW_8187B_AC_BE 0x00f8 /* 4 byte for 8187B */
#define URTW_TALLY_CNT 0x00fa /* 2 byte */
#define URTW_TALLY_SEL 0x00fc /* 1 byte */
#define URTW_8187B_AC_BK 0x00fc /* 4 byte for 8187B */
#define URTW_ADDR_MAGIC2 0x00fe /* 2 byte */
#define URTW_ADDR_MAGIC3 0x00ff /* 1 byte */
/* for 8225 */
#define URTW_8225_ADDR_0_MAGIC 0x0
#define URTW_8225_ADDR_0_DATA_MAGIC1 (0x1b7)
#define URTW_8225_ADDR_0_DATA_MAGIC2 (0x0b7)
#define URTW_8225_ADDR_0_DATA_MAGIC3 (0x127)
#define URTW_8225_ADDR_0_DATA_MAGIC4 (0x027)
#define URTW_8225_ADDR_0_DATA_MAGIC5 (0x22f)
#define URTW_8225_ADDR_0_DATA_MAGIC6 (0x2bf)
#define URTW_8225_ADDR_1_MAGIC 0x1
#define URTW_8225_ADDR_2_MAGIC 0x2
#define URTW_8225_ADDR_2_DATA_MAGIC1 (0xc4d)
#define URTW_8225_ADDR_2_DATA_MAGIC2 (0x44d)
#define URTW_8225_ADDR_3_MAGIC 0x3
#define URTW_8225_ADDR_3_DATA_MAGIC1 (0x2)
#define URTW_8225_ADDR_5_MAGIC 0x5
#define URTW_8225_ADDR_5_DATA_MAGIC1 (0x4)
#define URTW_8225_ADDR_6_MAGIC 0x6
#define URTW_8225_ADDR_6_DATA_MAGIC1 (0xe6)
#define URTW_8225_ADDR_6_DATA_MAGIC2 (0x80)
#define URTW_8225_ADDR_7_MAGIC 0x7
#define URTW_8225_ADDR_8_MAGIC 0x8
#define URTW_8225_ADDR_8_DATA_MAGIC1 (0x588)
#define URTW_8225_ADDR_9_MAGIC 0x9
#define URTW_8225_ADDR_9_DATA_MAGIC1 (0x700)
#define URTW_8225_ADDR_C_MAGIC 0xc
#define URTW_8225_ADDR_C_DATA_MAGIC1 (0x850)
#define URTW_8225_ADDR_C_DATA_MAGIC2 (0x050)
/* for EEPROM */
#define URTW_EPROM_CHANPLAN 0x03
#define URTW_EPROM_CHANPLAN_BY_HW (0x80)
#define URTW_EPROM_TXPW_BASE 0x05
#define URTW_EPROM_RFCHIPID 0x06
#define URTW_EPROM_RFCHIPID_RTL8225U (5)
#define URTW_EPROM_RFCHIPID_RTL8225Z2 (6)
#define URTW_EPROM_MACADDR 0x07
#define URTW_EPROM_TXPW0 0x16
#define URTW_EPROM_TXPW2 0x1b
#define URTW_EPROM_TXPW1 0x3d
#define URTW_EPROM_SWREV 0x3f
#define URTW_EPROM_CID_MASK (0xff)
#define URTW_EPROM_CID_RSVD0 (0x00)
#define URTW_EPROM_CID_RSVD1 (0xff)
#define URTW_EPROM_CID_ALPHA0 (0x01)
#define URTW_EPROM_CID_SERCOMM_PS (0x02)
#define URTW_EPROM_CID_HW_LED (0x03)
/* LED */
#define URTW_CID_DEFAULT 0
#define URTW_CID_8187_ALPHA0 1
#define URTW_CID_8187_SERCOMM_PS 2
#define URTW_CID_8187_HW_LED 3
#define URTW_SW_LED_MODE0 0
#define URTW_SW_LED_MODE1 1
#define URTW_SW_LED_MODE2 2
#define URTW_SW_LED_MODE3 3
#define URTW_HW_LED 4
#define URTW_LED_CTL_POWER_ON 0
#define URTW_LED_CTL_LINK 2
#define URTW_LED_CTL_TX 4
#define URTW_LED_PIN_GPIO0 0
#define URTW_LED_PIN_LED0 1
#define URTW_LED_PIN_LED1 2
#define URTW_LED_UNKNOWN 0
#define URTW_LED_ON 1
#define URTW_LED_OFF 2
#define URTW_LED_BLINK_NORMAL 3
#define URTW_LED_BLINK_SLOWLY 4
#define URTW_LED_POWER_ON_BLINK 5
#define URTW_LED_SCAN_BLINK 6
#define URTW_LED_NO_LINK_BLINK 7
#define URTW_LED_BLINK_CM3 8
/* for extra area */
#define URTW_EPROM_DISABLE 0
#define URTW_EPROM_ENABLE 1
#define URTW_EPROM_DELAY 10
#define URTW_8187_GETREGS_REQ 5
#define URTW_8187_SETREGS_REQ 5
#define URTW_8225_RF_MAX_SENS 6
#define URTW_8225_RF_DEF_SENS 4
#define URTW_DEFAULT_RTS_RETRY 7
#define URTW_DEFAULT_TX_RETRY 7
#define URTW_DEFAULT_RTS_THRESHOLD 2342U
#define URTW_ASIFS_TIME 10
#define URTW_ACKCTS_LEN 14 /* len for ACK and CTS */
struct urtw_8187b_rxhdr {
uint32_t flag;
#define URTW_RX_FLAG_LEN /* 0 ~ 11 bits */
#define URTW_RX_FLAG_ICV_ERR (1 << 12)
#define URTW_RX_FLAG_CRC32_ERR (1 << 13)
#define URTW_RX_FLAG_PM (1 << 14)
#define URTW_RX_FLAG_RX_ERR (1 << 15)
#define URTW_RX_FLAG_BCAST (1 << 16)
#define URTW_RX_FLAG_PAM (1 << 17)
#define URTW_RX_FLAG_MCAST (1 << 18)
#define URTW_RX_FLAG_QOS (1 << 19) /* only for RTL8187B */
#define URTW_RX_FLAG_RXRATE /* 20 ~ 23 bits */
#define URTW_RX_FLAG_RXRATE_SHIFT 20
#define URTW_RX_FLAG_TRSW (1 << 24) /* only for RTL8187B */
#define URTW_RX_FLAG_SPLCP (1 << 25)
#define URTW_RX_FLAG_FOF (1 << 26)
#define URTW_RX_FLAG_DMA_FAIL (1 << 27)
#define URTW_RX_FLAG_LAST (1 << 28)
#define URTW_RX_FLAG_FIRST (1 << 29)
#define URTW_RX_FLAG_EOR (1 << 30)
#define URTW_RX_FLAG_OWN (1U << 31)
uint64_t mactime;
uint8_t noise;
uint8_t rssi;
#define URTW_RX_RSSI /* 0 ~ 6 bits */
#define URTW_RX_RSSI_MASK 0x3f
#define URTW_RX_ANTENNA (1 << 7)
uint8_t agc;
uint8_t flag2;
#define URTW_RX_FLAG2_DECRYPTED (1 << 0)
#define URTW_RX_FLAG2_WAKUP (1 << 1)
#define URTW_RX_FLAG2_SHIFT (1 << 2)
#define URTW_RX_FLAG2_RSVD0 /* 3 ~ 7 bits */
uint16_t flag3;
#define URTW_RX_FLAG3_NUMMCSI /* 0 ~ 3 bits */
#define URTW_RX_FLAG3_SNR_L2E /* 4 ~ 9 bits */
#define URTW_RX_FLAG3_CFO_BIAS /* 10 ~ 15 bits */
int8_t pwdb;
uint8_t fot;
} __packed;
struct urtw_8187b_txhdr {
uint32_t flag;
#define URTW_TX_FLAG_PKTLEN /* 0 ~ 11 bits */
#define URTW_TX_FLAG_RSVD0 /* 12 ~ 14 bits */
#define URTW_TX_FLAG_NO_ENC (1 << 15)
#define URTW_TX_FLAG_SPLCP (1 << 16)
#define URTW_TX_FLAG_MOREFRAG (1 << 17)
#define URTW_TX_FLAG_CTS (1 << 18)
#define URTW_TX_FLAG_RTSRATE /* 19 ~ 22 bits */
#define URTW_TX_FLAG_RTSRATE_SHIFT 19
#define URTW_TX_FLAG_RTS (1 << 23)
#define URTW_TX_FLAG_TXRATE /* 24 ~ 27 bits */
#define URTW_TX_FLAG_TXRATE_SHIFT 24
#define URTW_TX_FLAG_LAST (1 << 28)
#define URTW_TX_FLAG_FIRST (1 << 29)
#define URTW_TX_FLAG_DMA (1 << 30)
#define URTW_TX_FLAG_OWN (1U << 31)
uint16_t rtsdur;
uint16_t len;
#define URTW_TX_LEN /* 0 ~ 14 bits */
#define URTW_TX_LEN_EXT (1 << 15)
uint32_t bufaddr;
uint16_t flag1;
#define URTW_TX_FLAG1_RXLEN /* 0 ~ 11 bits */
#define URTW_TX_FLAG1_RSVD0 /* 12 ~ 14 bits */
#define URTW_TX_FLAG1_MICCAL (1 << 15)
uint16_t txdur;
uint32_t nextdescaddr;
uint8_t rtsagc;
uint8_t retry;
uint16_t flag2;
#define URTW_TX_FLAG2_RTDB (1 << 0)
#define URTW_TX_FLAG2_NOACM (1 << 1)
#define URTW_TX_FLAG2_PIFS (1 << 2)
#define URTW_TX_FLAG2_RSVD0 /* 3 ~ 6 bits */
#define URTW_TX_FLAG2_RTSRATEFALLBACK /* 7 ~ 10 bits */
#define URTW_TX_FLAG2_RATEFALLBACK /* 11 ~ 15 bits */
uint16_t delaybound;
uint16_t flag3;
#define URTW_TX_FLAG3_RSVD0 /* 0 ~ 3 bits */
#define URTW_TX_FLAG3_AGC /* 4 ~ 11 bits */
#define URTW_TX_FLAG3_ANTENNA (1 << 12)
#define URTW_TX_FLAG3_SPC /* 13 ~ 14 bits */
#define URTW_TX_FLAG3_RSVD1 (1 << 15)
uint32_t flag4;
#define URTW_TX_FLAG4_LENADJUST /* 0 ~ 1 bits */
#define URTW_TX_FLAG4_RSVD0 (1 << 2)
#define URTW_TX_FLAG4_TPCDESEN (1 << 3)
#define URTW_TX_FLAG4_TPCPOLARITY /* 4 ~ 5 bits */
#define URTW_TX_FLAG4_TPCEN (1 << 6)
#define URTW_TX_FLAG4_PTEN (1 << 7)
#define URTW_TX_FLAG4_BCKEY /* 8 ~ 13 bits */
#define URTW_TX_FLAG4_ENBCKEY (1 << 14)
#define URTW_TX_FLAG4_ENPMPD (1 << 15)
#define URTW_TX_FLAG4_FRAGQSZ /* 16 ~ 31 bits */
} __packed;
struct urtw_8187l_rxhdr {
uint32_t flag;
uint8_t noise;
uint8_t rssi;
#define URTW_RX_8187L_RSSI /* 0 ~ 6 bits */
#define URTW_RX_8187L_RSSI_MASK 0x3f
#define URTW_RX_8187L_ANTENNA (1 << 7)
uint8_t agc;
uint8_t flag2;
#define URTW_RX_8187L_DECRYPTED (1 << 0)
#define URTW_RX_8187L_WAKEUP (1 << 1)
#define URTW_RX_8187L_SHIFT (1 << 2)
#define URTW_RX_8187L_RSVD0 /* 3 ~ 7 bits */
uint64_t mactime;
} __packed;
struct urtw_8187l_txhdr {
uint32_t flag;
uint16_t rtsdur;
uint16_t len;
uint32_t retry;
} __packed;
@@ -0,0 +1,185 @@
/*-
* Copyright (c) 2008 Weongyo Jeong <weongyo@FreeBSD.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
enum {
URTW_8187B_BULK_RX,
URTW_8187B_BULK_TX_STATUS,
URTW_8187B_BULK_TX_BE,
URTW_8187B_BULK_TX_BK,
URTW_8187B_BULK_TX_VI,
URTW_8187B_BULK_TX_VO,
URTW_8187B_BULK_TX_EP12,
URTW_8187B_N_XFERS = 7
};
enum {
URTW_8187L_BULK_RX,
URTW_8187L_BULK_TX_LOW,
URTW_8187L_BULK_TX_NORMAL,
URTW_8187L_N_XFERS = 3
};
/* XXX no definition at net80211? */
#define URTW_MAX_CHANNELS 15
struct urtw_data {
struct urtw_softc *sc;
uint8_t *buf;
uint16_t buflen;
struct mbuf *m;
struct ieee80211_node *ni; /* NB: tx only */
STAILQ_ENTRY(urtw_data) next;
};
typedef STAILQ_HEAD(, urtw_data) urtw_datahead;
#define URTW_RX_DATA_LIST_COUNT 4
#define URTW_TX_DATA_LIST_COUNT 16
#define URTW_RX_MAXSIZE 0x9c4
#define URTW_TX_MAXSIZE 0x9c4
#define URTW_TX_MAXRETRY 11
struct urtw_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint64_t wr_tsf;
uint8_t wr_flags;
uint8_t wr_pad;
uint16_t wr_chan_freq;
uint16_t wr_chan_flags;
int8_t wr_dbm_antsignal;
} __packed __aligned(8);
#define URTW_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL))
struct urtw_tx_radiotap_header {
struct ieee80211_radiotap_header wt_ihdr;
uint8_t wt_flags;
uint8_t wt_pad;
uint16_t wt_chan_freq;
uint16_t wt_chan_flags;
} __packed;
#define URTW_TX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_CHANNEL))
struct urtw_stats {
unsigned txrates[12];
};
struct urtw_vap {
struct ieee80211vap vap;
int (*newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
};
#define URTW_VAP(vap) ((struct urtw_vap *)(vap))
struct urtw_softc {
struct ieee80211com sc_ic;
struct mbufq sc_snd;
device_t sc_dev;
struct usb_device *sc_udev;
struct mtx sc_mtx;
void *sc_tx_dma_buf;
int sc_debug;
int sc_flags;
#define URTW_INIT_ONCE (1 << 1)
#define URTW_RTL8187B (1 << 2)
#define URTW_RTL8187B_REV_B (1 << 3)
#define URTW_RTL8187B_REV_D (1 << 4)
#define URTW_RTL8187B_REV_E (1 << 5)
#define URTW_DETACHED (1 << 6)
#define URTW_RUNNING (1 << 7)
enum ieee80211_state sc_state;
int sc_epromtype;
#define URTW_EEPROM_93C46 0
#define URTW_EEPROM_93C56 1
uint8_t sc_crcmon;
struct ieee80211_channel *sc_curchan;
/* for RF */
usb_error_t (*sc_rf_init)(struct urtw_softc *);
usb_error_t (*sc_rf_set_chan)(struct urtw_softc *,
int);
usb_error_t (*sc_rf_set_sens)(struct urtw_softc *,
int);
usb_error_t (*sc_rf_stop)(struct urtw_softc *);
uint8_t sc_rfchip;
uint32_t sc_max_sens;
uint32_t sc_sens;
/* for LED */
struct usb_callout sc_led_ch;
struct task sc_led_task;
uint8_t sc_psr;
uint8_t sc_strategy;
#define URTW_LED_GPIO 1
uint8_t sc_gpio_ledon;
uint8_t sc_gpio_ledinprogress;
uint8_t sc_gpio_ledstate;
uint8_t sc_gpio_ledpin;
uint8_t sc_gpio_blinktime;
uint8_t sc_gpio_blinkstate;
/* RX/TX */
struct usb_xfer *sc_xfer[URTW_8187B_N_XFERS];
#define URTW_PRIORITY_LOW 0
#define URTW_PRIORITY_NORMAL 1
#define URTW_DATA_TIMEOUT 10000 /* 10 sec */
#define URTW_8187B_TXPIPE_BE 0x6 /* best effort */
#define URTW_8187B_TXPIPE_BK 0x7 /* background */
#define URTW_8187B_TXPIPE_VI 0x5 /* video */
#define URTW_8187B_TXPIPE_VO 0x4 /* voice */
#define URTW_8187B_TXPIPE_MAX 4
struct urtw_data sc_rx[URTW_RX_DATA_LIST_COUNT];
urtw_datahead sc_rx_active;
urtw_datahead sc_rx_inactive;
struct urtw_data sc_tx[URTW_TX_DATA_LIST_COUNT];
urtw_datahead sc_tx_active;
urtw_datahead sc_tx_inactive;
urtw_datahead sc_tx_pending;
uint8_t sc_rts_retry;
uint8_t sc_tx_retry;
uint8_t sc_preamble_mode;
#define URTW_PREAMBLE_MODE_SHORT 1
#define URTW_PREAMBLE_MODE_LONG 2
struct callout sc_watchdog_ch;
int sc_txtimer;
int sc_currate;
/* TX power */
uint8_t sc_txpwr_cck[URTW_MAX_CHANNELS];
uint8_t sc_txpwr_cck_base;
uint8_t sc_txpwr_ofdm[URTW_MAX_CHANNELS];
uint8_t sc_txpwr_ofdm_base;
uint8_t sc_acmctl;
uint64_t sc_txstatus; /* only for 8187B */
struct task sc_updateslot_task;
struct urtw_stats sc_stats;
struct urtw_rx_radiotap_header sc_rxtap;
struct urtw_tx_radiotap_header sc_txtap;
};
#define URTW_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
#define URTW_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
#define URTW_ASSERT_LOCKED(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
@@ -0,0 +1 @@
#include <sys/epoch.h>
@@ -0,0 +1,29 @@
/*
* Copyright 2026, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <sys/haiku-module.h>
HAIKU_FBSD_WLAN_DRIVERS_GLUE(realtekwifi8187)
HAIKU_DRIVER_REQUIREMENTS(FBSD_WLAN);
HAIKU_FIRMWARE_VERSION(0);
NO_HAIKU_FIRMWARE_NAME_MAP();
NO_HAIKU_FBSD_MII_DRIVER();
NO_HAIKU_CHECK_DISABLE_INTERRUPTS();
NO_HAIKU_REENABLE_INTERRUPTS();
extern driver_t* DRIVER_MODULE_NAME(urtw, uhub);
void
__haiku_init_hardware()
{
driver_t *usb_drivers[] = {
DRIVER_MODULE_NAME(urtw, uhub),
NULL
};
_fbsd_init_hardware_uhub(usb_drivers);
}