linux-kernelorg-stable/include/uapi/linux
Chris Wulff a139c98f76 USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL
While supporting GET_REPORT is a mandatory request per the HID
specification the current implementation of the GET_REPORT request responds
to the USB Host with an empty reply of the request length. However, some
USB Hosts will request the contents of feature reports via the GET_REPORT
request. In addition, some proprietary HID 'protocols' will expect
different data, for the same report ID, to be to become available in the
feature report by sending a preceding SET_REPORT to the USB Device that
defines what data is to be presented when that feature report is
subsequently retrieved via GET_REPORT (with a very fast < 5ms turn around
between the SET_REPORT and the GET_REPORT).

There are two other patch sets already submitted for adding GET_REPORT
support. The first [1] allows for pre-priming a list of reports via IOCTLs
which then allows the USB Host to perform the request, with no further
userspace interaction possible during the GET_REPORT request. And another
[2] which allows for a single report to be setup by userspace via IOCTL,
which will be fetched and returned by the kernel for subsequent GET_REPORT
requests by the USB Host, also with no further userspace interaction
possible.

This patch, while loosely based on both the patch sets, differs by allowing
the option for userspace to respond to each GET_REPORT request by setting
up a poll to notify userspace that a new GET_REPORT request has arrived. To
support this, two extra IOCTLs are supplied. The first of which is used to
retrieve the report ID of the GET_REPORT request (in the case of having
non-zero report IDs in the HID descriptor). The second IOCTL allows for
storing report responses in a list for responding to requests.

The report responses are stored in a list (it will be either added if it
does not exist or updated if it exists already). A flag (userspace_req) can
be set to whether subsequent requests notify userspace or not.

Basic operation when a GET_REPORT request arrives from USB Host:

- If the report ID exists in the list and it is set for immediate return
  (i.e. userspace_req == false) then response is sent immediately,
userspace is not notified

- The report ID does not exist, or exists but is set to notify userspace
  (i.e. userspace_req == true) then notify userspace via poll:

	- If userspace responds, and either adds or update the response in
	  the list and respond to the host with the contents

	- If userspace does not respond within the fixed timeout (2500ms)
	  but the report has been set prevously, then send 'old' report
	  contents

	- If userspace does not respond within the fixed timeout (2500ms)
	  and the report does not exist in the list then send an empty
	  report

Note that userspace could 'prime' the report list at any other time.

While this patch allows for flexibility in how the system responds to
requests, and therefore the HID 'protocols' that could be supported, a
drawback is the time it takes to service the requests and therefore the
maximum throughput that would be achievable. The USB HID Specification
v1.11 itself states that GET_REPORT is not intended for periodic data
polling, so this limitation is not severe.

Testing on an iMX8M Nano Ultra Lite with a heavy multi-core CPU loading
showed that userspace can typically respond to the GET_REPORT request
within 1200ms - which is well within the 5000ms most operating systems seem
to allow, and within the 2500ms set by this patch.

[1] https://lore.kernel.org/all/20220805070507.123151-2-sunil@amarulasolutions.com/
[2] https://lore.kernel.org/all/20220726005824.2817646-1-vi@endrift.com/

