svn commit: r356401 - stable/11/usr.sbin/usbconfig

Hans Petter Selasky hselasky at FreeBSD.org
Mon Jan 6 09:24:49 UTC 2020


Author: hselasky
Date: Mon Jan  6 09:24:47 2020
New Revision: 356401
URL: https://svnweb.freebsd.org/changeset/base/356401

Log:
  MFC r356137:
  Implement dump_stats command for usbconfig(8).
  
  This command is useful when debugging USB device issues.
  
  Sponsored by:	Mellanox Technologies

Modified:
  stable/11/usr.sbin/usbconfig/dump.c
  stable/11/usr.sbin/usbconfig/dump.h
  stable/11/usr.sbin/usbconfig/usbconfig.8
  stable/11/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/usbconfig/dump.c
==============================================================================
--- stable/11/usr.sbin/usbconfig/dump.c	Mon Jan  6 09:23:54 2020	(r356400)
+++ stable/11/usr.sbin/usbconfig/dump.c	Mon Jan  6 09:24:47 2020	(r356401)
@@ -483,3 +483,32 @@ dump_string_by_index(struct libusb20_device *pdev, uin
 	}
 	free(pbuf);
 }
+
+void
+dump_device_stats(struct libusb20_device *pdev)
+{
+	struct libusb20_device_stats st;
+
+	if (libusb20_dev_get_stats(pdev, &st)) {
+		printf("{}\n");
+	} else {
+		printf("{\n"
+		    "    UE_CONTROL_OK       : %llu\n"
+		    "    UE_ISOCHRONOUS_OK   : %llu\n"
+		    "    UE_BULK_OK          : %llu\n"
+		    "    UE_INTERRUPT_OK     : %llu\n"
+		    "    UE_CONTROL_FAIL     : %llu\n"
+		    "    UE_ISOCHRONOUS_FAIL : %llu\n"
+		    "    UE_BULK_FAIL        : %llu\n"
+		    "    UE_INTERRUPT_FAIL   : %llu\n"
+		    "}\n",
+		    (unsigned long long)st.xfer_ok[0],
+		    (unsigned long long)st.xfer_ok[1],
+		    (unsigned long long)st.xfer_ok[2],
+	            (unsigned long long)st.xfer_ok[3],
+		    (unsigned long long)st.xfer_fail[0],
+		    (unsigned long long)st.xfer_fail[1],
+		    (unsigned long long)st.xfer_fail[2],
+		    (unsigned long long)st.xfer_fail[3]);
+	}
+}

Modified: stable/11/usr.sbin/usbconfig/dump.h
==============================================================================
--- stable/11/usr.sbin/usbconfig/dump.h	Mon Jan  6 09:23:54 2020	(r356400)
+++ stable/11/usr.sbin/usbconfig/dump.h	Mon Jan  6 09:24:47 2020	(r356401)
@@ -37,6 +37,7 @@ void	dump_device_info(struct libusb20_device *pdev, ui
 void	dump_be_quirk_names(struct libusb20_backend *pbe);
 void	dump_be_dev_quirks(struct libusb20_backend *pbe);
 void	dump_device_desc(struct libusb20_device *pdev);
+void	dump_device_stats(struct libusb20_device *pdev);
 void	dump_config(struct libusb20_device *pdev, uint8_t all_cfg);
 
 #endif	/* _DUMP_H_ */

Modified: stable/11/usr.sbin/usbconfig/usbconfig.8
==============================================================================
--- stable/11/usr.sbin/usbconfig/usbconfig.8	Mon Jan  6 09:23:54 2020	(r356400)
+++ stable/11/usr.sbin/usbconfig/usbconfig.8	Mon Jan  6 09:24:47 2020	(r356401)
@@ -1,6 +1,6 @@
 .\" $FreeBSD$
 .\"
-.\" Copyright (c) 2008-2010 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
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 16, 2019
+.Dd December 27, 2019
 .Dt USBCONFIG 8
 .Os
 .Sh NAME
@@ -116,6 +116,8 @@ Display all the configuration descriptors.
 Display string descriptor at selected index.
 .It Cm dump_info
 Display summary information about the device.
+.It Cm dump_stats
+Display USB transfer statistics.
 .It Cm show_ifdrv
 Display the list of interface drivers (such as
 .Xr ukbd 4

Modified: stable/11/usr.sbin/usbconfig/usbconfig.c
==============================================================================
--- stable/11/usr.sbin/usbconfig/usbconfig.c	Mon Jan  6 09:23:54 2020	(r356400)
+++ stable/11/usr.sbin/usbconfig/usbconfig.c	Mon Jan  6 09:24:47 2020	(r356401)
@@ -82,6 +82,7 @@ struct options {
 	uint8_t	got_dump_curr_config:1;
 	uint8_t	got_dump_all_config:1;
 	uint8_t	got_dump_info:1;
+  	uint8_t	got_dump_stats:1;
 	uint8_t	got_show_iface_driver:1;
 	uint8_t	got_remove_device_quirk:1;
 	uint8_t	got_add_device_quirk:1;
@@ -121,6 +122,7 @@ enum {
 	T_DUMP_ALL_CONFIG_DESC,
 	T_DUMP_STRING,
 	T_DUMP_INFO,
+	T_DUMP_STATS,
 	T_SUSPEND,
 	T_RESUME,
 	T_POWER_OFF,
@@ -155,6 +157,7 @@ static const struct token token[] = {
 	{"dump_all_config_desc", T_DUMP_ALL_CONFIG_DESC, 0},
 	{"dump_string", T_DUMP_STRING, 1},
 	{"dump_info", T_DUMP_INFO, 0},
+	{"dump_stats", T_DUMP_STATS, 0},
 	{"show_ifdrv", T_SHOW_IFACE_DRIVER, 0},
 	{"suspend", T_SUSPEND, 0},
 	{"resume", T_RESUME, 0},
@@ -296,6 +299,7 @@ usage(void)
 	    "  dump_all_config_desc" "\n"
 	    "  dump_string <index>" "\n"
 	    "  dump_info" "\n"
+	    "  dump_stats" "\n"
 	    "  show_ifdrv" "\n"
 	    "  suspend" "\n"
 	    "  resume" "\n"
@@ -506,7 +510,8 @@ flush_command(struct libusb20_backend *pbe, struct opt
 		    opt->got_dump_device_desc ||
 		    opt->got_dump_curr_config ||
 		    opt->got_dump_all_config ||
-		    opt->got_dump_info);
+		    opt->got_dump_info ||
+		    opt->got_dump_stats);
 
 		if (opt->got_list || dump_any) {
 			dump_device_info(pdev,
@@ -527,6 +532,10 @@ flush_command(struct libusb20_backend *pbe, struct opt
 			dump_device_desc(pdev);
 			dump_config(pdev, 1);
 		}
+		if (opt->got_dump_stats) {
+			printf("\n");
+			dump_device_stats(pdev);
+		}
 		if (dump_any) {
 			printf("\n");
 		}
@@ -749,6 +758,12 @@ main(int argc, char **argv)
 			if (opt->got_dump_info)
 				duplicate_option(argv[n]);
 			opt->got_dump_info = 1;
+			opt->got_any++;
+			break;
+		case T_DUMP_STATS:
+			if (opt->got_dump_stats)
+				duplicate_option(argv[n]);
+			opt->got_dump_stats = 1;
 			opt->got_any++;
 			break;
 		case T_DUMP_STRING:


More information about the svn-src-all mailing list