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>
30 * struct tb_nvm - Structure holding NVM information
36 * @non_active: Non-active portion NVMem device
65 * enum tb_switch_tmu_rate - TMU refresh rate
81 * struct tb_switch_tmu - Structure holding switch TMU configuration
83 * @has_ucap: Does the switch support uni-directional mode
86 * @unidirectional: Is the TMU in uni-directional or bi-directional mode
97 * struct tb_switch - a thunderbolt switch
101 * @dma_port: If the switch has port supporting DMA configuration based
123 * @safe_mode: The switch is in safe-mode
181 * struct tb_port - a thunderbolt port, part of a tb_switch
223 * @index: Retimer index facing the router USB4 port
242 * struct tb_path_hop - routing information for a tb_path
249 * currently, %-1 to disable)
257 * next hop to take (on out_port->remote) is determined by
258 * next_hop_index. When routing packet to another switch (out->remote is
275 * enum tb_path_port - path options mask
291 * struct tb_path - a unidirectional path between two ports
330 /* HopIDs 0-7 are reserved by the Thunderbolt protocol */
333 * Support paths from the farthest (depth 6) router to the host and back
334 * to the same level (not necessarily to the same router).
346 * struct tb_cm_ops - Connection manager specific operations vector
368 * @approve_xdomain_paths: Approve (establish) XDomain DMA paths
369 * @disconnect_xdomain_paths: Disconnect XDomain DMA paths
400 return (void *)tb->privdata; in tb_priv()
408 * tb_upstream_port() - return the upstream port of a switch
412 * During switch alloc/init tb_upstream_port()->remote may be NULL, even for
419 return &sw->ports[sw->config.upstream_port_number]; in tb_upstream_port()
423 * tb_is_upstream_port() - Is the port upstream facing
431 const struct tb_port *upstream_port = tb_upstream_port(port->sw); in tb_is_upstream_port()
432 return port == upstream_port || port->dual_link_port == upstream_port; in tb_is_upstream_port()
437 return ((u64) sw->config.route_hi) << 32 | sw->config.route_lo; in tb_route()
444 port = route >> (sw->config.depth * 8); in tb_port_at()
445 if (WARN_ON(port > sw->config.max_port_number)) in tb_port_at()
447 return &sw->ports[port]; in tb_port_at()
451 * tb_port_has_remote() - Does the port have switch connected downstream
460 if (!port->remote) in tb_port_has_remote()
462 if (port->dual_link_port && port->link_nr) in tb_port_has_remote()
470 return port && port->port && port->config.type == TB_TYPE_PORT; in tb_port_is_null()
475 return port && port->config.type == TB_TYPE_NHI; in tb_port_is_nhi()
480 return port && port->config.type == TB_TYPE_PCIE_DOWN; in tb_port_is_pcie_down()
485 return port && port->config.type == TB_TYPE_PCIE_UP; in tb_port_is_pcie_up()
490 return port && port->config.type == TB_TYPE_DP_HDMI_IN; in tb_port_is_dpin()
495 return port && port->config.type == TB_TYPE_DP_HDMI_OUT; in tb_port_is_dpout()
500 return port && port->config.type == TB_TYPE_USB3_DOWN; in tb_port_is_usb3_down()
505 return port && port->config.type == TB_TYPE_USB3_UP; in tb_port_is_usb3_up()
511 if (sw->is_unplugged) in tb_sw_read()
512 return -ENODEV; in tb_sw_read()
513 return tb_cfg_read(sw->tb->ctl, in tb_sw_read()
525 if (sw->is_unplugged) in tb_sw_write()
526 return -ENODEV; in tb_sw_write()
527 return tb_cfg_write(sw->tb->ctl, in tb_sw_write()
539 if (port->sw->is_unplugged) in tb_port_read()
540 return -ENODEV; in tb_port_read()
541 return tb_cfg_read(port->sw->tb->ctl, in tb_port_read()
543 tb_route(port->sw), in tb_port_read()
544 port->port, in tb_port_read()
553 if (port->sw->is_unplugged) in tb_port_write()
554 return -ENODEV; in tb_port_write()
555 return tb_cfg_write(port->sw->tb->ctl, in tb_port_write()
557 tb_route(port->sw), in tb_port_write()
558 port->port, in tb_port_write()
564 #define tb_err(tb, fmt, arg...) dev_err(&(tb)->nhi->pdev->dev, fmt, ## arg)
565 #define tb_WARN(tb, fmt, arg...) dev_WARN(&(tb)->nhi->pdev->dev, fmt, ## arg)
566 #define tb_warn(tb, fmt, arg...) dev_warn(&(tb)->nhi->pdev->dev, fmt, ## arg)
567 #define tb_info(tb, fmt, arg...) dev_info(&(tb)->nhi->pdev->dev, fmt, ## arg)
568 #define tb_dbg(tb, fmt, arg...) dev_dbg(&(tb)->nhi->pdev->dev, fmt, ## arg)
573 level(__sw->tb, "%llx: " fmt, \
584 level(__port->sw->tb, "%llx:%x: " fmt, \
585 tb_route(__port->sw), __port->port, ## arg); \
630 get_device(&tb->dev); in tb_domain_get()
636 put_device(&tb->dev); in tb_domain_put()
667 * tb_switch_for_each_port() - Iterate over each switch port
674 for ((p) = &(sw)->ports[1]; \
675 (p) <= &(sw)->ports[(sw)->config.max_port_number]; (p)++)
680 get_device(&sw->dev); in tb_switch_get()
686 put_device(&sw->dev); in tb_switch_put()
691 return dev->type == &tb_switch_type; in tb_is_switch()
703 return tb_to_switch(sw->dev.parent); in tb_switch_parent()
708 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_light_ridge()
709 sw->config.device_id == PCI_DEVICE_ID_INTEL_LIGHT_RIDGE; in tb_switch_is_light_ridge()
714 return sw->config.vendor_id == PCI_VENDOR_ID_INTEL && in tb_switch_is_eagle_ridge()
715 sw->config.device_id == PCI_DEVICE_ID_INTEL_EAGLE_RIDGE; in tb_switch_is_eagle_ridge()
720 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_cactus_ridge()
721 switch (sw->config.device_id) { in tb_switch_is_cactus_ridge()
732 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_falcon_ridge()
733 switch (sw->config.device_id) { in tb_switch_is_falcon_ridge()
744 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_alpine_ridge()
745 switch (sw->config.device_id) { in tb_switch_is_alpine_ridge()
758 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_titan_ridge()
759 switch (sw->config.device_id) { in tb_switch_is_titan_ridge()
771 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_ice_lake()
772 switch (sw->config.device_id) { in tb_switch_is_ice_lake()
783 if (sw->config.vendor_id == PCI_VENDOR_ID_INTEL) { in tb_switch_is_tiger_lake()
784 switch (sw->config.device_id) { in tb_switch_is_tiger_lake()
796 * tb_switch_is_usb4() - Is the switch USB4 compliant
799 * Returns true if the @sw is USB4 compliant router, false otherwise.
803 return sw->config.thunderbolt_version == USB4_VERSION_1_0; in tb_switch_is_usb4()
807 * tb_switch_is_icm() - Is the switch handled by ICM firmware
817 return !sw->config.enabled; in tb_switch_is_icm()
836 return sw->tmu.rate == TB_SWITCH_TMU_RATE_HIFI && in tb_switch_tmu_is_enabled()
837 !sw->tmu.unidirectional; in tb_switch_tmu_is_enabled()
855 * tb_for_each_port_on_path() - Iterate over each port on path
919 return (fls64(route) + TB_ROUTE_SHIFT - 1) / TB_ROUTE_SHIFT; in tb_route_length()
923 * tb_downstream_route() - get route to downstream switch
931 return tb_route(port->sw) in tb_downstream_route()
932 | ((u64) port->port << (port->sw->config.depth * 8)); in tb_downstream_route()
950 return dev->type == &tb_retimer_type; in tb_is_retimer()