Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jan 2020 09:41:00 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r356408 - stable/10/usr.sbin/usbconfig
Message-ID:  <202001060941.0069f0hK015897@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Jan  6 09:40:59 2020
New Revision: 356408
URL: https://svnweb.freebsd.org/changeset/base/356408

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/10/usr.sbin/usbconfig/dump.c
  stable/10/usr.sbin/usbconfig/dump.h
  stable/10/usr.sbin/usbconfig/usbconfig.8
  stable/10/usr.sbin/usbconfig/usbconfig.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/usbconfig/dump.c
==============================================================================
--- stable/10/usr.sbin/usbconfig/dump.c	Mon Jan  6 09:40:18 2020	(r356407)
+++ stable/10/usr.sbin/usbconfig/dump.c	Mon Jan  6 09:40:59 2020	(r356408)
@@ -481,3 +481,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/10/usr.sbin/usbconfig/dump.h
==============================================================================
--- stable/10/usr.sbin/usbconfig/dump.h	Mon Jan  6 09:40:18 2020	(r356407)
+++ stable/10/usr.sbin/usbconfig/dump.h	Mon Jan  6 09:40:59 2020	(r356408)
@@ -35,6 +35,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/10/usr.sbin/usbconfig/usbconfig.8
==============================================================================
--- stable/10/usr.sbin/usbconfig/usbconfig.8	Mon Jan  6 09:40:18 2020	(r356407)
+++ stable/10/usr.sbin/usbconfig/usbconfig.8	Mon Jan  6 09:40:59 2020	(r356408)
@@ -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/10/usr.sbin/usbconfig/usbconfig.c
==============================================================================
--- stable/10/usr.sbin/usbconfig/usbconfig.c	Mon Jan  6 09:40:18 2020	(r356407)
+++ stable/10/usr.sbin/usbconfig/usbconfig.c	Mon Jan  6 09:40:59 2020	(r356408)
@@ -80,6 +80,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;
@@ -119,6 +120,7 @@ enum {
 	T_DUMP_ALL_CONFIG_DESC,
 	T_DUMP_STRING,
 	T_DUMP_INFO,
+	T_DUMP_STATS,
 	T_SUSPEND,
 	T_RESUME,
 	T_POWER_OFF,
@@ -153,6 +155,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},
@@ -294,6 +297,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"
@@ -504,7 +508,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,
@@ -525,6 +530,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");
 		}
@@ -747,6 +756,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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001060941.0069f0hK015897>