From 41cc56fa9e30ca84bbbed4f7c889a6c73b9b7fab Mon Sep 17 00:00:00 2001 From: hselasky Date: Mon, 6 Jan 2020 09:16:41 +0000 Subject: [PATCH] MFC r356135: Make USB statistics per device instead of per bus. Bump the FreeBSD version due to structure change to force recompilation of external USB modules. Sponsored by: Mellanox Technologies git-svn-id: svn://svn.freebsd.org/base/stable/10@356396 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/usb/usb_bus.h | 11 +---------- sys/dev/usb/usb_device.h | 13 ++++++++++++- sys/dev/usb/usb_generic.c | 5 ++--- sys/dev/usb/usb_transfer.c | 4 ++-- sys/sys/param.h | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/sys/dev/usb/usb_bus.h b/sys/dev/usb/usb_bus.h index 10191eb54..2868d3fef 100644 --- a/sys/dev/usb/usb_bus.h +++ b/sys/dev/usb/usb_bus.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -39,20 +39,11 @@ struct usb_bus_msg { struct usb_bus *bus; }; -/* - * The following structure defines the USB statistics structure. - */ -struct usb_bus_stat { - uint32_t uds_requests[4]; -}; - /* * The following structure defines an USB BUS. There is one USB BUS * for every Host or Device controller. */ struct usb_bus { - struct usb_bus_stat stats_err; - struct usb_bus_stat stats_ok; #if USB_HAVE_ROOT_MOUNT_HOLD struct root_hold_token *bus_roothold; #endif diff --git a/sys/dev/usb/usb_device.h b/sys/dev/usb/usb_device.h index 1f6165b00..9b928471f 100644 --- a/sys/dev/usb/usb_device.h +++ b/sys/dev/usb/usb_device.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /*- - * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. + * Copyright (c) 2008-2019 Hans Petter Selasky. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -174,11 +174,22 @@ union usb_device_scratch { uint8_t data[255]; }; +/* + * Helper structure to keep track of USB device statistics. + */ +struct usb_device_statistics { + uint32_t uds_requests[4]; +}; + /* * The following structure defines an USB device. There exists one of * these structures for every USB device. */ struct usb_device { + /* statistics */ + struct usb_device_statistics stats_err; + struct usb_device_statistics stats_ok; + /* generic clear stall message */ struct usb_udev_msg cs_msg[2]; struct sx enum_sx; diff --git a/sys/dev/usb/usb_generic.c b/sys/dev/usb/usb_generic.c index 3418e1e28..e1b221a19 100644 --- a/sys/dev/usb/usb_generic.c +++ b/sys/dev/usb/usb_generic.c @@ -2222,10 +2222,9 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags) for (n = 0; n != 4; n++) { u.stat->uds_requests_fail[n] = - f->udev->bus->stats_err.uds_requests[n]; - + f->udev->stats_err.uds_requests[n]; u.stat->uds_requests_ok[n] = - f->udev->bus->stats_ok.uds_requests[n]; + f->udev->stats_ok.uds_requests[n]; } break; diff --git a/sys/dev/usb/usb_transfer.c b/sys/dev/usb/usb_transfer.c index 4ddbc98a9..1ee82a1c1 100644 --- a/sys/dev/usb/usb_transfer.c +++ b/sys/dev/usb/usb_transfer.c @@ -2593,10 +2593,10 @@ usbd_transfer_done(struct usb_xfer *xfer, usb_error_t error) #endif /* keep some statistics */ if (xfer->error) { - info->bus->stats_err.uds_requests + info->udev->stats_err.uds_requests [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++; } else { - info->bus->stats_ok.uds_requests + info->udev->stats_ok.uds_requests [xfer->endpoint->edesc->bmAttributes & UE_XFERTYPE]++; } diff --git a/sys/sys/param.h b/sys/sys/param.h index 6659a651e..73ab768b9 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1004501 /* Master, propagated to newvers */ +#define __FreeBSD_version 1004502 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, -- 2.42.0