0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef TB_TUNNEL_H_
0010 #define TB_TUNNEL_H_
0011
0012 #include "tb.h"
0013
0014 enum tb_tunnel_type {
0015 TB_TUNNEL_PCI,
0016 TB_TUNNEL_DP,
0017 TB_TUNNEL_DMA,
0018 TB_TUNNEL_USB3,
0019 };
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 struct tb_tunnel {
0045 struct tb *tb;
0046 struct tb_port *src_port;
0047 struct tb_port *dst_port;
0048 struct tb_path **paths;
0049 size_t npaths;
0050 int (*init)(struct tb_tunnel *tunnel);
0051 void (*deinit)(struct tb_tunnel *tunnel);
0052 int (*activate)(struct tb_tunnel *tunnel, bool activate);
0053 int (*consumed_bandwidth)(struct tb_tunnel *tunnel, int *consumed_up,
0054 int *consumed_down);
0055 int (*release_unused_bandwidth)(struct tb_tunnel *tunnel);
0056 void (*reclaim_available_bandwidth)(struct tb_tunnel *tunnel,
0057 int *available_up,
0058 int *available_down);
0059 struct list_head list;
0060 enum tb_tunnel_type type;
0061 int max_up;
0062 int max_down;
0063 int allocated_up;
0064 int allocated_down;
0065 };
0066
0067 struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down,
0068 bool alloc_hopid);
0069 struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up,
0070 struct tb_port *down);
0071 struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in,
0072 bool alloc_hopid);
0073 struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in,
0074 struct tb_port *out, int link_nr,
0075 int max_up, int max_down);
0076 struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
0077 struct tb_port *dst, int transmit_path,
0078 int transmit_ring, int receive_path,
0079 int receive_ring);
0080 bool tb_tunnel_match_dma(const struct tb_tunnel *tunnel, int transmit_path,
0081 int transmit_ring, int receive_path, int receive_ring);
0082 struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down,
0083 bool alloc_hopid);
0084 struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
0085 struct tb_port *down, int max_up,
0086 int max_down);
0087
0088 void tb_tunnel_free(struct tb_tunnel *tunnel);
0089 int tb_tunnel_activate(struct tb_tunnel *tunnel);
0090 int tb_tunnel_restart(struct tb_tunnel *tunnel);
0091 void tb_tunnel_deactivate(struct tb_tunnel *tunnel);
0092 bool tb_tunnel_is_invalid(struct tb_tunnel *tunnel);
0093 bool tb_tunnel_port_on_path(const struct tb_tunnel *tunnel,
0094 const struct tb_port *port);
0095 int tb_tunnel_consumed_bandwidth(struct tb_tunnel *tunnel, int *consumed_up,
0096 int *consumed_down);
0097 int tb_tunnel_release_unused_bandwidth(struct tb_tunnel *tunnel);
0098 void tb_tunnel_reclaim_available_bandwidth(struct tb_tunnel *tunnel,
0099 int *available_up,
0100 int *available_down);
0101
0102 static inline bool tb_tunnel_is_pci(const struct tb_tunnel *tunnel)
0103 {
0104 return tunnel->type == TB_TUNNEL_PCI;
0105 }
0106
0107 static inline bool tb_tunnel_is_dp(const struct tb_tunnel *tunnel)
0108 {
0109 return tunnel->type == TB_TUNNEL_DP;
0110 }
0111
0112 static inline bool tb_tunnel_is_dma(const struct tb_tunnel *tunnel)
0113 {
0114 return tunnel->type == TB_TUNNEL_DMA;
0115 }
0116
0117 static inline bool tb_tunnel_is_usb3(const struct tb_tunnel *tunnel)
0118 {
0119 return tunnel->type == TB_TUNNEL_USB3;
0120 }
0121
0122 #endif
0123