Lines Matching +full:dma +full:- +full:router
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Thunderbolt driver - bus logic (NHI independent)
12 #include <linux/nvmem-provider.h>
31 * struct tb_nvm - Structure holding NVM information
37 * @non_active: Non-active portion NVMem device
72 * enum tb_switch_tmu_rate - TMU refresh rate
88 * struct tb_switch_tmu - Structure holding switch TMU configuration
90 * @has_ucap: Does the switch support uni-directional mode
93 * @unidirectional: Is the TMU in uni-directional or bi-directional mode
104 * struct tb_switch - a thunderbolt switch
108 * @dma_port: If the switch has port supporting DMA configuration based
130 * @safe_mode: The switch is in safe-mode
146 * @max_usb3_credits: Router preferred number of buffers for USB 3.x
147 * @min_dp_aux_credits: Router preferred minimum number of buffers for DP AUX
148 * @min_dp_main_credits: Router preferred minimum number of buffers for DP MAIN
149 * @max_pcie_credits: Router preferred number of buffers for PCIe
150 * @max_dma_credits: Router preferred number of buffers for DMA/P2P
155 * In USB4 terminology this structure represents a router.
202 * struct tb_port - a thunderbolt port, part of a tb_switch
223 * @dma_credits: Number of credits allocated for DMA tunneling for all
224 * DMA paths through this port.
253 * struct usb4_port - USB4 port device
271 * @index: Retimer index facing the router USB4 port
290 * struct tb_path_hop - routing information for a tb_path
297 * currently, %-1 to disable)
301 * @nfc_credits: Number of non-flow controlled buffers allocated for the
307 * next hop to take (on out_port->remote) is determined by
308 * next_hop_index. When routing packet to another switch (out->remote is
326 * enum tb_path_port - path options mask
342 * struct tb_path - a unidirectional path between two ports
379 /* HopIDs 0-7 are reserved by the Thunderbolt protocol */
382 * Support paths from the farthest (depth 6) router to the host and back
383 * to the same level (not necessarily to the same router).
396 * struct tb_cm_ops - Connection manager specific operations vector
419 * @approve_xdomain_paths: Approve (establish) XDomain DMA paths
420 * @disconnect_xdomain_paths: Disconnect XDomain DMA paths
421 * @usb4_switch_op: Optional proxy for USB4 router operations. If set
422 * this will be called whenever USB4 router operation is
423 * performed. If this returns %-EOPNOTSUPP then the
424 * native USB4 router operation is called.
428 * router operation.
469 return (void *)tb->privdata; in tb_priv()
477 * tb_upstream_port() - return the upstream port of a switch
481 * During switch alloc/init tb_upstream_port()->remote may be NULL, even for
488 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
492 * tb_is_upstream_port() - Is the port upstream facing
500 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
501 return port == upstream_port || port->dual_link_port == upstream_port; in tb_is_upstream_port()
506 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
513 port = route >> (sw->config.depth * 8); in tb_port_at()
514 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
516 return &sw->ports[port]; in tb_port_at()
520 * tb_port_has_remote() - Does the port have switch connected downstream
529 if (!port->remote) in tb_port_has_remote()
531 if (port->dual_link_port && port->link_nr) in tb_port_has_remote()
539 return port && port->port && port->config.type == TB_TYPE_PORT; in tb_port_is_null()
544 return port && port->config.type == TB_TYPE_NHI; in tb_port_is_nhi()
549 return port && port->config.type == TB_TYPE_PCIE_DOWN; in tb_port_is_pcie_down()
554 return port && port->config.type == TB_TYPE_PCIE_UP; in tb_port_is_pcie_up()
559 return port && port->config.type == TB_TYPE_DP_HDMI_IN; in tb_port_is_dpin()
564 return port && port->config.type == TB_TYPE_DP_HDMI_OUT; in tb_port_is_dpout()
569 return port && port->config.type == TB_TYPE_USB3_DOWN; in tb_port_is_usb3_down()
574 return port && port->config.type == TB_TYPE_USB3_UP; in tb_port_is_usb3_up()
580 if (sw->is_unplugged) in tb_sw_read()
581 return -ENODEV; in tb_sw_read()
582 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
594 if (sw->is_unplugged) in tb_sw_write()
595 return -ENODEV; in tb_sw_write()
596 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
608 if (port->sw->is_unplugged) in tb_port_read()
609 return -ENODEV; in tb_port_read()
610 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
612 tb_route(port->sw), in tb_port_read()
613 port->port, in tb_port_read()
622 if (port->sw->is_unplugged) in tb_port_write()
623 return -ENODEV; in tb_port_write()
624 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
626 tb_route(port->sw), in tb_port_write()
627 port->port, in tb_port_write()
633 #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
634 #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
635 #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
636 #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
637 #define tb_dbg(tb, fmt, arg...) dev_dbg(&(tb)->nhi->pdev->dev, fmt, ## arg)
642 level(__sw->tb, "%llx: " fmt, \
653 level(__port->sw->tb, "%llx:%x: " fmt, \
654 tb_route(__port->sw), __port->port, ## arg); \
705 get_device(&tb->dev); in tb_domain_get()
711 put_device(&tb->dev); in tb_domain_put()
752 * tb_switch_for_each_port() - Iterate over each switch port
759 for ((p) = &(sw)->ports[1]; \
760 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
765 get_device(&sw->dev); in tb_switch_get()
771 put_device(&sw->dev); in tb_switch_put()
776 return dev->type == &tb_switch_type; in tb_is_switch()
788 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
793 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
794 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
799 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
800 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
805 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
806 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
817 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
818 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
829 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
830 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
843 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
844 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
855 * tb_switch_is_usb4() - Is the switch USB4 compliant
858 * Returns true if the @sw is USB4 compliant router, false otherwise.
862 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
866 * tb_switch_is_icm() - Is the switch handled by ICM firmware
876 return !sw->config.enabled; in tb_switch_is_icm()
895 return sw->tmu.rate == TB_SWITCH_TMU_RATE_HIFI && in tb_switch_tmu_is_enabled()
896 !sw->tmu.unidirectional; in tb_switch_tmu_is_enabled()
914 return tb_port_is_null(port) && port->sw->credit_allocation; in tb_port_use_credit_allocation()
918 * tb_for_each_port_on_path() - Iterate over each port on path
972 * tb_path_for_each_hop() - Iterate over each hop on path
979 for ((hop) = &(path)->hops[0]; \
980 (hop) <= &(path)->hops[(path)->path_length - 1]; (hop)++)
1001 return (fls64(route) + TB_ROUTE_SHIFT - 1) / TB_ROUTE_SHIFT; in tb_route_length()
1005 * tb_downstream_route() - get route to downstream switch
1013 return tb_route(port->sw) in tb_downstream_route()
1014 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
1033 return dev->type == &tb_retimer_type; in tb_is_retimer()
1107 return dev->type == &usb4_port_device_type; in tb_is_usb4_port_device()