STRUCT USB_DEVICE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct usb_device ✨

okay so real talk, this is from the Kernel API Manual (yes, the struct usb_device(9) page, we're doing this πŸ’…) and it's literally the kernel's whole personality wrapped around a USB device.

🌸 NAME 🌸

struct usb_device β€” the kernel's representation of a USB device. it's giving "everything you ever wanted to know about a plugged-in thing" πŸ’–

πŸŽ€ SYNOPSIS πŸŽ€

bestie. look at this. it's a lot, and every single field is important, so here's the whole thing, character for character, no cap:

struct usb_device {
    int devnum;
    char devpath[16];
    u32 route;
    enum usb_device_state   state;
    enum usb_device_speed   speed;
    unsigned int            rx_lanes;
    unsigned int            tx_lanes;
    enum usb_ssp_rate       ssp_rate;
    struct usb_tt   *tt;
    int ttport;
    unsigned int toggle[2];
    struct usb_device *parent;
    struct usb_bus *bus;
    struct usb_host_endpoint ep0;
    struct device dev;
    struct usb_device_descriptor descriptor;
    struct usb_host_bos *bos;
    struct usb_host_config *config;
    struct usb_host_config *actconfig;
    struct usb_host_endpoint *ep_in[16];
    struct usb_host_endpoint *ep_out[16];
    char **rawdescriptors;
    unsigned short bus_mA;
    u8 portnum;
    u8 level;
    u8 devaddr;
    unsigned can_submit:1;
    unsigned persist_enabled:1;
    unsigned reset_in_progress:1;
    unsigned have_langid:1;
    unsigned authorized:1;
    unsigned authenticated:1;
    unsigned lpm_capable:1;
    unsigned lpm_devinit_allow:1;
    unsigned usb2_hw_lpm_capable:1;
    unsigned usb2_hw_lpm_besl_capable:1;
    unsigned usb2_hw_lpm_enabled:1;
    unsigned usb2_hw_lpm_allowed:1;
    unsigned usb3_lpm_u1_enabled:1;
    unsigned usb3_lpm_u2_enabled:1;
    int string_langid;
    char *product;
    char *manufacturer;
    char *serial;
    struct list_head filelist;
    int maxchild;
    u32 quirks;
    atomic_t urbnum;
    unsigned long active_duration;
    unsigned long connect_time;
    unsigned do_remote_wakeup:1;
    unsigned reset_resume:1;
    unsigned port_is_suspended:1;
    unsigned offload_pm_locked:1;
    int offload_usage;
    spinlock_t offload_lock;
    enum usb_link_tunnel_mode tunnel_mode;
    struct device_link *usb4_link;
    int slot_id;
    struct usb2_lpm_parameters l1_params;
    struct usb3_lpm_parameters u1_params;
    struct usb3_lpm_parameters u2_params;
    unsigned lpm_disable_count;
    u16 hub_delay;
    unsigned use_generic_driver:1;
 };

πŸ¦‹ Members πŸ¦‹

okay okay, field-by-field, buckle up, this is the main character section πŸ‘‘

  • devnum β€” device number; address on a USB bus. their little street address on the bus fr fr 🏠
  • devpath β€” device ID string for use in messages (e.g., /port/...)
  • route β€” tree topology hex string for use with xHCI
  • state β€” device state: configured, not attached, etc.
  • speed β€” device speed: high/full/low (or error)
  • rx_lanes β€” number of rx lanes in use, USB 3.2 adds dual-lane support
  • tx_lanes β€” number of tx lanes in use, USB 3.2 adds dual-lane support
  • ssp_rate β€” SuperSpeed Plus phy signaling rate and lane count
  • tt β€” Transaction Translator info; used with low/full speed dev, highspeed hub
  • ttport β€” device port on that tt hub
  • toggle β€” one bit for each endpoint, with ([0] = IN, [1] = OUT) endpoints
  • parent β€” our hub, unless we're the root. everybody's got a parent except the root, iconic 🌳
  • bus β€” bus we're part of
  • ep0 β€” endpoint 0 data (default control pipe)
  • dev β€” generic device interface
  • descriptor β€” USB device descriptor
  • bos β€” USB device BOS descriptor set
  • config β€” all of the device's configs
  • actconfig β€” the active configuration
  • ep_in β€” array of IN endpoints
  • ep_out β€” array of OUT endpoints
  • rawdescriptors β€” raw descriptors for each config
  • bus_mA β€” Current available from the bus
  • portnum β€” parent port number (origin 1)
  • level β€” number of USB hub ancestors
  • devaddr β€” device address, XHCI: assigned by HW, others: same as devnum
  • can_submit β€” URBs may be submitted
  • persist_enabled β€” USB_PERSIST enabled for this device
  • reset_in_progress β€” the device is being reset
  • have_langid β€” whether string_langid is valid
  • authorized β€” policy has said we can use it; (user space) policy determines if we authorize this device to be used or not. By default, wired USB devices are authorized. WUSB devices are not, until we authorize them from user space. FIXME -- complete doc πŸ™ˆ (the kernel literally left a FIXME here, we respect the honesty)
  • authenticated β€” Crypto authentication passed
  • lpm_capable β€” device supports LPM
  • lpm_devinit_allow β€” Allow USB3 device initiated LPM, exit latency is in range
  • usb2_hw_lpm_capable β€” device can perform USB2 hardware LPM
  • usb2_hw_lpm_besl_capable β€” device can perform USB2 hardware BESL LPM
  • usb2_hw_lpm_enabled β€” USB2 hardware LPM is enabled
  • usb2_hw_lpm_allowed β€” Userspace allows USB 2.0 LPM to be enabled
  • usb3_lpm_u1_enabled β€” USB3 hardware U1 LPM enabled
  • usb3_lpm_u2_enabled β€” USB3 hardware U2 LPM enabled
  • string_langid β€” language ID for strings
  • product β€” iProduct string, if present (static)
  • manufacturer β€” iManufacturer string, if present (static)
  • serial β€” iSerialNumber string, if present (static)
  • filelist β€” usbfs files that are open to this device
  • maxchild β€” number of ports if hub
  • quirks β€” quirks of the whole device
  • urbnum β€” number of URBs submitted for the whole device
  • active_duration β€” total time device is not suspended
  • connect_time β€” time device was first connected
  • do_remote_wakeup β€” remote wakeup should be enabled
  • reset_resume β€” needs reset instead of resume
  • port_is_suspended β€” the upstream port is suspended (L2 or U3)
  • offload_pm_locked β€” prevents offload_usage changes during PM transitions.
  • offload_usage β€” number of offload activities happening on this usb device.
  • offload_lock β€” protects offload_usage and offload_pm_locked
  • tunnel_mode β€” Connection native or tunneled over USB4
  • usb4_link β€” device link to the USB4 host interface
  • slot_id β€” Slot ID assigned by xHCI
  • l1_params β€” best effor service latency for USB2 L1 LPM state, and L1 timeout. (yes "effor" β€” that's literally what the doc says, we don't fix typos in other people's homework πŸ’€)
  • u1_params β€” exit latencies for USB3 U1 LPM state, and hub-initiated timeout.
  • u2_params β€” exit latencies for USB3 U2 LPM state, and hub-initiated timeout.
  • lpm_disable_count β€” Ref count used by usb_disable_lpm and usb_enable_lpm to keep track of the number of functions that require USB 3.0 Link Power Management to be disabled for this usb_device. This count should only be manipulated by those functions, with the bandwidth_mutex is held. πŸ”’ (and yeah, that sentence grammar is exactly the original's, we are merely the messenger)
  • hub_delay β€” cached value consisting of: parent->hub_delay + wHubDelay + tTPTransmissionDelay (40ns) Will be used as wValue for SetIsochDelay requests.
  • use_generic_driver β€” ask driver core to reprobe using the generic driver.

🌈 Notes 🌈

🚨 heads up bestie: Usbcore drivers should not set usbdev->state directly. Instead use usb_set_device_state. that's the whole rule, don't be messy, use the setter πŸ’…

⭐ SEE ALSO ⭐


okay that's the whole page, you ate that 🫢 this little beauty lives in ./include/linux, dated October 2026, and it's part of the Kernel API Manual β€” go forth and read structs responsibly, mwah πŸ’–πŸ§šβœ¨

πŸ“¦ where this page comes from