Skip to content

Commit 522d67b

Browse files
committed
sys/linux: add basic examples of vusb variants
This change is the first step in addressing issue [1]. Despite syzkaller's best efforts, some usb drivers are proving resistant to attempts to probe them. Specifically, crafted devices are not accurate enough to bypass checks in probe(). These checks mostly deal with usb interfaces and endpoints. One way to address this issue is to define syz_connect_* calls variants to help syzkaller succeed probing by describing in detail various device attributes. Start by describing such calls for select drivers, each representing its own category of sorts. At the moment, code coverage for these drivers is unimpressive: - rtl8150 Used to succeed probing until a better usb endpoint check was implemented. - sierra_net Same as rtl8150. Depends on usbnet API for bind() and usb ep checks. - lan78xx Requires numerous control requests between driver and device DURING probe. Extra descriptions are helpful but are not enough to fully complete probing process. Also, add a seed for each such example. This is only a stepping stone to improve usb fuzzing results and most likely will be subject to change in the future. [1] #6206
1 parent 1804e95 commit 522d67b

File tree

5 files changed

+309
-0
lines changed

5 files changed

+309
-0
lines changed

sys/linux/test/vusb_lan78xx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# This seed helps syzkaller to reliably pass the probe() checks for lan78xx driver.
2+
# As some CTRL requests occur during the probe, a few syz_usb_control_io() calls may
3+
# be in a weird order or even duplicate.
4+
5+
# TODO: currently, probe does not succeed completely. Most likely, it stems from the fact that
6+
# the abundance of expected CTRL requests *during* probe is not something syzkaller can handle at the moment.
7+
# Timing is essential among other things. This should be mitigated by a separate syz_usb_connect pseudo-call
8+
# that deals with such requests without syz_usb_control_io.
9+
10+
# Ensure that we pass driver-specific basic usb interface and endpoint checks during initial probe() stages.
11+
12+
r0 = syz_usb_connect$lan78xx(0x5, 0x3f, &(0x7f0000000000)={{0x12, 0x1, 0x200, 0xff, 0xff, 0xff, 0x40, 0x424, 0x7850, 0x0, 0x1, 0x2, 0x3, 0x1, [{{0x9, 0x2, 0x2d, 0x1, 0x1, 0x0, 0x80, 0xfa, {{0x9, 0x4, 0x0, 0x0, 0x3, 0xff, 0x0, 0x0, 0x0, "", {{0x9, 0x5, 0x81, 0x2, 0x200, 0x0, 0x0, 0x0, ""}, {0x9, 0x5, 0x2, 0x2, 0x200, 0x0, 0x0, 0x0, ""}, {0x9, 0x5, 0x83, 0x3, 0x40, 0x1, 0x0, 0x0, ""}}}}}}]}}, 0x0)
13+
14+
# This is where the fun begins.
15+
# Functions like lan78xx_bind() and lan78xx_phy_init() in lan78xx_probe() utilize ~50 CTRL requests, both directions, during probe.
16+
17+
# Write to INT_EP_CTL register in lan78xx_setup_irq_domain().
18+
19+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f00000003c0)={0x34, &(0x7f0000000140)={0x20, 0x11, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})
20+
21+
# Write to HW_CFG register in lan78xx_reset().
22+
23+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000000780)={0x34, &(0x7f0000000600)={0x40, 0x11, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})
24+
25+
# Read from HW_CFG register.
26+
27+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
28+
29+
# Write to HW_CFG register.
30+
31+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000000f00)={0x34, &(0x7f0000000cc0)={0x40, 0x10, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})
32+
33+
# Write to RX_ADDRL and RX_ADDRH registers in lan78xx_init_mac_address().
34+
35+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000001240)={0x34, &(0x7f0000001080)={0x0, 0x6, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})
36+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000001700)={0x34, &(0x7f0000001500)={0x20, 0x18, 0x1, ')'}, 0x0, 0x0, 0x0, 0x0, 0x0})
37+
38+
# Read from MAF_LO(0) and MAF_HI(0) registers.
39+
40+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
41+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
42+
43+
# Write to ID_REV register, back in lan78xx_reset().
44+
45+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000002180)={0x34, &(0x7f0000000400)=ANY=[], 0x0, 0x0, 0x0, 0x0, 0x0})
46+
47+
# Write and read to/from USB_CFG0 register.
48+
49+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f00000006c0)={0x34, &(0x7f0000000500)={0x0, 0x7, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})
50+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
51+
52+
# Write to USB_CFG1 register in lan78xx_init_ltm().
53+
54+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000002540)={0x34, &(0x7f0000002340)={0x0, 0xf, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})
55+
56+
# Read from 6 registers (LTM_BELT_IDLE0 etc.) in a row.
57+
58+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
59+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
60+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
61+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
62+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
63+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
64+
65+
# Read from BURST_CAP and BULK_IN_DLY registers in lan78xx_reset().
66+
67+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
68+
syz_usb_control_io$lan78xx(r0, 0x0, 0x0)
69+
70+
# Write to HW_CFG register.
71+
72+
syz_usb_control_io$lan78xx(r0, 0x0, &(0x7f0000000380)={0x34, &(0x7f0000000840)={0x0, 0x0, 0x0, ""}, 0x0, 0x0, 0x0, 0x0, 0x0})

