2017-11-01 17:09:13 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
2012-10-13 13:46:48 +04:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* usbdevice_fs.h -- USB device file system.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000
|
|
|
|
* Thomas Sailer (sailer@ife.ee.ethz.ch)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* History:
|
|
|
|
* 0.1 04.01.2000 Created
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _UAPI_LINUX_USBDEVICE_FS_H
|
|
|
|
#define _UAPI_LINUX_USBDEVICE_FS_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/magic.h>
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* usbdevfs ioctl codes */
|
|
|
|
|
|
|
|
struct usbdevfs_ctrltransfer {
|
|
|
|
__u8 bRequestType;
|
|
|
|
__u8 bRequest;
|
|
|
|
__u16 wValue;
|
|
|
|
__u16 wIndex;
|
|
|
|
__u16 wLength;
|
|
|
|
__u32 timeout; /* in milliseconds */
|
|
|
|
void __user *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_bulktransfer {
|
|
|
|
unsigned int ep;
|
|
|
|
unsigned int len;
|
|
|
|
unsigned int timeout; /* in milliseconds */
|
|
|
|
void __user *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_setinterface {
|
|
|
|
unsigned int interface;
|
|
|
|
unsigned int altsetting;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_disconnectsignal {
|
|
|
|
unsigned int signr;
|
|
|
|
void __user *context;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define USBDEVFS_MAXDRIVERNAME 255
|
|
|
|
|
|
|
|
struct usbdevfs_getdriver {
|
|
|
|
unsigned int interface;
|
|
|
|
char driver[USBDEVFS_MAXDRIVERNAME + 1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_connectinfo {
|
|
|
|
unsigned int devnum;
|
|
|
|
unsigned char slow;
|
|
|
|
};
|
|
|
|
|
USB: add usbfs ioctl to retrieve the connection parameters
Recently usfbs gained availability to retrieve device speed, but there
is sill no way to determine the bus number or list of ports the device
is connected to when using usbfs. While this information can be obtained
from sysfs, not all environments allow sysfs access. In a jailed
environment a program might be simply given an opened file descriptor to
usbfs device, and it is really important that all data can be gathered
from said file descriptor.
This patch introduces a new ioctl, USBDEVFS_CONNINFO_EX, which return
extended connection information for the device, including the bus
number, address, port list and speed. The API allows kernel to extend
amount of data returned by the ioctl and userspace has an option of
adjusting the amount of data it is willing to consume. A new capability,
USBDEVFS_CAP_CONNINFO_EX, is introduced to help userspace in determining
whether the kernel supports this new ioctl.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 01:36:58 +03:00
|
|
|
struct usbdevfs_conninfo_ex {
|
|
|
|
__u32 size; /* Size of the structure from the kernel's */
|
|
|
|
/* point of view. Can be used by userspace */
|
|
|
|
/* to determine how much data can be */
|
|
|
|
/* used/trusted. */
|
|
|
|
__u32 busnum; /* USB bus number, as enumerated by the */
|
|
|
|
/* kernel, the device is connected to. */
|
|
|
|
__u32 devnum; /* Device address on the bus. */
|
|
|
|
__u32 speed; /* USB_SPEED_* constants from ch9.h */
|
2019-06-19 09:36:16 +03:00
|
|
|
__u8 num_ports; /* Number of ports the device is connected */
|
USB: add usbfs ioctl to retrieve the connection parameters
Recently usfbs gained availability to retrieve device speed, but there
is sill no way to determine the bus number or list of ports the device
is connected to when using usbfs. While this information can be obtained
from sysfs, not all environments allow sysfs access. In a jailed
environment a program might be simply given an opened file descriptor to
usbfs device, and it is really important that all data can be gathered
from said file descriptor.
This patch introduces a new ioctl, USBDEVFS_CONNINFO_EX, which return
extended connection information for the device, including the bus
number, address, port list and speed. The API allows kernel to extend
amount of data returned by the ioctl and userspace has an option of
adjusting the amount of data it is willing to consume. A new capability,
USBDEVFS_CAP_CONNINFO_EX, is introduced to help userspace in determining
whether the kernel supports this new ioctl.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 01:36:58 +03:00
|
|
|
/* to on the way to the root hub. It may */
|
|
|
|
/* be bigger than size of 'ports' array so */
|
|
|
|
/* userspace can detect overflows. */
|
2019-06-19 09:36:16 +03:00
|
|
|
__u8 ports[7]; /* List of ports on the way from the root */
|
USB: add usbfs ioctl to retrieve the connection parameters
Recently usfbs gained availability to retrieve device speed, but there
is sill no way to determine the bus number or list of ports the device
is connected to when using usbfs. While this information can be obtained
from sysfs, not all environments allow sysfs access. In a jailed
environment a program might be simply given an opened file descriptor to
usbfs device, and it is really important that all data can be gathered
from said file descriptor.
This patch introduces a new ioctl, USBDEVFS_CONNINFO_EX, which return
extended connection information for the device, including the bus
number, address, port list and speed. The API allows kernel to extend
amount of data returned by the ioctl and userspace has an option of
adjusting the amount of data it is willing to consume. A new capability,
USBDEVFS_CAP_CONNINFO_EX, is introduced to help userspace in determining
whether the kernel supports this new ioctl.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 01:36:58 +03:00
|
|
|
/* hub to the device. Current limit in */
|
|
|
|
/* USB specification is 7 tiers (root hub, */
|
|
|
|
/* 5 intermediate hubs, device), which */
|
|
|
|
/* gives at most 6 port entries. */
|
|
|
|
};
|
|
|
|
|
2012-10-13 13:46:48 +04:00
|
|
|
#define USBDEVFS_URB_SHORT_NOT_OK 0x01
|
|
|
|
#define USBDEVFS_URB_ISO_ASAP 0x02
|
|
|
|
#define USBDEVFS_URB_BULK_CONTINUATION 0x04
|
2017-12-11 19:58:21 +03:00
|
|
|
#define USBDEVFS_URB_NO_FSBR 0x20 /* Not used */
|
2012-10-13 13:46:48 +04:00
|
|
|
#define USBDEVFS_URB_ZERO_PACKET 0x40
|
|
|
|
#define USBDEVFS_URB_NO_INTERRUPT 0x80
|
|
|
|
|
|
|
|
#define USBDEVFS_URB_TYPE_ISO 0
|
|
|
|
#define USBDEVFS_URB_TYPE_INTERRUPT 1
|
|
|
|
#define USBDEVFS_URB_TYPE_CONTROL 2
|
|
|
|
#define USBDEVFS_URB_TYPE_BULK 3
|
|
|
|
|
|
|
|
struct usbdevfs_iso_packet_desc {
|
|
|
|
unsigned int length;
|
|
|
|
unsigned int actual_length;
|
|
|
|
unsigned int status;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_urb {
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char endpoint;
|
|
|
|
int status;
|
|
|
|
unsigned int flags;
|
|
|
|
void __user *buffer;
|
|
|
|
int buffer_length;
|
|
|
|
int actual_length;
|
|
|
|
int start_frame;
|
2013-10-09 19:19:29 +04:00
|
|
|
union {
|
|
|
|
int number_of_packets; /* Only used for isoc urbs */
|
|
|
|
unsigned int stream_id; /* Only used with bulk streams */
|
|
|
|
};
|
2012-10-13 13:46:48 +04:00
|
|
|
int error_count;
|
|
|
|
unsigned int signr; /* signal to be sent on completion,
|
|
|
|
or 0 if none should be sent. */
|
|
|
|
void __user *usercontext;
|
|
|
|
struct usbdevfs_iso_packet_desc iso_frame_desc[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ioctls for talking directly to drivers */
|
|
|
|
struct usbdevfs_ioctl {
|
|
|
|
int ifno; /* interface 0..N ; negative numbers reserved */
|
|
|
|
int ioctl_code; /* MUST encode size + direction of data so the
|
|
|
|
* macros in <asm/ioctl.h> give correct values */
|
|
|
|
void __user *data; /* param buffer (in, or out) */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* You can do most things with hubs just through control messages,
|
|
|
|
* except find out what device connects to what port. */
|
|
|
|
struct usbdevfs_hub_portinfo {
|
|
|
|
char nports; /* number of downstream ports in this hub */
|
|
|
|
char port [127]; /* e.g. port 3 connects to device 27 */
|
|
|
|
};
|
|
|
|
|
2015-01-29 19:29:13 +03:00
|
|
|
/* System and bus capability flags */
|
2012-10-13 13:46:48 +04:00
|
|
|
#define USBDEVFS_CAP_ZERO_PACKET 0x01
|
|
|
|
#define USBDEVFS_CAP_BULK_CONTINUATION 0x02
|
|
|
|
#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
|
|
|
|
#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
|
2015-01-29 19:29:13 +03:00
|
|
|
#define USBDEVFS_CAP_REAP_AFTER_DISCONNECT 0x10
|
2016-02-04 00:58:26 +03:00
|
|
|
#define USBDEVFS_CAP_MMAP 0x20
|
2016-02-22 00:38:01 +03:00
|
|
|
#define USBDEVFS_CAP_DROP_PRIVILEGES 0x40
|
USB: add usbfs ioctl to retrieve the connection parameters
Recently usfbs gained availability to retrieve device speed, but there
is sill no way to determine the bus number or list of ports the device
is connected to when using usbfs. While this information can be obtained
from sysfs, not all environments allow sysfs access. In a jailed
environment a program might be simply given an opened file descriptor to
usbfs device, and it is really important that all data can be gathered
from said file descriptor.
This patch introduces a new ioctl, USBDEVFS_CONNINFO_EX, which return
extended connection information for the device, including the bus
number, address, port list and speed. The API allows kernel to extend
amount of data returned by the ioctl and userspace has an option of
adjusting the amount of data it is willing to consume. A new capability,
USBDEVFS_CAP_CONNINFO_EX, is introduced to help userspace in determining
whether the kernel supports this new ioctl.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 01:36:58 +03:00
|
|
|
#define USBDEVFS_CAP_CONNINFO_EX 0x80
|
2012-10-13 13:46:48 +04:00
|
|
|
|
|
|
|
/* USBDEVFS_DISCONNECT_CLAIM flags & struct */
|
|
|
|
|
|
|
|
/* disconnect-and-claim if the driver matches the driver field */
|
|
|
|
#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
|
|
|
|
/* disconnect-and-claim except when the driver matches the driver field */
|
|
|
|
#define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
|
|
|
|
|
|
|
|
struct usbdevfs_disconnect_claim {
|
|
|
|
unsigned int interface;
|
|
|
|
unsigned int flags;
|
|
|
|
char driver[USBDEVFS_MAXDRIVERNAME + 1];
|
|
|
|
};
|
|
|
|
|
2013-10-09 19:19:31 +04:00
|
|
|
struct usbdevfs_streams {
|
|
|
|
unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
|
|
|
|
unsigned int num_eps;
|
|
|
|
unsigned char eps[0];
|
|
|
|
};
|
2012-10-13 13:46:48 +04:00
|
|
|
|
USB: add usbfs ioctl to retrieve the connection speed
The usbfs interface does not provide any way for the user to learn the
speed at which a device is connected. The current API includes a
USBDEVFS_CONNECTINFO ioctl, but all it provides is the device's
address and a one-bit value indicating whether the connection is low
speed. That may have sufficed in the era of USB-1.1, but it isn't
good enough today.
This patch introduces a new ioctl, USBDEVFS_GET_SPEED, which returns a
numeric value indicating the speed of the connection: unknown, low,
full, high, wireless, super, or super-plus.
Similar information (not exactly the same) is available through sysfs,
but it seems reasonable to provide the actual value in usbfs.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Reinhard Huck <reinhard.huck@thesycon.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-05 17:28:01 +03:00
|
|
|
/*
|
|
|
|
* USB_SPEED_* values returned by USBDEVFS_GET_SPEED are defined in
|
|
|
|
* linux/usb/ch9.h
|
|
|
|
*/
|
|
|
|
|
2012-10-13 13:46:48 +04:00
|
|
|
#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
|
|
|
|
#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
|
|
|
|
#define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
|
|
|
|
#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
|
|
|
|
#define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
|
|
|
|
#define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
|
|
|
|
#define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
|
|
|
|
#define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
|
|
|
|
#define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
|
|
|
|
#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
|
|
|
|
#define USBDEVFS_DISCARDURB _IO('U', 11)
|
|
|
|
#define USBDEVFS_REAPURB _IOW('U', 12, void *)
|
|
|
|
#define USBDEVFS_REAPURB32 _IOW('U', 12, __u32)
|
|
|
|
#define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
|
|
|
|
#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)
|
|
|
|
#define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
|
|
|
|
#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
|
|
|
|
#define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
|
|
|
|
#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
|
|
|
|
#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
|
|
|
|
#define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
|
|
|
|
#define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
|
|
|
|
#define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
|
|
|
|
#define USBDEVFS_RESET _IO('U', 20)
|
|
|
|
#define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
|
|
|
|
#define USBDEVFS_DISCONNECT _IO('U', 22)
|
|
|
|
#define USBDEVFS_CONNECT _IO('U', 23)
|
|
|
|
#define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
|
|
|
|
#define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
|
|
|
|
#define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
|
|
|
|
#define USBDEVFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbdevfs_disconnect_claim)
|
2013-10-09 19:19:31 +04:00
|
|
|
#define USBDEVFS_ALLOC_STREAMS _IOR('U', 28, struct usbdevfs_streams)
|
|
|
|
#define USBDEVFS_FREE_STREAMS _IOR('U', 29, struct usbdevfs_streams)
|
2016-02-22 00:38:01 +03:00
|
|
|
#define USBDEVFS_DROP_PRIVILEGES _IOW('U', 30, __u32)
|
USB: add usbfs ioctl to retrieve the connection speed
The usbfs interface does not provide any way for the user to learn the
speed at which a device is connected. The current API includes a
USBDEVFS_CONNECTINFO ioctl, but all it provides is the device's
address and a one-bit value indicating whether the connection is low
speed. That may have sufficed in the era of USB-1.1, but it isn't
good enough today.
This patch introduces a new ioctl, USBDEVFS_GET_SPEED, which returns a
numeric value indicating the speed of the connection: unknown, low,
full, high, wireless, super, or super-plus.
Similar information (not exactly the same) is available through sysfs,
but it seems reasonable to provide the actual value in usbfs.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Reinhard Huck <reinhard.huck@thesycon.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-05 17:28:01 +03:00
|
|
|
#define USBDEVFS_GET_SPEED _IO('U', 31)
|
USB: add usbfs ioctl to retrieve the connection parameters
Recently usfbs gained availability to retrieve device speed, but there
is sill no way to determine the bus number or list of ports the device
is connected to when using usbfs. While this information can be obtained
from sysfs, not all environments allow sysfs access. In a jailed
environment a program might be simply given an opened file descriptor to
usbfs device, and it is really important that all data can be gathered
from said file descriptor.
This patch introduces a new ioctl, USBDEVFS_CONNINFO_EX, which return
extended connection information for the device, including the bus
number, address, port list and speed. The API allows kernel to extend
amount of data returned by the ioctl and userspace has an option of
adjusting the amount of data it is willing to consume. A new capability,
USBDEVFS_CAP_CONNINFO_EX, is introduced to help userspace in determining
whether the kernel supports this new ioctl.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-11 01:36:58 +03:00
|
|
|
/*
|
|
|
|
* Returns struct usbdevfs_conninfo_ex; length is variable to allow
|
|
|
|
* extending size of the data returned.
|
|
|
|
*/
|
|
|
|
#define USBDEVFS_CONNINFO_EX(len) _IOC(_IOC_READ, 'U', 32, len)
|
2019-08-07 17:29:50 +03:00
|
|
|
#define USBDEVFS_FORBID_SUSPEND _IO('U', 33)
|
|
|
|
#define USBDEVFS_ALLOW_SUSPEND _IO('U', 34)
|
|
|
|
#define USBDEVFS_WAIT_FOR_RESUME _IO('U', 35)
|
2012-10-13 13:46:48 +04:00
|
|
|
|
|
|
|
#endif /* _UAPI_LINUX_USBDEVICE_FS_H */
|