If the api is modeled on usbfs, the rump part for usb drivers can be
developed on Linux

On Wednesday, November 25, 2026, Manolo de Medici <[email protected]>
wrote:

> Hello,
> I quickly checked this iteration and I’m left with the impression that
> there are some general issues with design so I’d like to propose you the
> following.
>
> I’d use the Linux usbfs as a specification for the Hurd userspace driver
> api, such that we would have a battle tested interface made by experts.
>
> There are a few things to consider, your arbiter can stay but please check
> the issues with coarse grained  locking. The Linux specification has four
> ioctl that require userspace pointers, the urb and its buffer, those will
> need to be intercepted by glibc and translate to handles, should be
> straightforward.
>
> After doing that, You could also think of batched and vectored extensions.
>
> Finally, can you provide as a simple example hooks in rump so that we can
> use this arbiters to drive usb devices using netbsd drivers?
>
> On Wednesday, November 25, 2026, <[email protected]> wrote:
>
>> Hello Samuel, Manolo,
>>
>> thank you both.  I reworked the stack along the lines you suggested; the
>> repository is updated in place.
>>
>> Samuel: agreed about the maintenance load, and I am not proposing this as
>> the default stack.  The part I would eventually like to see upstream is
>> only the hurdish part -- the arbiter interface and its permission model --
>> not the xHCI hardware driver.  That one can stay out of tree, or be
>> replaced by a rump-backed implementation of the same interface.
>>
>> Manolo: both of your points are implemented.
>>
>> 1. A typed arbiter interface, no more binary framing.
>>
>>    usb.defs is now the only way to submit transfers.  xhci is a libnetfs
>>    translator modelled on pci-arbiter:
>>
>>      /dev/xhci0/devices    text listing of attached devices
>>      /dev/xhci0/slotN      one node per addressed device
>>
>>    The slot is a property of the node, never an argument of an RPC, so a
>>    client holding the port of slot1 cannot name another device.  Queries
>>    and IN transfers require O_READ; endpoint configuration, resets and OUT
>>    transfers require O_WRITE.  Class translators open a node with
>>    file_name_lookup, read the configuration descriptor from the arbiter
>>    and pick the interface and endpoints themselves; --slot is gone.
>>
>>    On unplug the slot is marked dead in the interrupt handler, pending
>>    transfers return ENODEV at once, and the node leaves the namespace.
>>
>> 2. SCSI and the physical transport are separate modules.
>>
>>    usb_bot.[ch] knows nothing about SCSI.  Its whole surface is
>>
>>      usb_bot_exec_cdb (bot, cdb, cdb_len, in, data, data_len,
>>                        &residue, &status)
>>
>>    which packs the CBW, runs the data stage, validates the CSW and does
>>    the BOT recovery rules (clear HALT, retry the CSW, reset on Phase
>>    Error).  scsi.[ch] builds CDBs above it, and umass.c is only the
>>    libtrivfs front end.  If a rump scsipi layer is plugged in later,
>>    scsi.[ch] is what it replaces; usb_bot.[ch] and the arbiter interface
>>    stay.
>>
>> Questions where your opinion decides whether this is useful beyond an
>> experiment:
>>
>>   - Is the per-node capability model the right shape for an arbiter that a
>>     rump/NetBSD host driver could implement later?  A few fields in
>>     usb.defs still carry xHCI encodings: ep_type, comp_code, the log2
>>     interval and the Protocol Speed ID.  That is honest about the current
>>     backend but leaks it into the ABI; I would rather turn them into
>>     USB-neutral transfer types, URB statuses and speed codes now, before
>>     anything depends on them, if that is the direction you prefer.
>>
>>   - Where should the interface itself live: hurd/incubator, or a separate
>>     proposal here first?  PROTOCOL.md describes the namespace, the RPCs,
>>     the error conventions and the locking, so it can be reviewed without
>>     reading the driver.
>>
>>   - usb.defs uses subsystem 42000.  Should it be registered in
>>     hurd/subsystems while the interface is still experimental, or left
>>     unregistered until it settles?
>>
>> One finding that may be useful on its own: usbhid can now serve /dev/kbd
>> (--proto=hurdkbd) for X.Org's native Hurd keyboard backend.
>> xf86-input-keyboard's hurd_kbd.c issues ioctl (_IOW('k', 1, int)), which
>> by
>> IOC_GROUP_SUBSYSTEM is kdioctl 120000, message 120001 -- not tioctl.
>> Answering kdioctl_kdskbdmode and delivering one kd_event per Set 1 byte is
>> enough for kbd_drv.so to attach.  Since Mach does not export kd_event,
>> both
>> the console client and X.Org define it locally; would an exported
>> <device/kd.h> be welcome, or is the local definition the intended
>> convention?
>>
>> The build no longer hardcodes /usr/include/hurd: it probes the compiler's
>> multiarch directory, and defs/kdioctl.defs is a verbatim copy of the Hurd
>> file, used only when the packaged one is absent.
>>
>> Remaining limitations: root hub ports only, no external hubs, no
>> isochronous transfers or streams, INTx only (MSI/MSI-X stays masked
>> because
>> the gnumach irq device delivers GSIs), and HID covers the Boot Protocol
>> feature set only.  Compared with the first version, umass now falls back
>> to
>> READ CAPACITY (16) above 2 TiB and issues SYNCHRONIZE CACHE (10) on
>> shutdown, and class translators no longer need a fixed slot and endpoint
>> set at startup.
>>
>> Tested under QEMU qemu-xhci with usb-storage, usb-kbd and usb-mouse:
>> mkfs.ext2 plus /hurd/ext2fs -T file still works, and X.Org starts with the
>> keyboard on /dev/kbd and the mouse on /dev/usbmouse0.
>>
>> https://git.disroot.org/slavagnu/hurd-xhci
>>
>> I will carry the maintenance, and the offer to complete the FSF assignment
>> stands.  Happy to send follow-up patches for whatever you want changed.
>>
>> Best regards,
>> slavagnu
>>
>

Reply via email to