|
10 | 10 | #include <linux/slab.h> |
11 | 11 | #include <linux/list.h> |
12 | 12 | #include <linux/ktime.h> |
| 13 | +#include <linux/string_helpers.h> |
13 | 14 |
|
14 | 15 | #include "tunnel.h" |
15 | 16 | #include "tb.h" |
@@ -153,18 +154,49 @@ static struct tb_tunnel *tb_tunnel_alloc(struct tb *tb, size_t npaths, |
153 | 154 | return tunnel; |
154 | 155 | } |
155 | 156 |
|
| 157 | +static int tb_pci_set_ext_encapsulation(struct tb_tunnel *tunnel, bool enable) |
| 158 | +{ |
| 159 | + int ret; |
| 160 | + |
| 161 | + /* Only supported of both routers are at least USB4 v2 */ |
| 162 | + if (usb4_switch_version(tunnel->src_port->sw) < 2 || |
| 163 | + usb4_switch_version(tunnel->dst_port->sw) < 2) |
| 164 | + return 0; |
| 165 | + |
| 166 | + ret = usb4_pci_port_set_ext_encapsulation(tunnel->src_port, enable); |
| 167 | + if (ret) |
| 168 | + return ret; |
| 169 | + |
| 170 | + ret = usb4_pci_port_set_ext_encapsulation(tunnel->dst_port, enable); |
| 171 | + if (ret) |
| 172 | + return ret; |
| 173 | + |
| 174 | + tb_tunnel_dbg(tunnel, "extended encapsulation %s\n", |
| 175 | + str_enabled_disabled(enable)); |
| 176 | + return 0; |
| 177 | +} |
| 178 | + |
156 | 179 | static int tb_pci_activate(struct tb_tunnel *tunnel, bool activate) |
157 | 180 | { |
158 | 181 | int res; |
159 | 182 |
|
| 183 | + if (activate) { |
| 184 | + res = tb_pci_set_ext_encapsulation(tunnel, activate); |
| 185 | + if (res) |
| 186 | + return res; |
| 187 | + } |
| 188 | + |
160 | 189 | res = tb_pci_port_enable(tunnel->src_port, activate); |
161 | 190 | if (res) |
162 | 191 | return res; |
163 | 192 |
|
164 | | - if (tb_port_is_pcie_up(tunnel->dst_port)) |
165 | | - return tb_pci_port_enable(tunnel->dst_port, activate); |
| 193 | + if (tb_port_is_pcie_up(tunnel->dst_port)) { |
| 194 | + res = tb_pci_port_enable(tunnel->dst_port, activate); |
| 195 | + if (res) |
| 196 | + return res; |
| 197 | + } |
166 | 198 |
|
167 | | - return 0; |
| 199 | + return activate ? 0 : tb_pci_set_ext_encapsulation(tunnel, activate); |
168 | 200 | } |
169 | 201 |
|
170 | 202 | static int tb_pci_init_credits(struct tb_path_hop *hop) |
|
0 commit comments