tb_switch_for_each_port(9)
π tb_switch_for_each_port β a Kernel API Manual moment (section 9, bestie)
okay so this is tb_switch_for_each_port(9) from the Kernel API Manual, and honestly? it's a little macro baddie that just wants to walk you through every port on a switch. no cap, that's the whole vibe. π¦
β¨ NAME β¨
tb_switch_for_each_port β iterate over each switch port, one by one, iconic behaviour only π
πΈ SYNOPSIS πΈ
tb_switch_for_each_port (sw , p );
like yes that's the whole call, she's compact π
π ARGUMENTS π
swβ the switch whose ports you're about to iterate over. she's the main character here π«Άpβ the port that gets used as the iterator. lowkey just the loop variable doing her little walk π
β DESCRIPTION β
so it iterates over each switch port, right? but β and this is the important part, don't skip it β it skips the control port (port 0). literally port 0 is not invited to this party, she's the control port, she has other duties π
that's it. that's the whole behaviour. no hidden lore, fr fr.
ngl the port-0 skip is the entire personality of this macro, so if you're expecting port 0 in your loop, you will be π
π SEE ALSO π
the whole friend group, all of them, no one left out π§ β from the kernel file ./drivers/thunderbolt/tb.h:
struct tb_nvm(9)enum tb_switch_tmu_mode(9)struct tb_switch_tmu(9)struct tb_switch(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_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)
like, go read them, they're all giving thunderbolt lore π₯
π bye bestie π
this page lives in ./drivers/thunderbolt, and it's dated October 2026 β so mark your calendar, that's your source and your version, slay πβ¨π keep iterating (but not over port 0, we talked about this) ππ«Ά
π¦ 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