thunderbolt: Generalize tunnel creation functionality

To be able to tunnel non-PCIe traffic, separate tunnel functionality
into generic and PCIe specific parts. Rename struct tb_pci_tunnel to
tb_tunnel, and make it hold an array of paths instead of just two.
Update all the tunneling functions to take this structure as parameter.

We also move tb_pci_port_active() to switch.c (and rename it) where we
will be keeping all port and switch related functions.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
This commit is contained in:
Mika Westerberg
2017-02-19 13:48:29 +02:00
parent 1752b9f787
commit 93f36ade5b
6 changed files with 235 additions and 150 deletions

View File

@@ -1,8 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Thunderbolt Cactus Ridge driver - Tunneling support
* Thunderbolt driver - Tunneling support
*
* Copyright (c) 2014 Andreas Noever <andreas.noever@gmail.com>
* Copyright (C) 2019, Intel Corporation
*/
#ifndef TB_TUNNEL_H_
@@ -10,22 +11,33 @@
#include "tb.h"
struct tb_pci_tunnel {
/**
* struct tb_tunnel - Tunnel between two ports
* @tb: Pointer to the domain
* @src_port: Source port of the tunnel
* @dst_port: Destination port of the tunnel
* @paths: All paths required by the tunnel
* @npaths: Number of paths in @paths
* @activate: Optional tunnel specific activation/deactivation
* @list: Tunnels are linked using this field
*/
struct tb_tunnel {
struct tb *tb;
struct tb_port *up_port;
struct tb_port *down_port;
struct tb_path *path_to_up;
struct tb_path *path_to_down;
struct tb_port *src_port;
struct tb_port *dst_port;
struct tb_path **paths;
size_t npaths;
int (*activate)(struct tb_tunnel *tunnel, bool activate);
struct list_head list;
};
struct tb_pci_tunnel *tb_pci_alloc(struct tb *tb, struct tb_port *up,
struct tb_port *down);
void tb_pci_free(struct tb_pci_tunnel *tunnel);
int tb_pci_activate(struct tb_pci_tunnel *tunnel);
int tb_pci_restart(struct tb_pci_tunnel *tunnel);
void tb_pci_deactivate(struct tb_pci_tunnel *tunnel);
bool tb_pci_is_invalid(struct tb_pci_tunnel *tunnel);
struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up,
struct tb_port *down);
void tb_tunnel_free(struct tb_tunnel *tunnel);
int tb_tunnel_activate(struct tb_tunnel *tunnel);
int tb_tunnel_restart(struct tb_tunnel *tunnel);
void tb_tunnel_deactivate(struct tb_tunnel *tunnel);
bool tb_tunnel_is_invalid(struct tb_tunnel *tunnel);
#endif