Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools headers UAPI: Sync usbdevice_fs.h with the kernels to get new ioctl

To get the changes in:

6d101f24f1dd ("USB: add usbfs ioctl to retrieve the connection parameters")

And address this perf build warning:

Warning: Kernel ABI header at 'tools/include/uapi/linux/usbdevice_fs.h' differs from latest version at 'include/uapi/linux/usbdevice_fs.h'
diff -u tools/include/uapi/linux/usbdevice_fs.h include/uapi/linux/usbdevice_fs.h

Which ends up autogenerating a ioctl_cmd->string table used by 'perf
trace':

$ tools/perf/trace/beauty/usbdevfs_ioctl.sh > before
$ cp include/uapi/linux/usbdevice_fs.h tools/include/uapi/linux/usbdevice_fs.h
$ tools/perf/trace/beauty/usbdevfs_ioctl.sh > after
$ diff -u before after
--- before 2019-07-26 15:26:55.513636844 -0300
+++ after 2019-07-26 15:29:11.650518677 -0300
@@ -23,6 +23,7 @@
[2] = "BULK",
[30] = "DROP_PRIVILEGES",
[31] = "GET_SPEED",
+ [32] = "CONNINFO_EX",
[3] = "RESETEP",
[4] = "SETINTERFACE",
[5] = "SETCONFIGURATION",
$

Now 'perf trace' ioctl beautifier will translate this new ioctl to a
string and at some point will allow filtering the 'ioctl' syscall with
something like this in a system wide strace-like sessin:

# perf trace -e ioctl/cmd=USBDEVFS_CONNINFO_EX/

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-tkdfbgzqypwco96b309c0ovd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+26
+26
tools/include/uapi/linux/usbdevice_fs.h
··· 76 76 unsigned char slow; 77 77 }; 78 78 79 + struct usbdevfs_conninfo_ex { 80 + __u32 size; /* Size of the structure from the kernel's */ 81 + /* point of view. Can be used by userspace */ 82 + /* to determine how much data can be */ 83 + /* used/trusted. */ 84 + __u32 busnum; /* USB bus number, as enumerated by the */ 85 + /* kernel, the device is connected to. */ 86 + __u32 devnum; /* Device address on the bus. */ 87 + __u32 speed; /* USB_SPEED_* constants from ch9.h */ 88 + __u8 num_ports; /* Number of ports the device is connected */ 89 + /* to on the way to the root hub. It may */ 90 + /* be bigger than size of 'ports' array so */ 91 + /* userspace can detect overflows. */ 92 + __u8 ports[7]; /* List of ports on the way from the root */ 93 + /* hub to the device. Current limit in */ 94 + /* USB specification is 7 tiers (root hub, */ 95 + /* 5 intermediate hubs, device), which */ 96 + /* gives at most 6 port entries. */ 97 + }; 98 + 79 99 #define USBDEVFS_URB_SHORT_NOT_OK 0x01 80 100 #define USBDEVFS_URB_ISO_ASAP 0x02 81 101 #define USBDEVFS_URB_BULK_CONTINUATION 0x04 ··· 157 137 #define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10 158 138 #define USBDEVFS_CAP_MMAP 0x20 159 139 #define USBDEVFS_CAP_DROP_PRIVILEGES 0x40 140 + #define USBDEVFS_CAP_CONNINFO_EX 0x80 160 141 161 142 /* USBDEVFS_DISCONNECT_CLAIM flags & struct */ 162 143 ··· 218 197 #define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams) 219 198 #define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32) 220 199 #define USBDEVFS_GET_SPEED _IO('U', 31) 200 + /* 201 + * Returns struct usbdevfs_conninfo_ex; length is variable to allow 202 + * extending size of the data returned. 203 + */ 204 + #define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len) 221 205 222 206 #endif /* _UAPI_LINUX_USBDEVICE_FS_H */