STRUCT TBSTREAM_DEV(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct tbstream_dev(9) β€” the Kernel API Manual, bestie edition

okay so this one lives in the kernel API manual and it's literally all about struct tbstream_dev, aka the stream character device. yes bestie, the character device that does the tunneling. let's get into it πŸŽ€


✨ NAME ✨

struct tbstream_dev β€” Stream character device. that's it, that's the vibe. πŸ¦‹

🌸 SYNOPSIS 🌸

here's the whole struct, character for character, no cap:

struct tbstream_dev {
    struct config_group group;
    struct tbstream *stream;
    struct miscdevice misc;
    struct kref kref;
    int index;
    int in_hopid;
    int out_hopid;
    unsigned int ring_size;
    unsigned int throttling;
    bool busy_poll;
    int users;
    bool closed;
    bool removed;
    wait_queue_head_t wait;
    struct mutex lock;
    struct tbstream_ring tx_ring;
    struct tbstream_ring rx_ring;
    struct list_head list;
 };

yes there are two whole rings, we stan πŸ’…

πŸ‘‘ Members πŸ‘‘

lowkey the most important part, so let's go member by member, no skipping, fr fr ✨

  • group β€” the ConfigFS group for this device. it's giving organizational queen πŸ‘‘
  • stream β€” pointer to the stream if it's attached, and NULL otherwise. so check it before you dereference it, bestie, i'm begging 😭
  • misc β€” the character device used for tunneling. main character energy, honestly
  • kref β€” the reference count. keep it balanced or things get ugly πŸ’€
  • index β€” a unique identifier for the character device. every device needs its own little name tag πŸŽ€
  • in_hopid β€” the In HopID
  • out_hopid β€” the Out HopID. in and out, balanced, iconic 🌈
  • ring_size β€” the size of the rings
  • throttling β€” interrupt throttling rate in ns. yes, nanoseconds, we're precise here ⭐
  • busy_poll β€” instead of interrupts, busy poll the rings. different strategy, same energy πŸ”₯
  • users β€” number of times cdev has been opened
  • closed β€” set when a CLOSE packet was received
  • removed β€” userspace removed the ConfigFS group underneath. rude but okay πŸ™ˆ
  • wait β€” waitqueue for open, read and write. it's where everyone waits their turn 🫢
  • lock β€” the lock protecting this structure. do not skip the lock, i'm serious πŸ’€
  • tx_ring β€” transmit ring
  • rx_ring β€” receive ring
  • list β€” stream devices are linked through this. friendship bracelet behavior, honestly πŸ’–

🧚 SEE ALSO 🧚

go read these next, iykyk:

  • Kernel file ./drivers/thunderbolt/stream.c
  • enum tbstream_frame_pdf(9)
  • struct tbstream_frame(9)
  • struct tbstream_ring(9)
  • struct tbstream_group(9)
  • struct tbstream(9)

ok that's the whole page, no gatekeeping πŸ’… go forth and tunnel responsibly, bestie. and remember: stream can be NULL, take the lock, and check that kref 🫢

and that's a wrap! this iconic little doc comes from ./drivers/thunderbolt in the Kernel API Manual, dated October 2026. slay, periodt, bye! πŸŒΈβœ¨πŸ’œ

πŸ“¦ where this page comes from