sys/linux/test/vusb_rtl8150

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This seed helps syzkaller to reliably pass the probe() checks for rtl8150 driver.
2+
# As some CTRL requests occur during the probe, a few syz_usb_control_io() calls may
3+
# be in a weird order or even duplicate.
4+
5+
# Ensure that we pass driver-specific basic usb interface and endpoint checks during initial probe() stages.
6+
7+
r0 = syz_usb_connect$rtl8150(0x3, 0x3f, &(0x7f00000003c0)={{0x12, 0x1, 0x110, 0xff, 0xff, 0x0, 0x40, 0xbda, 0x8150, 0x40, 0x1, 0x2, 0x3, 0x1, [{{0x9, 0x2, 0x2d, 0x1, 0x1, 0x5, 0x80, 0x0, {{0x9, 0x4, 0x0, 0x7f, 0x3, 0xff, 0x11, 0x1, 0x5, "", {{0x9, 0x5, 0x81, 0x2, 0x40, 0x6, 0x9, 0x4, ""}, {0x9, 0x5, 0x2, 0x2, 0x20, 0x2, 0x57, 0x6e, ""}, {0x9, 0x5, 0x83, 0x3, 0x240, 0x3, 0x82, 0x8, ""}}}}}}]}}, 0x0)
8+
9+
# During probe, rtl8150_reset() requires reading/writing registers via usb_control_msg(), see:
10+
# https://elixir.bootlin.com/linux/v6.16/source/drivers/net/usb/rtl8150.c#L316
11+
12+
# The timing of dealing with CTRL requests is very awkward. So as not to fail dealing with registers, these calls come in.
13+
# They are not directly related to rtl8150 code itself yet seem to be making that the next calls below run on time.
14+
# TODO: figure out the circumstances fully and consider switching to sleep/nanosleep instead.
15+
16+
syz_usb_control_io$rtl8150(r0, &(0x7f0000000580)={0x14, 0x0, &(0x7f0000000480)={0x0, 0x3, 0x3, @lang_id={0x0, 0x3, 0x0}}}, 0x0)
17+
syz_usb_control_io$rtl8150(r0, &(0x7f0000002980)={0x14, 0x0, &(0x7f00000028c0)={0x0, 0x3, 0x3, @lang_id={0x0, 0x3, 0x0}}}, 0x0)
18+
19+
# Receive a request via set_registers().
20+
21+
syz_usb_control_io$rtl8150(r0, 0x0, 0x0)
22+
23+
# Send a request via get_registers(). Sent data should make the while{} loop in rtl8150_reset() stop early.
24+
25+
syz_usb_control_io$rtl8150(r0, 0x0, &(0x7f0000004280)={0x2c, 0x0, 0x0, 0x0, 0x0, &(0x7f0000004240)={0x40, 0x5, 0x2, "2bd8"}})

