1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Thunderbolt driver - Tunneling support
5 * Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
6 * Copyright (C) 2019, Intel Corporation
21 * struct tb_tunnel - Tunnel between two ports
22 * @tb: Pointer to the domain
23 * @src_port: Source port of the tunnel
24 * @dst_port: Destination port of the tunnel. For discovered incomplete
25 * tunnels may be %NULL or null adapter port instead.
26 * @paths: All paths required by the tunnel
27 * @npaths: Number of paths in @paths
28 * @init: Optional tunnel specific initialization
29 * @activate: Optional tunnel specific activation/deactivation
30 * @list: Tunnels are linked using this field
31 * @type: Type of the tunnel
35 struct tb_port
*src_port
;
36 struct tb_port
*dst_port
;
37 struct tb_path
**paths
;
39 int (*init
)(struct tb_tunnel
*tunnel
);
40 int (*activate
)(struct tb_tunnel
*tunnel
, bool activate
);
41 struct list_head list
;
42 enum tb_tunnel_type type
;
45 struct tb_tunnel
*tb_tunnel_discover_pci(struct tb
*tb
, struct tb_port
*down
);
46 struct tb_tunnel
*tb_tunnel_alloc_pci(struct tb
*tb
, struct tb_port
*up
,
47 struct tb_port
*down
);
48 struct tb_tunnel
*tb_tunnel_discover_dp(struct tb
*tb
, struct tb_port
*in
);
49 struct tb_tunnel
*tb_tunnel_alloc_dp(struct tb
*tb
, struct tb_port
*in
,
51 struct tb_tunnel
*tb_tunnel_alloc_dma(struct tb
*tb
, struct tb_port
*nhi
,
52 struct tb_port
*dst
, int transmit_ring
,
53 int transmit_path
, int receive_ring
,
56 void tb_tunnel_free(struct tb_tunnel
*tunnel
);
57 int tb_tunnel_activate(struct tb_tunnel
*tunnel
);
58 int tb_tunnel_restart(struct tb_tunnel
*tunnel
);
59 void tb_tunnel_deactivate(struct tb_tunnel
*tunnel
);
60 bool tb_tunnel_is_invalid(struct tb_tunnel
*tunnel
);
62 static inline bool tb_tunnel_is_pci(const struct tb_tunnel
*tunnel
)
64 return tunnel
->type
== TB_TUNNEL_PCI
;
67 static inline bool tb_tunnel_is_dp(const struct tb_tunnel
*tunnel
)
69 return tunnel
->type
== TB_TUNNEL_DP
;
72 static inline bool tb_tunnel_is_dma(const struct tb_tunnel
*tunnel
)
74 return tunnel
->type
== TB_TUNNEL_DMA
;