On Tue, Mar 23, 2021 at 05:57:01PM +0300, Mika Westerberg wrote: > This exposes two new attributes under each device router: usb3 and dp > that hold number of tunnels ending to this switch. These attributes are > only available if the connection manager supports it (tunneling_details > attribute reads 1). Currently only the software connection manager > supports this. > > Based on these userspace can show the user more detailed information > what is going on. > > Signed-off-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > --- > .../ABI/testing/sysfs-bus-thunderbolt | 26 +++++++++++ > drivers/thunderbolt/domain.c | 10 +++++ > drivers/thunderbolt/switch.c | 29 ++++++++++++ > drivers/thunderbolt/tb.c | 44 ++++++++++++++----- > drivers/thunderbolt/tb.h | 4 ++ > include/linux/thunderbolt.h | 6 +++ > 6 files changed, 108 insertions(+), 11 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-thunderbolt b/Documentation/ABI/testing/sysfs-bus-thunderbolt > index c41c68f64693..1569be391ca6 100644 > --- a/Documentation/ABI/testing/sysfs-bus-thunderbolt > +++ b/Documentation/ABI/testing/sysfs-bus-thunderbolt > @@ -61,6 +61,14 @@ Description: This attribute holds current Thunderbolt security level > the BIOS. > ======= ================================================== > > +What: /sys/bus/thunderbolt/devices/.../domainX/tunneling_details > +Date: July 2021 > +KernelVersion: 5.13 > +Contact: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > +Description: The connection manager implementation may expose > + additional details about tunneling. If it supports this > + the attribute reads 1. > + > What: /sys/bus/thunderbolt/devices/.../authorized > Date: Sep 2017 > KernelVersion: 4.13 > @@ -102,6 +110,15 @@ Contact: thunderbolt-software@xxxxxxxxxxxx > Description: This attribute contains 1 if Thunderbolt device was already > authorized on boot and 0 otherwise. > > +What: /sys/bus/thunderbolt/devices/.../dp > +Date: Jul 2021 > +KernelVersion: 5.13 > +Contact: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > +Description: Only available if the domain tunneling_details attribute > + reads 1. If present means that the device router has > + DisplayPort sink. Contents will be number how many > + active DisplayPort tunnels end up to this router. > + > What: /sys/bus/thunderbolt/devices/.../generation > Date: Jan 2020 > KernelVersion: 5.5 > @@ -169,6 +186,15 @@ Contact: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > Description: This attribute reports number of TX lanes the device is > using simultaneusly through its upstream port. > > +What: /sys/bus/thunderbolt/devices/.../usb3 > +Date: Jul 2021 > +KernelVersion: 5.13 > +Contact: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx> > +Description: Only available if the domain tunneling_details attribute > + reads 1. If present means that the device router has > + USB 3.x upstream adapter. Reads 1 if there is an active > + USB 3.x tunnel to this router. > + > What: /sys/bus/thunderbolt/devices/.../vendor > Date: Sep 2017 > KernelVersion: 4.13 > diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c > index 98f4056f89ff..d86b0864f870 100644 > --- a/drivers/thunderbolt/domain.c > +++ b/drivers/thunderbolt/domain.c > @@ -282,11 +282,21 @@ static ssize_t security_show(struct device *dev, struct device_attribute *attr, > } > static DEVICE_ATTR_RO(security); > > +static ssize_t tunneling_details_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + const struct tb *tb = container_of(dev, struct tb, dev); > + > + return sprintf(buf, "%d\n", !!(tb->cm_caps & TB_CAP_TUNNEL_DETAILS)); sysfs_emit() please. thanks, greg k-h