sys/linux/test/vusb_sierra_net

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This seed helps syzkaller to reliably pass the probe() checks for sierra_net driver.
2+
# As some CTRL requests occur during the probe, a few syz_usb_control_io() calls may
3+
# be in a weird order or even duplicate.
4+
5+
# Ensure that we pass driver-specific basic usb interface and endpoint checks during initial probe() stages.
6+
7+
r0 = syz_usb_connect$sierra_net(0x0, 0x3f, &(0x7f0000000080)={{0x12, 0x1, 0x200, 0xff, 0xff, 0xff, 0x40, 0x1199, 0x68a3, 0x0, 0x1, 0x2, 0x3, 0x1, [{{0x9, 0x2, 0x2d, 0x1, 0x1, 0x0, 0x80, 0xfa, {{0x9, 0x4, 0x7, 0x0, 0x3, 0xff, 0x0, 0x0, 0x0, "", {{0x9, 0x5, 0x43978451d8f6fedb, 0x2, 0x40, 0x2, 0x1b, 0xfe, ""}, {0x9, 0x5, 0x7, 0x2, 0x200, 0xc, 0x77, 0x3, ""}, {0x9, 0x5, 0x81, 0x3, 0x20, 0x0, 0xfd, 0x32, ""}}}}}}]}}, 0x0)
8+
9+
# To pass the probe, at the minumum one has to make the crafted device write to the driver in sierra_net_get_fw_attr(), see:
10+
# https://elixir.bootlin.com/linux/v6.16/source/drivers/net/usb/sierra_net.c#L636
11+
# Technically, there are other CTRL requests, such as the ones in sierra_net_dosync() - however, they are allowed to fail, so we can ignore them.
12+
13+
# Seemingly, this call is only here to keep the timing right.
14+
# TODO: fix the expected delay with sleep/nanosleep.
15+
16+
syz_usb_control_io$sierra_net(r0, 0x0, 0x0)
17+
18+
# Send a CTRL request to driver concerning firmware data. See:
19+
# https://elixir.bootlin.com/linux/v6.16/source/drivers/net/usb/sierra_net.c#L743
20+
21+
syz_usb_control_io$sierra_net(r0, &(0x7f0000000100)={0x14, &(0x7f0000000000)={0x20, 0x21, 0x8, {0x8, 0x11, "e4ff14eca81f"}}, 0x0}, 0x0)

