monitor: Add latency when decoding BT_HCI_EVT_NUM_COMPLETED_PACKETS

This adds latency, min-max, and median information when decoding
BT_HCI_EVT_NUM_COMPLETED_PACKETS so it works similarly to --analyze:

> HCI Event: Number of Completed Packets (0x13) plen 5
        Num handles: 1
        Handle: 256 Address: XX:XX:XX:XX:XX:XX
        Count: 1
        Latency: 23 msec (2-66 msec ~19 msec)
This commit is contained in:
Luiz Augusto von Dentz 2023-05-18 16:14:49 -07:00
parent e99fbb5e4e
commit cd176eb2d4
6 changed files with 344 additions and 208 deletions

View File

@ -706,7 +706,8 @@ void broadcom_lm_diag(const void *data, uint8_t size)
}
}
static void lm_diag_evt(uint16_t index, const void *data, uint8_t size)
static void lm_diag_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
broadcom_lm_diag(data, 63);
}

View File

@ -793,11 +793,13 @@ const struct vendor_ocf *intel_vendor_ocf(uint16_t ocf)
return NULL;
}
static void startup_evt(uint16_t index, const void *data, uint8_t size)
static void startup_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
}
static void fatal_exception_evt(uint16_t index, const void *data, uint8_t size)
static void fatal_exception_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint16_t line = get_le16(data);
uint8_t module = get_u8(data + 2);
@ -808,7 +810,8 @@ static void fatal_exception_evt(uint16_t index, const void *data, uint8_t size)
print_field("Reason: 0x%2.2x", reason);
}
static void bootup_evt(uint16_t index, const void *data, uint8_t size)
static void bootup_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t zero = get_u8(data);
uint8_t num_packets = get_u8(data + 1);
@ -911,7 +914,8 @@ static void bootup_evt(uint16_t index, const void *data, uint8_t size)
print_field("DDC status: %s (0x%2.2x)", str, ddc_status);
}
static void default_bd_data_evt(uint16_t index, const void *data, uint8_t size)
static void default_bd_data_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t mem_status = get_u8(data);
const char *str;
@ -928,8 +932,8 @@ static void default_bd_data_evt(uint16_t index, const void *data, uint8_t size)
print_field("Memory status: %s (0x%2.2x)", str, mem_status);
}
static void secure_send_commands_result_evt(uint16_t index, const void *data,
uint8_t size)
static void secure_send_commands_result_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t result = get_u8(data);
uint16_t opcode = get_le16(data + 1);
@ -973,7 +977,8 @@ static void secure_send_commands_result_evt(uint16_t index, const void *data,
print_status(status);
}
static void debug_exception_evt(uint16_t index, const void *data, uint8_t size)
static void debug_exception_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint16_t line = get_le16(data);
uint8_t module = get_u8(data + 2);
@ -984,8 +989,8 @@ static void debug_exception_evt(uint16_t index, const void *data, uint8_t size)
print_field("Reason: 0x%2.2x", reason);
}
static void le_link_established_evt(uint16_t index, const void *data,
uint8_t size)
static void le_link_established_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint16_t handle = get_le16(data);
uint32_t access_addr = get_le32(data + 10);
@ -999,7 +1004,8 @@ static void le_link_established_evt(uint16_t index, const void *data,
packet_hexdump(data + 14, size - 14);
}
static void scan_status_evt(uint16_t index, const void *data, uint8_t size)
static void scan_status_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t enable = get_u8(data);
@ -1014,15 +1020,16 @@ static void scan_status_evt(uint16_t index, const void *data, uint8_t size)
}
static void act_deact_traces_complete_evt(uint16_t index, const void *data,
uint8_t size)
static void act_deact_traces_complete_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
print_status(status);
}
static void lmp_pdu_trace_evt(uint16_t index, const void *data, uint8_t size)
static void lmp_pdu_trace_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t type, len, id;
uint16_t handle, count;
@ -1116,16 +1123,16 @@ static void lmp_pdu_trace_evt(uint16_t index, const void *data, uint8_t size)
}
}
static void write_bd_data_complete_evt(uint16_t index, const void *data,
uint8_t size)
static void write_bd_data_complete_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t status = get_u8(data);
print_status(status);
}
static void sco_rejected_via_lmp_evt(uint16_t index, const void *data,
uint8_t size)
static void sco_rejected_via_lmp_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t reason = get_u8(data + 6);
@ -1133,8 +1140,8 @@ static void sco_rejected_via_lmp_evt(uint16_t index, const void *data,
packet_print_error("Reason", reason);
}
static void ptt_switch_notification_evt(uint16_t index, const void *data,
uint8_t size)
static void ptt_switch_notification_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint16_t handle = get_le16(data);
uint8_t table = get_u8(data + 2);
@ -1157,7 +1164,8 @@ static void ptt_switch_notification_evt(uint16_t index, const void *data,
print_field("Packet type table: %s (0x%2.2x)", str, table);
}
static void system_exception_evt(uint16_t index, const void *data, uint8_t size)
static void system_exception_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
uint8_t type = get_u8(data);
const char *str;
@ -1741,7 +1749,8 @@ static const struct intel_tlv *process_ext_subevent(const struct intel_tlv *tlv,
return next_tlv;
}
static void intel_vendor_ext_evt(uint16_t index, const void *data, uint8_t size)
static void intel_vendor_ext_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
/* The data pointer points to a number of tlv.*/
const struct intel_tlv *tlv = data;

View File

@ -299,7 +299,8 @@ const struct vendor_ocf *msft_vendor_ocf(void)
return &vendor_ocf_entry;
}
static void msft_evt(uint16_t index, const void *data, uint8_t size)
static void msft_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
packet_hexdump(data, size);
}

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,10 @@ struct packet_conn_data {
uint8_t type;
uint8_t dst[6];
uint8_t dst_type;
struct queue *tx_q;
struct timeval tx_min;
struct timeval tx_max;
struct timeval tx_med;
void *data;
void (*destroy)(void *data);
};

View File

@ -25,7 +25,8 @@ struct vendor_ocf {
struct vendor_evt {
uint8_t evt;
const char *str;
void (*evt_func) (uint16_t index, const void *data, uint8_t size);
void (*evt_func) (struct timeval *tv, uint16_t index,
const void *data, uint8_t size);
uint8_t evt_size;
bool evt_fixed;
};