From 529f8f9fa939b8db13bf5cd1cd549d993cf25cb8 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 23 Mar 2012 15:42:58 +0100 Subject: usb-hub: add tracepoints Add tracepoints to the usb hub emulation. Signed-off-by: Gerd Hoffmann --- hw/usb/dev-hub.c | 43 +++++++++++++++++++++++++++++++++++++++++-- trace-events | 11 ++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-hub.c b/hw/usb/dev-hub.c index eb4e711207..9c9166551e 100644 --- a/hw/usb/dev-hub.c +++ b/hw/usb/dev-hub.c @@ -22,11 +22,10 @@ * THE SOFTWARE. */ #include "qemu-common.h" +#include "trace.h" #include "hw/usb.h" #include "hw/usb/desc.h" -//#define DEBUG - #define NUM_PORTS 8 typedef struct USBHubPort { @@ -157,6 +156,7 @@ static void usb_hub_attach(USBPort *port1) USBHubState *s = port1->opaque; USBHubPort *port = &s->ports[port1->index]; + trace_usb_hub_attach(s->dev.addr, port1->index + 1); port->wPortStatus |= PORT_STAT_CONNECTION; port->wPortChange |= PORT_STAT_C_CONNECTION; if (port->port.dev->speed == USB_SPEED_LOW) { @@ -172,6 +172,7 @@ static void usb_hub_detach(USBPort *port1) USBHubState *s = port1->opaque; USBHubPort *port = &s->ports[port1->index]; + trace_usb_hub_detach(s->dev.addr, port1->index + 1); usb_wakeup(s->intr); /* Let upstream know the device on this port is gone */ @@ -247,6 +248,7 @@ static void usb_hub_handle_reset(USBDevice *dev) USBHubPort *port; int i; + trace_usb_hub_reset(s->dev.addr); for (i = 0; i < NUM_PORTS; i++) { port = s->ports + i; port->wPortStatus = PORT_STAT_POWER; @@ -261,12 +263,39 @@ static void usb_hub_handle_reset(USBDevice *dev) } } +static const char *feature_name(int feature) +{ + static const char *name[] = { + [PORT_CONNECTION] = "connection", + [PORT_ENABLE] = "enable", + [PORT_SUSPEND] = "suspend", + [PORT_OVERCURRENT] = "overcurrent", + [PORT_RESET] = "reset", + [PORT_POWER] = "power", + [PORT_LOWSPEED] = "lowspeed", + [PORT_HIGHSPEED] = "highspeed", + [PORT_C_CONNECTION] = "change connection", + [PORT_C_ENABLE] = "change enable", + [PORT_C_SUSPEND] = "change suspend", + [PORT_C_OVERCURRENT] = "change overcurrent", + [PORT_C_RESET] = "change reset", + [PORT_TEST] = "test", + [PORT_INDICATOR] = "indicator", + }; + if (feature < 0 || feature >= ARRAY_SIZE(name)) { + return "?"; + } + return name[feature] ?: "?"; +} + static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBHubState *s = (USBHubState *)dev; int ret; + trace_usb_hub_control(s->dev.addr, request, value, index, length); + ret = usb_desc_handle_control(dev, p, request, value, index, length, data); if (ret >= 0) { return ret; @@ -295,6 +324,9 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, goto fail; } port = &s->ports[n]; + trace_usb_hub_get_port_status(s->dev.addr, index, + port->wPortStatus, + port->wPortChange); data[0] = port->wPortStatus; data[1] = port->wPortStatus >> 8; data[2] = port->wPortChange; @@ -315,6 +347,10 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, unsigned int n = index - 1; USBHubPort *port; USBDevice *dev; + + trace_usb_hub_set_port_feature(s->dev.addr, index, + feature_name(value)); + if (n >= NUM_PORTS) { goto fail; } @@ -345,6 +381,9 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p, unsigned int n = index - 1; USBHubPort *port; + trace_usb_hub_clear_port_feature(s->dev.addr, index, + feature_name(value)); + if (n >= NUM_PORTS) { goto fail; } diff --git a/trace-events b/trace-events index e3b178767c..e7ce5b2cb3 100644 --- a/trace-events +++ b/trace-events @@ -289,7 +289,7 @@ usb_uhci_td_nextqh(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" usb_uhci_td_async(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" usb_uhci_td_complete(uint32_t qh, uint32_t td) "qh 0x%x, td 0x%x" -# hw/usb-desc.c +# hw/usb/desc.c usb_desc_device(int addr, int len, int ret) "dev %d query device, len %d, ret %d" usb_desc_device_qualifier(int addr, int len, int ret) "dev %d query device qualifier, len %d, ret %d" usb_desc_config(int addr, int index, int len, int ret) "dev %d query config %d, len %d, ret %d" @@ -301,6 +301,15 @@ usb_set_interface(int addr, int iface, int alt, int ret) "dev %d, interface %d, usb_clear_device_feature(int addr, int feature, int ret) "dev %d, feature %d, ret %d" usb_set_device_feature(int addr, int feature, int ret) "dev %d, feature %d, ret %d" +# hw/usb/dev-hub.c +usb_hub_reset(int addr) "dev %d" +usb_hub_control(int addr, int request, int value, int index, int length) "dev %d, req 0x%x, value %d, index %d, langth %d" +usb_hub_get_port_status(int addr, int nr, int status, int changed) "dev %d, port %d, status 0x%x, changed 0x%x" +usb_hub_set_port_feature(int addr, int nr, const char *f) "dev %d, port %d, feature %s" +usb_hub_clear_port_feature(int addr, int nr, const char *f) "dev %d, port %d, feature %s" +usb_hub_attach(int addr, int nr) "dev %d, port %d" +usb_hub_detach(int addr, int nr) "dev %d, port %d" + # hw/usb/host-linux.c usb_host_open_started(int bus, int addr) "dev %d:%d" usb_host_open_success(int bus, int addr) "dev %d:%d" -- cgit v1.2.1