sys/linux/vusb.txt

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,3 +1438,175 @@ htc_frame_flags = HTC_FLAGS_RECV_TRAILER
14381438
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
14391439
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
14401440
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1441+
1442+
# Assorted driver-specific descriptions of generic syz_* calls' variants.
1443+
1444+
# Generic calls such as syz_usb_connect() and syz_usb_control_io() should be enough
1445+
# (in theory) to emulate a proper device and finish driver probes without a hitch.
1446+
# However, there are cases when syzkaller fails to come up with correct inputs to achieve it.
1447+
# Use fixed descriptors to quickly pass through probe() to access select drivers' post-probe functionality.
1448+
1449+
# It is important to note that, one way or another, drivers in question require multiple control requests
1450+
# between a driver and a device processed during probe(). Descriptions below do not deal with specific
1451+
# CTRL requests as such (except for basic information included in vusb_responses_XXX). Instead, rely on
1452+
# seeds, created both manually and with syzkaller's help. For examples, see sys/linux/test/vusb_XXX.
1453+
1454+
# Common constants for endpoint descriptors.
1455+
define USB_ENDPOINT_BULK_ATTR (USB_ENDPOINT_XFER_BULK)
1456+
define USB_ENDPOINT_INT_ATTR (USB_ENDPOINT_XFER_INT)
1457+
1458+
define USB_FIXED_ENDPOINT_BULK_IN_ADDR (1 | USB_DIR_IN)
1459+
define USB_FIXED_ENDPOINT_BULK_OUT_ADDR (2)
1460+
define USB_FIXED_ENDPOINT_INT_IN_ADDR (3 | USB_DIR_IN)
1461+
1462+
define USB_RECIP_DEVICE 0x00
1463+
1464+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1465+
1466+
# rtl8150 driver specific descriptions.
1467+
1468+
resource fd_usb_rtl8150[fd_usb]
1469+
1470+
syz_usb_connect$rtl8150(speed flags[usb_device_speed], dev_len len[dev], dev ptr[in, usb_device_descriptor_rtl8150], conn_descs const[0]) fd_usb_rtl8150 (timeout[3000], prog_timeout[3000], remote_cover)
1471+
syz_usb_control_io$rtl8150(fd fd_usb_rtl8150, descs ptr[in, vusb_descriptors_rtl8150], resps ptr[in, vusb_responses_rtl8150]) (timeout[300], remote_cover)
1472+
1473+
usb_device_descriptor_rtl8150 {
1474+
inner usb_device_descriptor_fixed_t[0x200, USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, 64, 0xbda, 0x8150, 0, array[usb_config_descriptor_rtl8150, 1]]
1475+
} [packed]
1476+
1477+
usb_config_descriptor_rtl8150 {
1478+
inner usb_config_descriptor_fixed_t[1, 1, USB_CONFIG_ATT_ONE, 250, usb_interface_descriptor_rtl8150]
1479+
} [packed]
1480+
1481+
usb_interface_descriptor_rtl8150 {
1482+
iface usb_interface_descriptor_fixed_t[0, 0, 3, USB_CLASS_VENDOR_SPEC, 0, 0, void, usb_endpoint_descriptors_rtl8150]
1483+
} [packed]
1484+
1485+
usb_endpoint_descriptors_rtl8150 {
1486+
bulk_in usb_endpoint_descriptor_fixed_t[USB_FIXED_ENDPOINT_BULK_IN_ADDR, USB_ENDPOINT_BULK_ATTR, 512, 0, void]
1487+
bulk_out usb_endpoint_descriptor_fixed_t[USB_FIXED_ENDPOINT_BULK_OUT_ADDR, USB_ENDPOINT_BULK_ATTR, 512, 0, void]
1488+
int_in usb_endpoint_descriptor_fixed_t[USB_FIXED_ENDPOINT_INT_IN_ADDR, USB_ENDPOINT_INT_ATTR, 64, 1, void]
1489+
} [packed]
1490+
1491+
vusb_descriptors_rtl8150 {
1492+
len len[parent, int32]
1493+
generic ptr[in, vusb_descriptor_generic]
1494+
1495+
USB_DT_STRING ptr[in, vusb_descriptor_t[USB_TYPE_STANDARD, USB_DT_STRING, usb_string_descriptor]]
1496+
} [packed]
1497+
1498+
vusb_responses_rtl8150 {
1499+
len len[parent, int32]
1500+
generic ptr[in, vusb_response_generic]
1501+
1502+
USB_REQ_GET_INTERFACE ptr[in, vusb_response_t[USB_TYPE_STANDARD, USB_REQ_GET_INTERFACE, int8]]
1503+
USB_REQ_GET_CONFIGURATION ptr[in, vusb_response_t[USB_TYPE_STANDARD, USB_REQ_GET_CONFIGURATION, int8]]
1504+
1505+
RTL8150_REQ_GET_REGS ptr[in, vusb_response_t[RTL8150_REQT_READ, RTL8150_REQ_GET_REGS, array[int8, 0:6]]]
1506+
RTL8150_REQ_SET_REGS ptr[in, vusb_response_t[RTL8150_REQT_WRITE, RTL8150_REQ_SET_REGS, array[int8, 0:6]]]
1507+
} [packed]
1508+
1509+
define RTL8150_REQ_GET_REGS 0x05
1510+
define RTL8150_REQ_SET_REGS 0x05
1511+
define RTL8150_REQT_READ 0xc0
1512+
define RTL8150_REQT_WRITE 0x40
1513+
1514+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1515+
1516+
# sierra_net driver specific descriptions.
1517+
1518+
resource fd_usb_sierra_net[fd_usb]
1519+
1520+
syz_usb_connect$sierra_net(speed flags[usb_device_speed], dev_len len[dev], dev ptr[in, usb_device_descriptor_sierra_net], conn_descs const[0]) fd_usb_sierra_net (timeout[3000], prog_timeout[3000], remote_cover)
1521+
syz_usb_control_io$sierra_net(fd fd_usb_sierra_net, descs ptr[in, vusb_descriptors_sierra_net], resps ptr[in, vusb_responses_sierra_net]) (timeout[300], remote_cover)
1522+
1523+
usb_device_descriptor_sierra_net {
1524+
inner usb_device_descriptor_fixed_t[0x200, USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, 64, 0x1199, 0x68a3, 0, array[usb_config_descriptor_sierra_net, 1]]
1525+
} [packed]
1526+
1527+
usb_config_descriptor_sierra_net {
1528+
inner usb_config_descriptor_fixed_t[1, 1, USB_CONFIG_ATT_ONE, 250, usb_interface_descriptor_sierra_net]
1529+
} [packed]
1530+
1531+
usb_interface_descriptor_sierra_net {
1532+
iface usb_interface_descriptor_fixed_t[7, 0, 3, USB_CLASS_VENDOR_SPEC, 0, 0, void, usb_endpoint_descriptors_sierra_net]
1533+
} [packed]
1534+
1535+
# sierra_net driver does not expect fixed ep addresses, so refrain from being too specific here.
1536+
# As long as we ensure there are 3 endpoints, 2 bulk and 1 int, syzkaller should figure it out.
1537+
usb_endpoint_descriptors_sierra_net {
1538+
bulk_in usb_endpoint_descriptor_t[flags[usb_endpoint_addresses, int8], const[USB_ENDPOINT_BULK_ATTR, int8], void]
1539+
bulk_out usb_endpoint_descriptor_t[flags[usb_endpoint_addresses, int8], const[USB_ENDPOINT_BULK_ATTR, int8], void]
1540+
status usb_endpoint_descriptor_t[flags[usb_endpoint_addresses, int8], const[USB_ENDPOINT_INT_ATTR, int8], void]
1541+
} [packed]
1542+
1543+
vusb_descriptors_sierra_net {
1544+
len len[parent, int32]
1545+
generic ptr[in, vusb_descriptor_generic]
1546+
1547+
USB_DT_STRING ptr[in, vusb_descriptor_t[USB_TYPE_STANDARD, USB_DT_STRING, usb_string_descriptor]]
1548+
} [packed]
1549+
1550+
vusb_responses_sierra_net {
1551+
len len[parent, int32]
1552+
generic ptr[in, vusb_response_generic]
1553+
1554+
USB_CDC_GET_ENCAPSULATED_RESPONSE ptr[in, vusb_response_t[SIERRA_CMD_TYPE_IN, USB_CDC_GET_ENCAPSULATED_RESPONSE, array[int8, 1024]]]
1555+
USB_CDC_SEND_ENCAPSULATED_COMMANDT ptr[in, vusb_response_t[SIERRA_CMD_TYPE_OUT, USB_CDC_SEND_ENCAPSULATED_COMMAND, array[int8, 0:4]]]
1556+
} [packed]
1557+
1558+
define SIERRA_CMD_TYPE_IN (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
1559+
define SIERRA_CMD_TYPE_OUT (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)
1560+
1561+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
1562+
1563+
# lan78xx driver specific descriptions.
1564+
# While these syz_* variants noticably help with the probe() process, they are not enough.
1565+
# This is due to a high number of control requests expected between the driver and the device.
1566+
1567+
include <drivers/net/usb/smsc95xx.h>
1568+
1569+
resource fd_usb_lan78xx[fd_usb]
1570+
1571+
syz_usb_connect$lan78xx(speed flags[usb_device_speed], dev_len len[dev], dev ptr[in, usb_device_descriptor_lan78xx], conn_descs const[0]) fd_usb_lan78xx (timeout[3000], prog_timeout[3000], remote_cover)
1572+
syz_usb_control_io$lan78xx(fd fd_usb_lan78xx, descs ptr[in, vusb_descriptors_lan78xx], resps ptr[in, vusb_responses_lan78xx]) (timeout[300], remote_cover)
1573+
1574+
usb_device_descriptor_lan78xx {
1575+
inner usb_device_descriptor_fixed_t[0x200, USB_CLASS_VENDOR_SPEC, USB_SUBCLASS_VENDOR_SPEC, 0xff, 64, 0x424, 0x7850, 0, array[usb_config_descriptor_lan78xx, 1]]
1576+
} [packed]
1577+
1578+
usb_config_descriptor_lan78xx {
1579+
inner usb_config_descriptor_fixed_t[1, 1, USB_CONFIG_ATT_ONE, 250, usb_interface_descriptor_lan78xx]
1580+
} [packed]
1581+
1582+
usb_interface_descriptor_lan78xx {
1583+
iface usb_interface_descriptor_fixed_t[0, 0, 3, USB_CLASS_VENDOR_SPEC, 0, 0, void, usb_endpoint_descriptors_lan78xx]
1584+
} [packed]
1585+
1586+
usb_endpoint_descriptors_lan78xx {
1587+
bulk_in usb_endpoint_descriptor_fixed_t[USB_FIXED_ENDPOINT_BULK_IN_ADDR, USB_ENDPOINT_BULK_ATTR, 512, 0, void]
1588+
bulk_out usb_endpoint_descriptor_fixed_t[USB_FIXED_ENDPOINT_BULK_OUT_ADDR, USB_ENDPOINT_BULK_ATTR, 512, 0, void]
1589+
int_in usb_endpoint_descriptor_fixed_t[USB_FIXED_ENDPOINT_INT_IN_ADDR, USB_ENDPOINT_INT_ATTR, 64, 1, void]
1590+
} [packed]
1591+
1592+
vusb_descriptors_lan78xx {
1593+
len len[parent, int32]
1594+
generic ptr[in, vusb_descriptor_generic]
1595+
1596+
USB_DT_STRING ptr[in, vusb_descriptor_t[USB_TYPE_STANDARD, USB_DT_STRING, usb_string_descriptor]]
1597+
} [packed]
1598+
1599+
vusb_responses_lan78xx {
1600+
len len[parent, int32]
1601+
generic ptr[in, vusb_response_generic]
1602+
1603+
USB_REQ_GET_INTERFACE ptr[in, vusb_response_t[USB_TYPE_STANDARD, USB_REQ_GET_INTERFACE, int8]]
1604+
USB_REQ_GET_CONFIGURATION ptr[in, vusb_response_t[USB_TYPE_STANDARD, USB_REQ_GET_CONFIGURATION, int8]]
1605+
1606+
USB_VENDOR_REQUEST_READ_REGISTER ptr[in, vusb_response_t[LAN78XX_REG_TYPE_IN, USB_VENDOR_REQUEST_READ_REGISTER, int32]]
1607+
USB_VENDOR_REQUEST_WRITE_REGISTER ptr[in, vusb_response_t[LAN78XX_REG_TYPE_OUT, USB_VENDOR_REQUEST_WRITE_REGISTER, int32]]
1608+
USB_VENDOR_REQUEST_GET_STATS ptr[in, vusb_response_t[LAN78XX_REG_TYPE_IN, USB_VENDOR_REQUEST_GET_STATS, array[int8, 47]]]
1609+
} [packed]
1610+
1611+
define LAN78XX_REG_TYPE_IN (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
1612+
define LAN78XX_REG_TYPE_OUT (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)

sys/linux/vusb.txt.const

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ HUB_CHAR_PORTIND = 128
7373
HUB_CHAR_TTTT = 96
7474
HUB_STATUS_LOCAL_POWER = 1
7575
HUB_STATUS_OVERCURRENT = 2
76+
LAN78XX_REG_TYPE_IN = 192
77+
LAN78XX_REG_TYPE_OUT = 64
78+
RTL8150_REQT_READ = 192
79+
RTL8150_REQT_WRITE = 64
80+
RTL8150_REQ_GET_REGS = 5
81+
RTL8150_REQ_SET_REGS = 5
82+
SIERRA_CMD_TYPE_IN = 161
83+
SIERRA_CMD_TYPE_OUT = 33
7684
UAC1_EXTENSION_UNIT = 8
7785
UAC1_PROCESSING_UNIT = 7
7886
UAC_AS_GENERAL = 1
@@ -162,6 +170,7 @@ USB_CDC_COUNTRY_TYPE = 7
162170
USB_CDC_DMM_TYPE = 20
163171
USB_CDC_ETHERNET_TYPE = 15
164172
USB_CDC_GET_CRC_MODE = 137
173+
USB_CDC_GET_ENCAPSULATED_RESPONSE = 1
165174
USB_CDC_GET_MAX_DATAGRAM_SIZE = 135
166175
USB_CDC_GET_NTB_FORMAT = 131
167176
USB_CDC_GET_NTB_INPUT_SIZE = 133
@@ -181,6 +190,7 @@ USB_CDC_NCM_TYPE = 26
181190
USB_CDC_NETWORK_TERMINAL_TYPE = 10
182191
USB_CDC_OBEX_TYPE = 21
183192
USB_CDC_PROTO_NONE = 0
193+
USB_CDC_SEND_ENCAPSULATED_COMMAND = 0
184194
USB_CDC_SUBCLASS_ETHERNET = 6
185195
USB_CDC_SUBCLASS_NCM = 13
186196
USB_CDC_UNION_TYPE = 6
@@ -235,6 +245,7 @@ USB_ENDPOINT_ATH9K_BULK_OUT_ADDRESS = 1
235245
USB_ENDPOINT_ATH9K_INT_ATTRIBUTES = 3
236246
USB_ENDPOINT_ATH9K_INT_IN_ADDRESS = 131
237247
USB_ENDPOINT_ATH9K_INT_OUT_ADDRESS = 4
248+
USB_ENDPOINT_BULK_ATTR = 2
238249
USB_ENDPOINT_CDC_ECM_DATA_ATTRIBUTES = 2
239250
USB_ENDPOINT_CDC_ECM_IN_ADDRESS = 130
240251
USB_ENDPOINT_CDC_ECM_NOTIFY_ADDRESS = 129
@@ -245,6 +256,7 @@ USB_ENDPOINT_HID_IN_ADDRESS = 129
245256
USB_ENDPOINT_HID_OUT_ADDRESS = 2
246257
USB_ENDPOINT_INTR_NOTIFICATION = 16
247258
USB_ENDPOINT_INTR_PERIODIC = 0
259+
USB_ENDPOINT_INT_ATTR = 3
248260
USB_ENDPOINT_PRINTER_ATTRIBUTES = 2
249261
USB_ENDPOINT_PRINTER_IN_ADDRESS = 130
250262
USB_ENDPOINT_PRINTER_OUT_ADDRESS = 1
@@ -265,6 +277,9 @@ USB_EXT_PORT_STAT_RX_LANES = 3840
265277
USB_EXT_PORT_STAT_RX_SPEED_ID = 15
266278
USB_EXT_PORT_STAT_TX_LANES = 61440
267279
USB_EXT_PORT_STAT_TX_SPEED_ID = 240
280+
USB_FIXED_ENDPOINT_BULK_IN_ADDR = 129
281+
USB_FIXED_ENDPOINT_BULK_OUT_ADDR = 2
282+
USB_FIXED_ENDPOINT_INT_IN_ADDR = 131
268283
USB_FULL_SPEED_OPERATION = 2
269284
USB_HIGH_SPEED_OPERATION = 4
270285
USB_HUB_PORTS_BITS = 4
@@ -297,6 +312,7 @@ USB_PORT_STAT_SPEED_5GBPS = 0
297312
USB_PORT_STAT_SUSPEND = 4
298313
USB_PORT_STAT_TEST = 2048
299314
USB_PTM_CAP_TYPE = 11
315+
USB_RECIP_DEVICE = 0
300316
USB_REQ_CLEAR_FEATURE = 1
301317
USB_REQ_GET_BATTERY_STATUS = 21
302318
USB_REQ_GET_CONFIGURATION = 8
@@ -366,6 +382,9 @@ USB_SUBCLASS_VENDOR_SPEC = 255
366382
USB_TYPE_CLASS = 32
367383
USB_TYPE_STANDARD = 0
368384
USB_TYPE_VENDOR = 64
385+
USB_VENDOR_REQUEST_GET_STATS = 162
386+
USB_VENDOR_REQUEST_READ_REGISTER = 161
387+
USB_VENDOR_REQUEST_WRITE_REGISTER = 160
369388
USB_WIRELESS_BEACON_DIRECTED = 8
370389
USB_WIRELESS_BEACON_MASK = 12
371390
USB_WIRELESS_BEACON_NONE = 12

0 commit comments

Comments
 (0)