Signed-off-by: David Sands <david.sands@biamp.com>
Signed-off-by: Chris Wulff <chris.wulff@biamp.com>
Link: https://lore.kernel.org/r/20240817142850.1311460-2-crwulff@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-08-22 17:25:59 +08:00
..
android
byteorder
caif
can can: isotp: remove ISO 15675-2 specification version where possible 2024-06-20 11:52:56 +02:00
cifs
dvb media: dvb: Fix dtvs_stats packing. 2024-04-15 13:42:38 +02:00
genwqe
hdlc
hsi
iio iio: core: Add new DMABUF interface infrastructure 2024-06-30 11:29:17 +01:00
isdn
media/raspberrypi media: uapi: pisp_be_config: Add extra config fields 2024-07-12 10:11:43 +02:00
misc
mmc
netfilter netfilter: nf_tables: rise cap on SELinux secmark context 2024-06-26 00:54:53 +02:00
netfilter_arp
netfilter_bridge
netfilter_ipv4
netfilter_ipv6
nfsd
raid
sched
spi
sunrpc
surface_aggregator
tc_act
tc_ematch
usb USB: gadget: f_hid: Add GET_REPORT via userspace IOCTL 2024-08-22 17:25:59 +08:00
a.out.h
acct.h
acrn.h
adb.h
adfs_fs.h
affs_hardblocks.h
agpgart.h
aio_abi.h
am437x-vpfe.h
amt.h
apm_bios.h
arcfb.h
arm_sdei.h
aspeed-lpc-ctrl.h
aspeed-p2a-ctrl.h
aspeed-video.h
atalk.h
atm.h
atm_eni.h
atm_he.h
atm_idt77105.h
atm_nicstar.h
atm_tcp.h
atm_zatm.h
atmapi.h
atmarp.h
atmbr2684.h
atmclip.h
atmdev.h
atmioc.h
atmlec.h
atmmpc.h
atmppp.h
atmsap.h
atmsvc.h
audit.h
auto_dev-ioctl.h
auto_fs.h
auto_fs4.h
auxvec.h
ax25.h
batadv_packet.h
batman_adv.h
baycom.h
bcm933xx_hcs.h
bfs_fs.h
binfmts.h
bits.h
blkpg.h
blktrace_api.h
blkzoned.h
bpf.h bpf: Add CHECKSUM_COMPLETE to bpf test progs 2024-06-13 14:29:47 +02:00
bpf_common.h
bpf_perf_event.h
bpqether.h
bsg.h
bt-bmc.h
btf.h
btrfs.h
btrfs_tree.h btrfs: remove raid-stripe-tree encoding field from stripe_extent 2024-07-11 15:33:28 +02:00
cachefiles.h
can.h
capability.h
capi.h
cciss_defs.h
cciss_ioctl.h
ccs.h
cdrom.h
cec-funcs.h
cec.h
cfm_bridge.h
cgroupstats.h
chio.h
close_range.h
cn_proc.h connector: Fix invalid conversion in cn_proc.h 2024-05-24 10:36:55 +01:00
coda.h
coff.h
comedi.h
connector.h
const.h
coresight-stm.h
counter.h
cramfs_fs.h
cryptouser.h crypto: remove CONFIG_CRYPTO_STATS 2024-04-02 10:49:38 +08:00
cuda.h
cxl_mem.h cxl/mbox: Add Clear Log mailbox command 2024-04-30 08:48:10 -07:00
cyclades.h
cycx_cfm.h
dcbnl.h
dccp.h
devlink.h devlink: Support setting max_io_eqs 2024-04-08 14:10:45 +01:00
dlm.h dlm: introduce DLM_LSFL_SOFTIRQ_SAFE 2024-06-11 12:57:49 -05:00
dlm_device.h
dlm_plock.h
dlmconstants.h
dm-ioctl.h
dm-log-userspace.h
dma-buf.h
dma-heap.h dma-buf: align fd_flags and heap_flags with dma_heap_allocation_data 2024-06-05 14:52:15 +05:30
dns_resolver.h
dpll.h
dqblk_xfs.h
dw100.h
edd.h
efs_fs_sb.h
elf-em.h
elf-fdpic.h
elf.h
errno.h
errqueue.h
erspan.h
ethtool.h net: phy: bcm54811: New link mode for BroadR-Reach 2024-07-14 20:38:34 -07:00
ethtool_netlink.h net: ethtool: Add new power limit get and set features 2024-07-05 18:30:00 -07:00
eventfd.h
eventpoll.h
ext4.h
f2fs.h
fadvise.h
falloc.h
fanotify.h
fb.h
fcntl.h fcntl: add F_DUPFD_QUERY fcntl() 2024-05-10 08:26:31 +02:00
fd.h
fdreg.h
fib_rules.h
fiemap.h
filter.h
firewire-cdev.h
firewire-constants.h
fou.h
fpga-dfl.h
fs.h - 875fa64577da ("mm/hugetlb_vmemmap: fix race with speculative PFN 2024-07-21 17:15:46 -07:00
fscrypt.h
fsi.h
fsl_hypervisor.h
fsl_mc.h
fsmap.h
fsverity.h
fuse.h
futex.h
gameport.h
gen_stats.h
genetlink.h
gfs2_ondisk.h
gpio.h
gsmmux.h
gtp.h gtp: add IPv6 support 2024-05-07 01:35:57 +02:00
handshake.h
hash_info.h
hdlc.h
hdlcdrv.h
hdreg.h
hid.h
hiddev.h
hidraw.h
hpet.h
hsr_netlink.h
hw_breakpoint.h
hyperv.h
i2c-dev.h
i2c.h
i2o-dev.h
i8k.h
icmp.h
icmpv6.h netfilter: conntrack: fix ct-state for ICMPv6 Multicast Router Discovery 2024-05-06 11:13:56 +02:00
idxd.h
if.h
if_addr.h
if_addrlabel.h
if_alg.h
if_arcnet.h
if_arp.h
if_bonding.h
if_bridge.h
if_cablemodem.h
if_eql.h
if_ether.h
if_fc.h
if_fddi.h
if_hippi.h
if_infiniband.h
if_link.h gtp: add IPv6 support 2024-05-07 01:35:57 +02:00
if_ltalk.h
if_macsec.h
if_packet.h
if_phonet.h
if_plip.h
if_ppp.h
if_pppol2tp.h
if_pppox.h
if_slip.h
if_team.h uapi: team: use header file generated from YAML spec 2024-04-02 18:24:33 -07:00
if_tun.h
if_tunnel.h pfcp: always set pfcp metadata 2024-04-01 10:49:28 +01:00
if_vlan.h
if_x25.h
if_xdp.h xsk: Require XDP_UMEM_TX_METADATA_LEN to actuate tx_metadata_len 2024-07-25 11:57:27 +02:00
ife.h
igmp.h
ila.h
in.h net/smc: Introduce IPPROTO_SMC 2024-06-17 13:14:09 +01:00
in6.h
in_route.h
inet_diag.h
inotify.h
input-event-codes.h input: Add support for "Do Not Disturb" 2024-06-07 11:08:07 +02:00
input.h
io_uring.h io_uring: fix user_data field name in comment 2024-08-16 12:31:26 -06:00
ioam6.h
ioam6_genl.h
ioam6_iptunnel.h
ioctl.h
iommufd.h iommufd: Put constants for all the uAPI enums 2024-07-15 09:44:54 -03:00
ioprio.h
ip.h
ip6_tunnel.h
ip_vs.h
ipc.h
ipmi.h
ipmi_bmc.h
ipmi_msgdefs.h
ipmi_ssif_bmc.h
ipsec.h
ipv6.h
ipv6_route.h
irqnr.h
iso_fs.h
isst_if.h
ivtv.h
ivtvfb.h
jffs2.h
joystick.h
kcm.h
kcmp.h
kcov.h
kd.h Revert "VT: Use macros to define ioctls" 2024-06-01 07:28:21 +02:00
kdev_t.h
kernel-page-flags.h
kernel.h
kernelcapi.h
kexec.h crash: add a new kexec flag for hotplug support 2024-04-23 14:59:01 +10:00
keyboard.h
keyctl.h
kfd_ioctl.h drm/amdkfd: enable single alu ops for gfx12 2024-05-02 16:18:13 -04:00
kfd_sysfs.h drm/amdkfd: enable single alu ops for gfx12 2024-05-02 16:18:13 -04:00
kvm.h KVM x86 misc changes for 6.11 2024-07-16 09:53:05 -04:00
kvm_para.h
l2tp.h
landlock.h landlock: Various documentation improvements 2024-07-18 08:27:47 +02:00
libc-compat.h
limits.h
lirc.h
llc.h
loadpin.h
loop.h
lp.h
lsm.h
lwtunnel.h
magic.h bcachefs: Move BCACHEFS_STATFS_MAGIC value to UAPI magic.h 2024-05-08 17:29:24 -04:00
major.h
map_to_7segment.h
map_to_14segment.h
matroxfb.h
max2175.h
mctp.h
mdio.h
media-bus-format.h media: uapi: Add generic serial metadata mbus formats 2024-04-29 14:56:36 +02:00
media.h
mei.h
mei_uuid.h
membarrier.h
memfd.h
mempolicy.h
mii.h
minix_fs.h
mman.h mm: add MAP_DROPPABLE for designating always lazily freeable mappings 2024-07-19 20:22:12 +02:00
mmtimer.h
module.h
mount.h fs: export mount options via statmount() 2024-06-28 14:36:43 +02:00
mpls.h
mpls_iptunnel.h
mptcp.h mptcp: add last time fields in mptcp_info 2024-04-11 08:19:54 -07:00
mptcp_pm.h
mqueue.h
mroute.h
mroute6.h
mrp_bridge.h
msdos_fs.h
msg.h
mtio.h
nbd-netlink.h
nbd.h
ncsi.h
ndctl.h
neighbour.h
net.h
net_dropmon.h
net_namespace.h
net_tstamp.h
netconf.h
netdev.h netdev: add qstat for csum complete 2024-05-30 12:15:56 +02:00
netdevice.h
netfilter.h
netfilter_arp.h
netfilter_bridge.h
netfilter_ipv4.h
netfilter_ipv6.h
netlink.h
netlink_diag.h
netrom.h
nexthop.h
nfc.h
nfs.h NFS/knfsd: Remove the invalid NFS error 'NFSERR_OPNOTSUPP' 2024-05-06 12:47:24 -04:00
nfs2.h
nfs3.h
nfs4.h NFSv4: Detect support for OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION 2024-07-08 13:47:25 -04:00
nfs4_mount.h
nfs_fs.h
nfs_idmap.h
nfs_mount.h
nfsacl.h
nfsd_netlink.h nfsd: new netlink ops to get/set server pool_mode 2024-07-08 14:10:05 -04:00
nilfs2_api.h
nilfs2_ondisk.h
nitro_enclaves.h
nl80211-vnd-intel.h
nl80211.h wifi: cfg80211: add support for advertising multiple radios belonging to a wiphy 2024-07-09 11:29:59 +02:00
npcm-video.h
nsfs.h nsfs: fix ioctl declaration 2024-08-12 22:03:26 +02:00
nsm.h
ntsync.h ntsync: Introduce NTSYNC_IOC_SEM_POST. 2024-04-11 15:34:40 +02:00
nubus.h
nvme_ioctl.h
nvram.h
omap3isp.h
omapfb.h
oom.h
openat2.h
openvswitch.h net: openvswitch: store sampling probability in cb. 2024-07-05 17:45:47 -07:00
packet_diag.h
papr_pdsm.h powerpc/papr_scm: Move duplicate definitions to common header files 2024-04-25 12:37:12 -07:00
param.h
parport.h
patchkey.h
pci.h
pci_regs.h Merge branch 'pci/doe' 2024-05-16 18:14:09 -05:00
pcitest.h
perf_event.h perf/x86/intel: Support new data source for Lunar Lake 2024-07-04 16:00:38 +02:00
personality.h
pfkeyv2.h
pfrut.h
pg.h
phantom.h
phonet.h
pidfd.h pidfs: allow retrieval of namespace file descriptors 2024-06-28 10:37:29 +02:00
pkt_cls.h net/sched: cls_flower: rework TCA_FLOWER_KEY_ENC_FLAGS usage 2024-07-15 09:14:38 -07:00
pkt_sched.h
pktcdvd.h
pmu.h
poll.h
posix_acl.h
posix_acl_xattr.h
posix_types.h
ppdev.h
ppp-comp.h
ppp-ioctl.h
ppp_defs.h
pps.h
pr.h
prctl.h RISC-V Patches for the 6.10 Merge Window, Part 1 2024-05-22 09:56:00 -07:00
psample.h net: psample: allow using rate as probability 2024-07-05 17:45:47 -07:00
psci.h
psp-dbc.h
psp-sev.h KVM: SEV: uapi: fix typo in SEV_RET_INVALID_CONFIG 2024-08-14 13:05:42 -04:00
ptp_clock.h
ptrace.h
qemu_fw_cfg.h
qnx4_fs.h
qnxtypes.h
qrtr.h
quota.h
radeonfb.h
random.h random: note that RNDGETPOOL was removed in 2.6.9-rc2 2024-07-19 20:22:48 +02:00
rds.h
reboot.h
reiserfs_fs.h
reiserfs_xattr.h
remoteproc_cdev.h
resource.h
rfkill.h
rio_cm_cdev.h
rio_mport_cdev.h
rkisp1-config.h
romfs_fs.h
rose.h
route.h
rpl.h
rpl_iptunnel.h
rpmsg.h
rpmsg_types.h
rseq.h
rtc.h
rtnetlink.h
rxrpc.h
scc.h
sched.h
scif_ioctl.h
screen_info.h
sctp.h
seccomp.h
securebits.h
sed-opal.h
seg6.h
seg6_genl.h
seg6_hmac.h
seg6_iptunnel.h
seg6_local.h
selinux_netlink.h
sem.h
serial.h
serial_core.h
serial_reg.h
serio.h
sev-guest.h KVM: SEV: Provide support for SNP_GUEST_REQUEST NAE event 2024-07-16 11:44:00 -04:00
shm.h
signal.h
signalfd.h
smc.h
smc_diag.h
smiapp.h
snmp.h xfrm: Add dir validation to "in" data path lookup 2024-05-01 10:06:27 +02:00
sock_diag.h
socket.h
sockios.h
sonet.h
sonypi.h
sound.h
soundcard.h
stat.h fs: Add initial atomic write support info to statx 2024-06-20 15:19:17 -06:00
stddef.h uapi: stddef.h: Provide UAPI macros for __counted_by_{le, be} 2024-05-08 00:42:25 -07:00
stm.h
string.h
suspend_ioctls.h
swab.h
switchtec_ioctl.h
sync_file.h
synclink.h
sysctl.h
sysinfo.h
target_core_user.h
taskstats.h
tcp.h tcp: socket option to check for MPTCP fallback to TCP 2024-05-13 14:48:04 -07:00
tcp_metrics.h tcp_metrics: add netlink protocol spec in YAML 2024-07-01 09:44:27 +01:00
tdx-guest.h
tee.h tee: tstee: Add Trusted Services TEE driver 2024-04-03 14:03:09 +02:00
termios.h
thermal.h
thp7312.h
time.h
time_types.h
timerfd.h
times.h
timex.h
tiocl.h
tipc.h
tipc_config.h
tipc_netlink.h
tipc_sockets_diag.h
tls.h
toshiba.h
tps6594_pfsm.h
trace_mmap.h tracing: Have memmapped ring buffer use ioctl of "R" range 0x20-2F 2024-07-03 16:40:45 -04:00
tty.h
tty_flags.h
types.h
ublk_cmd.h
udf_fs_i.h
udmabuf.h
udp.h udpencap: Remove Obsolete UDP_ENCAP_ESPINUDP_NON_IKE Support 2024-04-18 11:38:23 +02:00
uhid.h
uinput.h
uio.h
uleds.h
ultrasound.h
um_timetravel.h um: add shared memory optimisation for time-travel=ext 2024-07-03 12:24:54 +02:00
un.h
unistd.h
unix_diag.h
usbdevice_fs.h
usbip.h
user_events.h
userfaultfd.h
userio.h
utime.h
utsname.h
uuid.h
uvcvideo.h
v4l2-common.h
v4l2-controls.h media: v4l2-ctrls: Add average QP control 2024-06-10 10:24:30 +02:00
v4l2-dv-timings.h
v4l2-mediabus.h media: uapi: Document which mbus format fields are valid for metadata 2024-04-29 14:56:36 +02:00
v4l2-subdev.h media: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing 2024-04-29 14:56:37 +02:00
vbox_err.h
vbox_vmmdev_types.h
vboxguest.h
vdpa.h vDPA: code clean for vhost_vdpa uapi 2024-04-22 17:07:13 -04:00
vduse.h
vesa.h
veth.h
vfio.h
vfio_ccw.h
vfio_zdev.h
vhost.h vhost-vdpa: change ioctl # for VDPA_GET_VRING_SIZE 2024-04-08 04:11:04 -04:00
vhost_types.h
videodev2.h media: uapi: Add PiSP Compressed RAW Bayer formats 2024-06-27 13:06:47 +02:00
virtio_9p.h
virtio_balloon.h
virtio_blk.h
virtio_bt.h Bluetooth: HCI: Remove HCI_AMP support 2024-05-14 10:54:49 -04:00
virtio_config.h
virtio_console.h
virtio_crypto.h
virtio_fs.h
virtio_gpio.h
virtio_gpu.h
virtio_i2c.h
virtio_ids.h
virtio_input.h
virtio_iommu.h
virtio_mem.h virtio-mem: support suspend+resume 2024-05-22 08:31:15 -04:00
virtio_mmio.h
virtio_net.h virtio_net: introduce device stats feature and structures 2024-04-30 10:51:32 +02:00
virtio_pci.h
virtio_pcidev.h
virtio_pmem.h
virtio_ring.h
virtio_rng.h
virtio_scmi.h
virtio_scsi.h
virtio_snd.h
virtio_types.h
virtio_vsock.h
vm_sockets.h
vm_sockets_diag.h
vmcore.h
vsockmon.h
vt.h
vtpm_proxy.h
wait.h
watch_queue.h
watchdog.h
wireguard.h
wireless.h
wmi.h
wwan.h
x25.h
xattr.h
xdp_diag.h
xfrm.h xfrm: support sending NAT keepalives in ESP in UDP states 2024-06-26 13:22:42 +02:00
xilinx-v4l2-controls.h
zorro.h
zorro_ids.h m68k: amiga: Turn off Warp1260 interrupts during boot 2024-06-04 08:59:58 +02:00