Lines Matching +full:ports +full:- +full:lane +full:- +full:control

1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Thunderbolt driver - bus logic (NHI independent)
12 #include <linux/nvmem-provider.h>
30 * struct tb_nvm - Structure holding NVM information
37 * @non_active: Non-active portion NVMem device
78 * enum tb_switch_tmu_mode - TMU mode
80 * @TB_SWITCH_TMU_MODE_LOWRES: Uni-directional, normal mode
81 * @TB_SWITCH_TMU_MODE_HIFI_UNI: Uni-directional, HiFi mode
82 * @TB_SWITCH_TMU_MODE_HIFI_BI: Bi-directional, HiFi mode
83 * @TB_SWITCH_TMU_MODE_MEDRES_ENHANCED_UNI: Enhanced Uni-directional, MedRes mode
96 * struct tb_switch_tmu - Structure holding router TMU configuration
98 * @has_ucap: Does the switch support uni-directional mode
112 * struct tb_switch - a thunderbolt switch
115 * @ports: Ports in this switch
141 * @safe_mode: The switch is in safe-mode
172 struct tb_port *ports; member
218 * struct tb_bandwidth_group - Bandwidth management group
220 * @index: Index of the group (aka Group_ID). Valid values %1-%7
221 * @ports: DP IN adapters belonging to this group are linked here
236 struct list_head ports; member
242 * struct tb_port - a thunderbolt port, part of a tb_switch
255 * @dual_link_port: If the switch is connected using two ports, points
260 * @list: Used to link ports to DP resources list
262 * @ctl_credits: Buffers reserved for control path
267 * @group_list: The adapter is linked to the group's list of ports through this
269 * non-zero.
273 * lane adapter).
303 * struct usb4_port - USB4 port device
305 * @port: Pointer to the lane 0 adapter
328 * @port: Pointer to the lane 0 adapter
350 * struct tb_path_hop - routing information for a tb_path
357 * currently, %-1 to disable)
359 * @initial_credits: Number of initial flow control credits allocated for
361 * @nfc_credits: Number of non-flow controlled buffers allocated for the
368 * next hop to take (on out_port->remote) is determined by
369 * next_hop_index. When routing packet to another switch (out->remote is
388 * enum tb_path_port - path options mask
404 * struct tb_path - a unidirectional path between two ports
407 * @ingress_shared_buffer: Shared buffering used for ingress ports on the path
408 * @egress_shared_buffer: Shared buffering used for egress ports on the path
409 * @ingress_fc_enable: Flow control for ingress ports on the path
410 * @egress_fc_enable: Flow control for egress ports on the path
415 * @clear_fc: Clear all flow control from the path config space entries
423 * PCIe ports.
443 /* HopIDs 0-7 are reserved by the Thunderbolt protocol */
465 * struct tb_cm_ops - Connection manager specific operations vector
466 * @driver_ready: Called right after control channel is started. Used by
471 * it is unregistered. Called without @tb->lock taken. Optional.
494 * performed. If this returns %-EOPNOTSUPP then the
541 return (void *)tb->privdata; in tb_priv()
549 * tb_upstream_port() - return the upstream port of a switch
553 * During switch alloc/init tb_upstream_port()->remote may be NULL, even for
560 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
564 * tb_is_upstream_port() - Is the port upstream facing
568 * ports both return true.
572 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
573 return port == upstream_port || port->dual_link_port == upstream_port; in tb_is_upstream_port()
578 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
585 port = route >> (sw->config.depth * 8); in tb_port_at()
586 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
588 return &sw->ports[port]; in tb_port_at()
595 return "symmetric, single lane"; in tb_width_name()
608 * tb_port_has_remote() - Does the port have switch connected downstream
617 if (!port->remote) in tb_port_has_remote()
619 if (port->dual_link_port && port->link_nr) in tb_port_has_remote()
627 return port && port->port && port->config.type == TB_TYPE_PORT; in tb_port_is_null()
632 return port && port->config.type == TB_TYPE_NHI; in tb_port_is_nhi()
637 return port && port->config.type == TB_TYPE_PCIE_DOWN; in tb_port_is_pcie_down()
642 return port && port->config.type == TB_TYPE_PCIE_UP; in tb_port_is_pcie_up()
647 return port && port->config.type == TB_TYPE_DP_HDMI_IN; in tb_port_is_dpin()
652 return port && port->config.type == TB_TYPE_DP_HDMI_OUT; in tb_port_is_dpout()
657 return port && port->config.type == TB_TYPE_USB3_DOWN; in tb_port_is_usb3_down()
662 return port && port->config.type == TB_TYPE_USB3_UP; in tb_port_is_usb3_up()
668 if (sw->is_unplugged) in tb_sw_read()
669 return -ENODEV; in tb_sw_read()
670 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
682 if (sw->is_unplugged) in tb_sw_write()
683 return -ENODEV; in tb_sw_write()
684 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
696 if (port->sw->is_unplugged) in tb_port_read()
697 return -ENODEV; in tb_port_read()
698 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
700 tb_route(port->sw), in tb_port_read()
701 port->port, in tb_port_read()
710 if (port->sw->is_unplugged) in tb_port_write()
711 return -ENODEV; in tb_port_write()
712 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
714 tb_route(port->sw), in tb_port_write()
715 port->port, in tb_port_write()
721 #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
722 #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
723 #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
724 #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
725 #define tb_dbg(tb, fmt, arg...) dev_dbg(&(tb)->nhi->pdev->dev, fmt, ## arg)
730 level(__sw->tb, "%llx: " fmt, \
741 level(__port->sw->tb, "%llx:%u: " fmt, \
742 tb_route(__port->sw), __port->port, ## arg); \
793 get_device(&tb->dev); in tb_domain_get()
799 put_device(&tb->dev); in tb_domain_put()
847 * tb_switch_for_each_port() - Iterate over each switch port
848 * @sw: Switch whose ports to iterate
851 * Iterates over each switch port skipping the control port (port %0).
854 for ((p) = &(sw)->ports[1]; \
855 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
860 get_device(&sw->dev); in tb_switch_get()
866 put_device(&sw->dev); in tb_switch_put()
871 return dev->type == &tb_switch_type; in tb_is_switch()
883 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
887 * tb_switch_downstream_port() - Return downstream facing port of parent router
901 * tb_switch_depth() - Returns depth of the connected router
906 return sw->config.depth; in tb_switch_depth()
911 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
912 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
917 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
918 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
923 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
924 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
935 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
936 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
947 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
948 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
962 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
963 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
975 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
976 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
988 * tb_switch_is_icm() - Is the switch handled by ICM firmware
998 return !sw->config.enabled; in tb_switch_is_icm()
1016 * tb_switch_tmu_is_configured() - Is given TMU mode configured
1026 return sw->tmu.mode_request == mode; in tb_switch_tmu_is_configured()
1030 * tb_switch_tmu_is_enabled() - Checks if the specified TMU mode is enabled
1038 return sw->tmu.mode != TB_SWITCH_TMU_MODE_OFF && in tb_switch_tmu_is_enabled()
1039 sw->tmu.mode == sw->tmu.mode_request; in tb_switch_tmu_is_enabled()
1049 * tb_switch_clx_is_enabled() - Checks if the CLx is enabled
1061 return sw->clx & clx; in tb_switch_clx_is_enabled()
1084 * tb_port_path_direction_downstream() - Checks if path directed downstream
1095 return src->sw->config.depth < dst->sw->config.depth; in tb_port_path_direction_downstream()
1100 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
1104 * tb_for_each_port_on_path() - Iterate over each port on path
1116 * tb_for_each_upstream_port_on_path() - Iterate over each upstreamm port on path
1121 * Walks over each upstream lane adapter on path from @src to @dst.
1177 * tb_path_for_each_hop() - Iterate over each hop on path
1184 for ((hop) = &(path)->hops[0]; \
1185 (hop) <= &(path)->hops[(path)->path_length - 1]; (hop)++)
1212 return (fls64(route) + TB_ROUTE_SHIFT - 1) / TB_ROUTE_SHIFT; in tb_route_length()
1216 * tb_downstream_route() - get route to downstream switch
1224 return tb_route(port->sw) in tb_downstream_route()
1225 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1241 return tb_to_switch(xd->dev.parent); in tb_xdomain_parent()
1245 * tb_xdomain_downstream_port() - Return downstream facing port of parent router
1252 return tb_port_at(xd->route, tb_xdomain_parent(xd)); in tb_xdomain_downstream_port()
1262 return dev->type == &tb_retimer_type; in tb_is_retimer()
1273 * usb4_switch_version() - Returns USB4 version of the router
1277 * on). Can be called to pre-USB4 router too and in that case returns %0.
1281 return FIELD_GET(USB4_VERSION_MAJOR_MASK, sw->config.thunderbolt_version); in usb4_switch_version()
1285 * tb_switch_is_usb4() - Is the switch USB4 compliant
1340 * enum tb_sb_target - Sideband transaction target
1357 * enum usb4_margin_sw_error_counter - Software margining error counter operation
1371 * struct usb4_port_margining_params - USB4 margining parameters
1445 return dev->type == &usb4_port_device_type; in tb_is_usb4_port_device()
1461 return usb4->offline; in usb4_port_device_is_offline()