STRUCT TB_TUNNEL(9)
π 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 domainsrc_portβ Source port of the tunnel π where the vibes come fromdst_portβ Destination port of the tunnel. For discovered incomplete tunnels may beNULLor null adapter port instead. β οΈ yeah she can be a little absent sometimes, don't take it personallynpathsβ Number of paths inpathspre_activateβ Optional tunnel specific initialization called before activation. Can touch hardware. π can touch hardware, bestie β that's the spicy partactivateβ Optional tunnel specific activation/deactivationpost_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 leavingmaximum_bandwidthβ Returns maximum possible bandwidth for this tunnelallocated_bandwidthβ Return how much bandwidth is allocated for the tunnelalloc_bandwidthβ Change tunnel bandwidth allocationconsumed_bandwidthβ Return how much bandwidth the tunnel consumesrelease_unused_bandwidthβ Release all unused bandwidth ποΈ let it gooooreclaim_available_bandwidthβ Reclaim back available bandwidth (she always comes back for it π )listβ Tunnels are linked using this field π friendship bracelet styletypeβ Type of the tunnelstateβ Current state of the tunnelmax_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 bandwidthdprx_startedβ DPRX negotiation was started (tb_dp_dprx_startwas 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 readcallbackβ Callback called when DP tunnel is fully activated π the celebration functioncallback_dataβ Data for callbackpathsβ All paths required by the tunnel π£οΈ every route she needs, flexible array at the end, we love a trailing member
π¦ SEE ALSO π¦
- Kernel file
./drivers/thunderbolt/tunnel.h enum tb_tunnel_state(9)tb_tunnel_is_active(9)enum tb_tunnel_event(9)
ok so real talk: read the members list before you go poking at hardware, especially aroundpre_activateandpost_deactivate. and rememberdestroyshould 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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms