STRUCT TB_SWITCH(9)
β¨ NAME β¨
struct tb_switch β a thunderbolt switch, bestie π
(and yeah, this is that tb_switch(9) page you were looking for)
Okay so real quick β this is a page from the Kernel API Manual, and it's lowkey all about one struct. Buckle up, she's a big one π
πΈ SYNOPSIS πΈ
struct tb_switch {
struct device dev;
struct tb_regs_switch_header config;
struct tb_port *ports;
struct tb_dma_port *dma_port;
struct tb_switch_tmu tmu;
struct tb *tb;
u64 uid;
uuid_t *uuid;
u16 vendor;
u16 device;
const char *vendor_name;
const char *device_name;
unsigned int link_speed;
enum tb_link_width link_width;
enum tb_link_width preferred_link_width;
bool link_usb4;
unsigned int generation;
int cap_plug_events;
int cap_vsec_tmu;
int cap_lc;
int cap_lp;
bool is_unplugged;
u8 *drom;
struct tb_nvm *nvm;
bool no_nvm_upgrade;
bool safe_mode;
bool boot;
bool rpm;
unsigned int authorized;
enum tb_security_level security_level;
struct dentry *debugfs_dir;
u8 *key;
u8 connection_id;
u8 connection_key;
u8 link;
u8 depth;
struct completion rpm_complete;
unsigned long quirks;
bool credit_allocation;
unsigned int max_usb3_credits;
unsigned int min_dp_aux_credits;
unsigned int min_dp_main_credits;
unsigned int max_pcie_credits;
unsigned int max_dma_credits;
unsigned int clx;
#ifdef CONFIG_DEBUG_FS;
struct debugfs_blob_wrapper drom_blob;
#endif;
};
No cap, that's the whole thing verbatim π copy it exactly, don't be cute with it.
π¦ MEMBERS π¦
Okay so every single field, one by one, no skipping, we're getting through this together π«Ά
devβ The device for the switch. Her actual device struct, the whole reason she shows up in sysfs and all that.configβ The switch configuration. It's astruct tb_regs_switch_header, iykyk.portsβ The ports in this switch. Plural, she has many β¨dma_portβ So if the switch has a port that supports the DMA-configuration-based mailbox, this bad boy holds a pointer to it (NULLotherwise). And it's giving multipurpose, because if it's set, that also means the switch has upgradeable NVM πtmuβ The switch TMU configuration.tbβ Pointer to the domain the switch belongs to.uidβ The unique ID of the switch. Very main character, very one-of-one πuuidβ The UUID of the switch, orNULLif that's not supported.vendorβ Vendor ID of the switch.deviceβ Device ID of the switch.vendor_nameβ Name of the vendor, orNULLif it's not known. Not us guessing, that's literally what the field says πdevice_nameβ Name of the device, orNULLif it's not known.link_speedβ Speed of the link, in Gb/s.link_widthβ Width of the upstream facing link.preferred_link_widthβ The router's preferred link width, and heads up: this is only set for Gen 4 links πlink_usb4β Whether the upstream link is USB4.generationβ The switch's Thunderbolt generation.cap_plug_eventsβ Offset to the plug events capability (0if it's not found).cap_vsec_tmuβ Offset to the TMU vendor specific capability (0if it's not found).cap_lcβ Offset to the link controller capability (0if it's not found).cap_lpβ Offset to the low power (CLx for TBT) capability (0if it's not found).is_unpluggedβ The switch is going away π yeah, she's leaving.dromβ The DROM of the switch (NULLif it's not found).nvmβ Pointer to the NVM if the switch has one (NULLotherwise).no_nvm_upgradeβ Prevents NVM upgrade of this switch. Respect the boundary π«safe_modeβ The switch is in safe-mode.bootβ Whether the switch was already authorized on boot or not.rpmβ The switch supports runtime PM.authorizedβ Whether the switch is authorized by user or policy.security_levelβ The switch's supported security level. It's anenum tb_security_level, look it up bestie πdebugfs_dirβ Pointer to the debugfs structure.keyβ Contains the key used to challenge the device, orNULLif it's not supported. Size of the key isTB_SWITCH_KEY_SIZEβ write that down βοΈconnection_idβ Connection ID used with ICM messaging.connection_keyβ Connection key used with ICM messaging.linkβ Root switch link this switch is connected to (ICM only).depthβ Depth in the chain this switch is connected at (ICM only).rpm_completeβ Completion used to wait for runtime resume to complete (ICM only).quirksβ Quirks used for this Thunderbolt switch. Everybody's got their little quirks fr fr πcredit_allocationβ Are the below buffer allocation parameters valid. She's the vibe check for the next five fields πmax_usb3_creditsβ Router preferred number of buffers for USB 3.x.min_dp_aux_creditsβ Router preferred minimum number of buffers for DP AUX. Note the minimum, don't get it twisted πmin_dp_main_creditsβ Router preferred minimum number of buffers for DP MAIN.max_pcie_creditsβ Router preferred number of buffers for PCIe.max_dma_creditsβ Router preferred number of buffers for DMA/P2P.clxβ CLx states on the upstream link of the router.drom_blobβ DROM debugfs blob wrapper. And psst β this one lives inside#ifdef CONFIG_DEBUG_FS;, so she only exists when debugfs is configured π§
π DESCRIPTION π
So here's the important bit, don't skip it:
When the switch is being added or removed to the domain (other switches), you need to have the domain lock held. π Like, non-negotiable. Hold the lock. That's the rule.
And in USB4 terminology, this structure represents a router. Same girl, different name, periodt π
β SEE ALSO β
Kernel file ./drivers/thunderbolt/tb.h β and like, all of these, in one big group-chat of related pages:
struct tb_nvm(9), enum tb_switch_tmu_mode(9), struct tb_switch_tmu(9), struct tb_bandwidth_group(9), struct tb_port(9), struct usb4_port(9), struct tb_retimer(9), struct tb_path_hop(9), enum tb_path_port(9), struct tb_path(9), struct tb_cm_ops(9), tb_upstream_port(9), tb_is_upstream_port(9), tb_port_has_remote(9), tb_domain_event(9), tb_switch_for_each_port(9), tb_switch_downstream_port(9), tb_switch_depth(9), tb_switch_is_icm(9), tb_switch_tmu_is_configured(9), tb_switch_tmu_is_enabled(9), tb_switch_clx_is_enabled(9), tb_port_path_direction_downstream(9), tb_for_each_port_on_path(9), tb_for_each_upstream_port_on_path(9), tb_path_for_each_hop(9), tb_downstream_route(9), tb_xdomain_downstream_port(9), usb4_switch_version(9), tb_switch_is_usb4(9), enum usb4_sb_target(9), enum usb4_margin_sw_error_counter(9), struct usb4_port_margining_params(9)
That's the whole page, bestie β go read some kernel source, you ate this πβ¨
Signed off from ./drivers/thunderbolt, dated October 2026, page struct tb_switch(9) β mwah ππ«Ά
π¦ 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