mirror of
https://git.proxmox.com/git/qemu
synced 2025-08-14 14:13:06 +00:00
usb-hub: add tracepoints
Add tracepoints to the usb hub emulation. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
f5bf14bf39
commit
529f8f9fa9
@ -22,11 +22,10 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "trace.h"
|
||||||
#include "hw/usb.h"
|
#include "hw/usb.h"
|
||||||
#include "hw/usb/desc.h"
|
#include "hw/usb/desc.h"
|
||||||
|
|
||||||
//#define DEBUG
|
|
||||||
|
|
||||||
#define NUM_PORTS 8
|
#define NUM_PORTS 8
|
||||||
|
|
||||||
typedef struct USBHubPort {
|
typedef struct USBHubPort {
|
||||||
@ -157,6 +156,7 @@ static void usb_hub_attach(USBPort *port1)
|
|||||||
USBHubState *s = port1->opaque;
|
USBHubState *s = port1->opaque;
|
||||||
USBHubPort *port = &s->ports[port1->index];
|
USBHubPort *port = &s->ports[port1->index];
|
||||||
|
|
||||||
|
trace_usb_hub_attach(s->dev.addr, port1->index + 1);
|
||||||
port->wPortStatus |= PORT_STAT_CONNECTION;
|
port->wPortStatus |= PORT_STAT_CONNECTION;
|
||||||
port->wPortChange |= PORT_STAT_C_CONNECTION;
|
port->wPortChange |= PORT_STAT_C_CONNECTION;
|
||||||
if (port->port.dev->speed == USB_SPEED_LOW) {
|
if (port->port.dev->speed == USB_SPEED_LOW) {
|
||||||
@ -172,6 +172,7 @@ static void usb_hub_detach(USBPort *port1)
|
|||||||
USBHubState *s = port1->opaque;
|
USBHubState *s = port1->opaque;
|
||||||
USBHubPort *port = &s->ports[port1->index];
|
USBHubPort *port = &s->ports[port1->index];
|
||||||
|
|
||||||
|
trace_usb_hub_detach(s->dev.addr, port1->index + 1);
|
||||||
usb_wakeup(s->intr);
|
usb_wakeup(s->intr);
|
||||||
|
|
||||||
/* Let upstream know the device on this port is gone */
|
/* Let upstream know the device on this port is gone */
|
||||||
@ -247,6 +248,7 @@ static void usb_hub_handle_reset(USBDevice *dev)
|
|||||||
USBHubPort *port;
|
USBHubPort *port;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
trace_usb_hub_reset(s->dev.addr);
|
||||||
for (i = 0; i < NUM_PORTS; i++) {
|
for (i = 0; i < NUM_PORTS; i++) {
|
||||||
port = s->ports + i;
|
port = s->ports + i;
|
||||||
port->wPortStatus = PORT_STAT_POWER;
|
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,
|
static int usb_hub_handle_control(USBDevice *dev, USBPacket *p,
|
||||||
int request, int value, int index, int length, uint8_t *data)
|
int request, int value, int index, int length, uint8_t *data)
|
||||||
{
|
{
|
||||||
USBHubState *s = (USBHubState *)dev;
|
USBHubState *s = (USBHubState *)dev;
|
||||||
int ret;
|
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);
|
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
|
||||||
if (ret >= 0) {
|
if (ret >= 0) {
|
||||||
return ret;
|
return ret;
|
||||||
@ -295,6 +324,9 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
port = &s->ports[n];
|
port = &s->ports[n];
|
||||||
|
trace_usb_hub_get_port_status(s->dev.addr, index,
|
||||||
|
port->wPortStatus,
|
||||||
|
port->wPortChange);
|
||||||
data[0] = port->wPortStatus;
|
data[0] = port->wPortStatus;
|
||||||
data[1] = port->wPortStatus >> 8;
|
data[1] = port->wPortStatus >> 8;
|
||||||
data[2] = port->wPortChange;
|
data[2] = port->wPortChange;
|
||||||
@ -315,6 +347,10 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p,
|
|||||||
unsigned int n = index - 1;
|
unsigned int n = index - 1;
|
||||||
USBHubPort *port;
|
USBHubPort *port;
|
||||||
USBDevice *dev;
|
USBDevice *dev;
|
||||||
|
|
||||||
|
trace_usb_hub_set_port_feature(s->dev.addr, index,
|
||||||
|
feature_name(value));
|
||||||
|
|
||||||
if (n >= NUM_PORTS) {
|
if (n >= NUM_PORTS) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -345,6 +381,9 @@ static int usb_hub_handle_control(USBDevice *dev, USBPacket *p,
|
|||||||
unsigned int n = index - 1;
|
unsigned int n = index - 1;
|
||||||
USBHubPort *port;
|
USBHubPort *port;
|
||||||
|
|
||||||
|
trace_usb_hub_clear_port_feature(s->dev.addr, index,
|
||||||
|
feature_name(value));
|
||||||
|
|
||||||
if (n >= NUM_PORTS) {
|
if (n >= NUM_PORTS) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
11
trace-events
11
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_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"
|
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(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_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"
|
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_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"
|
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
|
# hw/usb/host-linux.c
|
||||||
usb_host_open_started(int bus, int addr) "dev %d:%d"
|
usb_host_open_started(int bus, int addr) "dev %d:%d"
|
||||||
usb_host_open_success(int bus, int addr) "dev %d:%d"
|
usb_host_open_success(int bus, int addr) "dev %d:%d"
|
||||||
|
Loading…
Reference in New Issue
Block a user