STRUCT TB_TUNNEL(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct tb_tunnel(9)

okay bestie, so this is straight out of the Kernel API Manual β€” we're talking struct tb_tunnel(9), like, the literal blueprint of a Tunnel between two ports πŸŒ€βœ¨. grab your emotional support iced coffee, because this one is a whole struct and she has a lot of fields. but don't panic, i got you 🫢


✨ NAME ✨

struct tb_tunnel β€” Tunnel between two ports 🌈

like, that's her. that's the whole vibe. a tunnel connecting a source port to a destination port. iconic behavior tbh.


πŸŽ€ SYNOPSIS πŸŽ€

struct tb_tunnel {
    struct kref kref;
    struct tb *tb;
    struct tb_port *src_port;
    struct tb_port *dst_port;
    size_t npaths;
    int (*pre_activate)(struct tb_tunnel *tunnel);
    int (*activate)(struct tb_tunnel *tunnel, bool activate);
    void (*post_deactivate)(struct tb_tunnel *tunnel);
    void (*destroy)(struct tb_tunnel *tunnel);
    int (*maximum_bandwidth)(struct tb_tunnel *tunnel, int *max_up, int
*max_down);
    int (*allocated_bandwidth)(struct tb_tunnel *tunnel, int
*allocated_up, int *allocated_down);
    int (*alloc_bandwidth)(struct tb_tunnel *tunnel, int *alloc_up, int
*alloc_down);
    int (*consumed_bandwidth)(struct tb_tunnel *tunnel, int
*consumed_up, int *consumed_down);
    int (*release_unused_bandwidth)(struct tb_tunnel *tunnel);
    void (*reclaim_available_bandwidth)(struct tb_tunnel *tunnel, int
*available_up, int *available_down);
    struct list_head list;
    enum tb_tunnel_type type;
    enum tb_tunnel_state state;
    int max_up;
    int max_down;
    int allocated_up;
    int allocated_down;
    bool bw_mode;
    bool dprx_started;
    bool dprx_canceled;
    ktime_t dprx_timeout;
    struct delayed_work dprx_work;
    void (*callback)(struct tb_tunnel *tunnel, void *data);
    void *callback_data;
    struct tb_path *paths[];
};

lowkey a flex how many function pointers she's carrying. main character struct energy fr fr πŸ‘‘


🌸 Members 🌸

okay so lemme walk you through every single one, no skips, no cap:

  • kref β€” Reference count πŸ’€ like the popularity counter. that's how many people are holding onto her.
  • tb β€” Pointer to the domain
  • src_port β€” Source port of the tunnel πŸš€ where the vibes come from
  • dst_port β€” Destination port of the tunnel. For discovered incomplete tunnels may be NULL or null adapter port instead. ⚠️ yeah she can be a little absent sometimes, don't take it personally
  • npaths β€” Number of paths in paths
  • pre_activate β€” Optional tunnel specific initialization called before activation. Can touch hardware. πŸ‘€ can touch hardware, bestie β€” that's the spicy part
  • activate β€” Optional tunnel specific activation/deactivation
  • post_deactivate β€” Optional tunnel specific de-initialization called after deactivation. Can touch hardware. (yes, hardware-touching again, be responsible 🫢)
  • destroy β€” Optional tunnel specific callback called when the tunnel memory is being released. Should not touch hardware. πŸš«πŸ”§ like hands off the hardware at this point, she's leaving
  • maximum_bandwidth β€” Returns maximum possible bandwidth for this tunnel
  • allocated_bandwidth β€” Return how much bandwidth is allocated for the tunnel
  • alloc_bandwidth β€” Change tunnel bandwidth allocation
  • consumed_bandwidth β€” Return how much bandwidth the tunnel consumes
  • release_unused_bandwidth β€” Release all unused bandwidth πŸ•ŠοΈ let it goooo
  • reclaim_available_bandwidth β€” Reclaim back available bandwidth (she always comes back for it πŸ’…)
  • list β€” Tunnels are linked using this field πŸ”— friendship bracelet style
  • type β€” Type of the tunnel
  • state β€” Current state of the tunnel
  • max_up β€” Maximum upstream bandwidth (Mb/s) available for the tunnel. Only set if the bandwidth needs to be limited.
  • max_down β€” Maximum downstream bandwidth (Mb/s) available for the tunnel. Only set if the bandwidth needs to be limited.
  • allocated_up β€” Allocated upstream bandwidth (only for USB3)
  • allocated_down β€” Allocated downstream bandwidth (only for USB3)
  • bw_mode β€” DP bandwidth allocation mode registers can be used to determine consumed and allocated bandwidth
  • dprx_started β€” DPRX negotiation was started (tb_dp_dprx_start was called for it) βœ…
  • dprx_canceled β€” Was DPRX capabilities read poll canceled πŸ™ˆ
  • dprx_timeout β€” If set DPRX capabilities read poll work will timeout after this passes ⏰
  • dprx_work β€” Worker that is scheduled to poll completion of DPRX capabilities read
  • callback β€” Callback called when DP tunnel is fully activated πŸŽ‰ the celebration function
  • callback_data β€” Data for callback
  • paths β€” All paths required by the tunnel πŸ›£οΈ every route she needs, flexible array at the end, we love a trailing member

πŸ¦‹ SEE ALSO πŸ¦‹


ok so real talk: read the members list before you go poking at hardware, especially around pre_activate and post_deactivate. and remember destroy should not touch hardware. that's a boundary. respect it. 🚧

that's the whole page bestie, you ate that πŸ’…βœ¨ go forth and tunnel responsibly πŸ§šβ€β™€οΈ

so yeah, this little gem lives in ./drivers/thunderbolt, dated October 2026 β€” mwah, see you in the next manpage πŸŽ€πŸ’–

πŸ“¦ where this page comes from