usb: dwc3: trace: decode ctrl request
Instead of *always* dumping raw ctrl bytes, let's decode standard requests which will make the lives of those debugging DWC3 quite a bit easier. Output will now look like so: irq/34-dwc3-1594 [000] d..1 107.573081: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 107.573694: dwc3_ctrl_req: Set Address(Addr = 01) irq/34-dwc3-1594 [000] d..1 107.588319: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 107.588816: dwc3_ctrl_req: Get Configuration Descriptor(Index = 0, Length = 9) irq/34-dwc3-1594 [000] d..1 107.589191: dwc3_ctrl_req: Set Configuration(Config = 3) irq/34-dwc3-1594 [000] d..1 107.589846: dwc3_ctrl_req: Get BOS Descriptor(Index = 0, Length = 5) irq/34-dwc3-1594 [000] d..1 107.590146: dwc3_ctrl_req: Get BOS Descriptor(Index = 0, Length = 22) irq/34-dwc3-1594 [000] d..1 107.590546: dwc3_ctrl_req: Get Configuration Descriptor(Index = 0, Length = 9) irq/34-dwc3-1594 [000] d..1 107.590840: dwc3_ctrl_req: Get Configuration Descriptor(Index = 0, Length = 69) irq/34-dwc3-1594 [000] d..1 107.591138: dwc3_ctrl_req: Get Configuration Descriptor(Index = 1, Length = 9) irq/34-dwc3-1594 [000] d..1 107.591541: dwc3_ctrl_req: Get Configuration Descriptor(Index = 1, Length = 32) irq/34-dwc3-1594 [000] d..1 107.591834: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 114.701005: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 114.721080: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 114.722709: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 114.728979: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 114.730544: dwc3_ctrl_req: Get Device Qualifier Descriptor(Index = 0, Length = 10) irq/34-dwc3-1594 [000] d..1 115.776018: dwc3_ctrl_req: Get Configuration Descriptor(Index = 0, Length = 9) irq/34-dwc3-1594 [000] d..1 115.776760: dwc3_ctrl_req: Set Configuration(Config = 0) irq/34-dwc3-1594 [000] d..1 115.777676: dwc3_ctrl_req: Get Configuration(Length = 1) irq/34-dwc3-1594 [000] d..1 115.924797: dwc3_ctrl_req: Get Device Descriptor(Index = 0, Length = 18) irq/34-dwc3-1594 [000] d..1 115.929025: dwc3_ctrl_req: Get String Descriptor(Index = 0, Length = 500) irq/34-dwc3-1594 [000] d..1 115.929566: dwc3_ctrl_req: Get String Descriptor(Index = 1, Length = 500) irq/34-dwc3-1594 [000] d..1 115.930911: dwc3_ctrl_req: Get String Descriptor(Index = 0, Length = 500) irq/34-dwc3-1594 [000] d..1 115.931528: dwc3_ctrl_req: Get String Descriptor(Index = 2, Length = 500) irq/34-dwc3-1594 [000] d..1 115.932950: dwc3_ctrl_req: Get String Descriptor(Index = 0, Length = 500) irq/34-dwc3-1594 [000] d..1 115.933533: dwc3_ctrl_req: Get String Descriptor(Index = 3, Length = 500) Note that Class and Vendor requests won't be decoded for obvious reasons. Those will be printed as a raw sequence of bytes. This patch has been tested against a normal host (both Linux and Windows) and USB30CV Chapter 9 tests. Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
This commit is contained in:
Родитель
3587f36a12
Коммит
af32423a2d
|
@ -222,6 +222,240 @@ dwc3_gadget_event_string(char *str, const struct dwc3_event_devt *event)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_get_status(__u8 t, __u16 i, __u16 l, char *str)
|
||||||
|
{
|
||||||
|
switch (t & USB_RECIP_MASK) {
|
||||||
|
case USB_RECIP_INTERFACE:
|
||||||
|
sprintf(str, "Get Interface Status(Intf = %d, Length = %d)",
|
||||||
|
i, l);
|
||||||
|
break;
|
||||||
|
case USB_RECIP_ENDPOINT:
|
||||||
|
sprintf(str, "Get Endpoint Status(ep%d%s)",
|
||||||
|
i & ~USB_DIR_IN,
|
||||||
|
i & USB_DIR_IN ? "in" : "out");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_set_clear_feature(__u8 t, __u8 b, __u16 v,
|
||||||
|
__u16 i, char *str)
|
||||||
|
{
|
||||||
|
switch (t & USB_RECIP_MASK) {
|
||||||
|
case USB_RECIP_DEVICE:
|
||||||
|
sprintf(str, "%s Device Feature(%s%s)",
|
||||||
|
b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
|
||||||
|
({char *s;
|
||||||
|
switch (v) {
|
||||||
|
case USB_DEVICE_SELF_POWERED:
|
||||||
|
s = "Self Powered";
|
||||||
|
break;
|
||||||
|
case USB_DEVICE_REMOTE_WAKEUP:
|
||||||
|
s = "Remote Wakeup";
|
||||||
|
break;
|
||||||
|
case USB_DEVICE_TEST_MODE:
|
||||||
|
s = "Test Mode";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
s = "UNKNOWN";
|
||||||
|
} s; }),
|
||||||
|
v == USB_DEVICE_TEST_MODE ?
|
||||||
|
({ char *s;
|
||||||
|
switch (i) {
|
||||||
|
case TEST_J:
|
||||||
|
s = ": TEST_J";
|
||||||
|
break;
|
||||||
|
case TEST_K:
|
||||||
|
s = ": TEST_K";
|
||||||
|
break;
|
||||||
|
case TEST_SE0_NAK:
|
||||||
|
s = ": TEST_SE0_NAK";
|
||||||
|
break;
|
||||||
|
case TEST_PACKET:
|
||||||
|
s = ": TEST_PACKET";
|
||||||
|
break;
|
||||||
|
case TEST_FORCE_EN:
|
||||||
|
s = ": TEST_FORCE_EN";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
s = ": UNKNOWN";
|
||||||
|
} s; }) : "");
|
||||||
|
break;
|
||||||
|
case USB_RECIP_INTERFACE:
|
||||||
|
sprintf(str, "%s Interface Feature(%s)",
|
||||||
|
b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
|
||||||
|
v == USB_INTRF_FUNC_SUSPEND ?
|
||||||
|
"Function Suspend" : "UNKNOWN");
|
||||||
|
break;
|
||||||
|
case USB_RECIP_ENDPOINT:
|
||||||
|
sprintf(str, "%s Endpoint Feature(%s ep%d%s)",
|
||||||
|
b == USB_REQ_CLEAR_FEATURE ? "Clear" : "Set",
|
||||||
|
v == USB_ENDPOINT_HALT ? "Halt" : "UNKNOWN",
|
||||||
|
i & ~USB_DIR_IN,
|
||||||
|
i & USB_DIR_IN ? "in" : "out");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_set_address(__u16 v, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Set Address(Addr = %02x)", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_get_set_descriptor(__u8 t, __u8 b, __u16 v,
|
||||||
|
__u16 i, __u16 l, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "%s %s Descriptor(Index = %d, Length = %d)",
|
||||||
|
b == USB_REQ_GET_DESCRIPTOR ? "Get" : "Set",
|
||||||
|
({ char *s;
|
||||||
|
switch (v >> 8) {
|
||||||
|
case USB_DT_DEVICE:
|
||||||
|
s = "Device";
|
||||||
|
break;
|
||||||
|
case USB_DT_CONFIG:
|
||||||
|
s = "Configuration";
|
||||||
|
break;
|
||||||
|
case USB_DT_STRING:
|
||||||
|
s = "String";
|
||||||
|
break;
|
||||||
|
case USB_DT_INTERFACE:
|
||||||
|
s = "Interface";
|
||||||
|
break;
|
||||||
|
case USB_DT_ENDPOINT:
|
||||||
|
s = "Endpoint";
|
||||||
|
break;
|
||||||
|
case USB_DT_DEVICE_QUALIFIER:
|
||||||
|
s = "Device Qualifier";
|
||||||
|
break;
|
||||||
|
case USB_DT_OTHER_SPEED_CONFIG:
|
||||||
|
s = "Other Speed Config";
|
||||||
|
break;
|
||||||
|
case USB_DT_INTERFACE_POWER:
|
||||||
|
s = "Interface Power";
|
||||||
|
break;
|
||||||
|
case USB_DT_OTG:
|
||||||
|
s = "OTG";
|
||||||
|
break;
|
||||||
|
case USB_DT_DEBUG:
|
||||||
|
s = "Debug";
|
||||||
|
break;
|
||||||
|
case USB_DT_INTERFACE_ASSOCIATION:
|
||||||
|
s = "Interface Association";
|
||||||
|
break;
|
||||||
|
case USB_DT_BOS:
|
||||||
|
s = "BOS";
|
||||||
|
break;
|
||||||
|
case USB_DT_DEVICE_CAPABILITY:
|
||||||
|
s = "Device Capability";
|
||||||
|
break;
|
||||||
|
case USB_DT_PIPE_USAGE:
|
||||||
|
s = "Pipe Usage";
|
||||||
|
break;
|
||||||
|
case USB_DT_SS_ENDPOINT_COMP:
|
||||||
|
s = "SS Endpoint Companion";
|
||||||
|
break;
|
||||||
|
case USB_DT_SSP_ISOC_ENDPOINT_COMP:
|
||||||
|
s = "SSP Isochronous Endpoint Companion";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
s = "UNKNOWN";
|
||||||
|
break;
|
||||||
|
} s; }), v & 0xff, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline void dwc3_decode_get_configuration(__u16 l, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Get Configuration(Length = %d)", l);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_set_configuration(__u8 v, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Set Configuration(Config = %d)", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_get_intf(__u16 i, __u16 l, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Get Interface(Intf = %d, Length = %d)", i, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_set_intf(__u8 v, __u16 i, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Set Interface(Intf = %d, Alt.Setting = %d)", i, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_synch_frame(__u16 i, __u16 l, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Synch Frame(Endpoint = %d, Length = %d)", i, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_set_sel(__u16 l, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Set SEL(Length = %d)", l);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void dwc3_decode_set_isoch_delay(__u8 v, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "Set Isochronous Delay(Delay = %d ns)", v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dwc3_decode_ctrl - returns a string represetion of ctrl request
|
||||||
|
*/
|
||||||
|
static inline const char *dwc3_decode_ctrl(char *str, __u8 bRequestType,
|
||||||
|
__u8 bRequest, __u16 wValue, __u16 wIndex, __u16 wLength)
|
||||||
|
{
|
||||||
|
switch (bRequest) {
|
||||||
|
case USB_REQ_GET_STATUS:
|
||||||
|
dwc3_decode_get_status(bRequestType, wIndex, wLength, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_CLEAR_FEATURE:
|
||||||
|
case USB_REQ_SET_FEATURE:
|
||||||
|
dwc3_decode_set_clear_feature(bRequestType, bRequest, wValue,
|
||||||
|
wIndex, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_SET_ADDRESS:
|
||||||
|
dwc3_decode_set_address(wValue, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_GET_DESCRIPTOR:
|
||||||
|
case USB_REQ_SET_DESCRIPTOR:
|
||||||
|
dwc3_decode_get_set_descriptor(bRequestType, bRequest, wValue,
|
||||||
|
wIndex, wLength, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_GET_CONFIGURATION:
|
||||||
|
dwc3_decode_get_configuration(wLength, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_SET_CONFIGURATION:
|
||||||
|
dwc3_decode_set_configuration(wValue, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_GET_INTERFACE:
|
||||||
|
dwc3_decode_get_intf(wIndex, wLength, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_SET_INTERFACE:
|
||||||
|
dwc3_decode_set_intf(wValue, wIndex, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_SYNCH_FRAME:
|
||||||
|
dwc3_decode_synch_frame(wIndex, wLength, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_SET_SEL:
|
||||||
|
dwc3_decode_set_sel(wLength, str);
|
||||||
|
break;
|
||||||
|
case USB_REQ_SET_ISOCH_DELAY:
|
||||||
|
dwc3_decode_set_isoch_delay(wValue, str);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sprintf(str, "%02x %02x %02x %02x %02x %02x %02x %02x",
|
||||||
|
bRequestType, bRequest,
|
||||||
|
cpu_to_le16(wValue) & 0xff,
|
||||||
|
cpu_to_le16(wValue) >> 8,
|
||||||
|
cpu_to_le16(wIndex) & 0xff,
|
||||||
|
cpu_to_le16(wIndex) >> 8,
|
||||||
|
cpu_to_le16(wLength) & 0xff,
|
||||||
|
cpu_to_le16(wLength) >> 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dwc3_ep_event_string - returns event name
|
* dwc3_ep_event_string - returns event name
|
||||||
* @event: then event code
|
* @event: then event code
|
||||||
|
|
|
@ -85,6 +85,7 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl,
|
||||||
__field(__u16, wValue)
|
__field(__u16, wValue)
|
||||||
__field(__u16, wIndex)
|
__field(__u16, wIndex)
|
||||||
__field(__u16, wLength)
|
__field(__u16, wLength)
|
||||||
|
__dynamic_array(char, str, DWC3_MSG_MAX)
|
||||||
),
|
),
|
||||||
TP_fast_assign(
|
TP_fast_assign(
|
||||||
__entry->bRequestType = ctrl->bRequestType;
|
__entry->bRequestType = ctrl->bRequestType;
|
||||||
|
@ -93,10 +94,9 @@ DECLARE_EVENT_CLASS(dwc3_log_ctrl,
|
||||||
__entry->wIndex = le16_to_cpu(ctrl->wIndex);
|
__entry->wIndex = le16_to_cpu(ctrl->wIndex);
|
||||||
__entry->wLength = le16_to_cpu(ctrl->wLength);
|
__entry->wLength = le16_to_cpu(ctrl->wLength);
|
||||||
),
|
),
|
||||||
TP_printk("bRequestType %02x bRequest %02x wValue %04x wIndex %04x wLength %d",
|
TP_printk("%s", dwc3_decode_ctrl(__get_str(str), __entry->bRequestType,
|
||||||
__entry->bRequestType, __entry->bRequest,
|
__entry->bRequest, __entry->wValue,
|
||||||
__entry->wValue, __entry->wIndex,
|
__entry->wIndex, __entry->wLength)
|
||||||
__entry->wLength
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче