aboutsummaryrefslogtreecommitdiff
path: root/lib/libusb/libusb20_ugen20.c
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2019-12-27 20:35:12 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2019-12-27 20:35:12 +0000
commit34b0ca243f6272d998475afd019d3a9e175cd817 (patch)
treeec0a06b0ea9d1a4623486baeeea3db145ef414ff /lib/libusb/libusb20_ugen20.c
parent7082625d976f0ad1b4207a12afe3c72e2acd9145 (diff)
downloadsrc-34b0ca243f6272d998475afd019d3a9e175cd817.tar.gz
src-34b0ca243f6272d998475afd019d3a9e175cd817.zip
Implement new libusb v2.0 API function, libusb20_dev_get_stats().
This function is useful when debugging USB device issues. MFC after: 1 week Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=356136
Diffstat (limited to 'lib/libusb/libusb20_ugen20.c')
-rw-r--r--lib/libusb/libusb20_ugen20.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index d28e674c1fe3..5687caf97e4f 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -80,6 +80,7 @@ static libusb20_check_connected_t ugen20_check_connected;
static libusb20_set_power_mode_t ugen20_set_power_mode;
static libusb20_get_power_mode_t ugen20_get_power_mode;
static libusb20_get_power_usage_t ugen20_get_power_usage;
+static libusb20_get_stats_t ugen20_get_stats;
static libusb20_kernel_driver_active_t ugen20_kernel_driver_active;
static libusb20_detach_kernel_driver_t ugen20_detach_kernel_driver;
static libusb20_do_request_sync_t ugen20_do_request_sync;
@@ -670,6 +671,29 @@ ugen20_get_power_usage(struct libusb20_device *pdev, uint16_t *power_usage)
}
static int
+ugen20_get_stats(struct libusb20_device *pdev, struct libusb20_device_stats *pstats)
+{
+ struct usb_device_stats st;
+
+ if (ioctl(pdev->file_ctrl, IOUSB(USB_DEVICESTATS), &st))
+ return (LIBUSB20_ERROR_OTHER);
+
+ memset(pstats, 0, sizeof(*pstats));
+
+ pstats->xfer_ok[0] = st.uds_requests_ok[0];
+ pstats->xfer_ok[1] = st.uds_requests_ok[1];
+ pstats->xfer_ok[2] = st.uds_requests_ok[2];
+ pstats->xfer_ok[3] = st.uds_requests_ok[3];
+
+ pstats->xfer_fail[0] = st.uds_requests_fail[0];
+ pstats->xfer_fail[1] = st.uds_requests_fail[1];
+ pstats->xfer_fail[2] = st.uds_requests_fail[2];
+ pstats->xfer_fail[3] = st.uds_requests_fail[3];
+
+ return (0); /* success */
+}
+
+static int
ugen20_kernel_driver_active(struct libusb20_device *pdev,
uint8_t iface_index)
{