diff mbox series

[2/2] monitor: Add iso packet count to analyze command

Message ID 20210413180430.356676-2-hj.tedd.an@gmail.com
State New
Headers show
Series None | expand

Commit Message

Tedd Ho-Jeong An April 13, 2021, 6:04 p.m. UTC
From: Tedd Ho-Jeong An <tedd.an@intel.com>

This patch adds iso tx/rx packet count to analyze command.
---
 monitor/analyze.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/monitor/analyze.c b/monitor/analyze.c
index 022761c21..225a37ffa 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -34,6 +34,7 @@  struct hci_dev {
 	unsigned long num_evt;
 	unsigned long num_acl;
 	unsigned long num_sco;
+	unsigned long num_iso;
 	unsigned long vendor_diag;
 	unsigned long system_note;
 	unsigned long user_log;
@@ -77,6 +78,7 @@  static void dev_destroy(void *data)
 	printf("  %lu events\n", dev->num_evt);
 	printf("  %lu ACL packets\n", dev->num_acl);
 	printf("  %lu SCO packets\n", dev->num_sco);
+	printf("  %lu ISO packets\n", dev->num_iso);
 	printf("  %lu vendor diagnostics\n", dev->vendor_diag);
 	printf("  %lu system notes\n", dev->system_note);
 	printf("  %lu user logs\n", dev->user_log);
@@ -255,6 +257,22 @@  static void sco_pkt(struct timeval *tv, uint16_t index,
 	dev->num_sco++;
 }
 
+static void iso_pkt(struct timeval *tv, uint16_t index,
+					const void *data, uint16_t size)
+{
+	const struct bt_hci_iso_hdr *hdr = data;
+	struct hci_dev *dev;
+
+	data += sizeof(*hdr);
+	size -= sizeof(*hdr);
+
+	dev = dev_lookup(index);
+	if (!dev)
+		return;
+
+	dev->num_iso++;
+}
+
 static void info_index(struct timeval *tv, uint16_t index,
 					const void *data, uint16_t size)
 {
@@ -448,6 +466,10 @@  void analyze_trace(const char *path)
 		case BTSNOOP_OPCODE_CTRL_EVENT:
 			ctrl_evt(&tv, index, buf, pktlen);
 			break;
+		case BTSNOOP_OPCODE_ISO_TX_PKT:
+		case BTSNOOP_OPCODE_ISO_RX_PKT:
+			iso_pkt(&tv, index, buf, pktlen);
+			break;
 		default:
 			fprintf(stderr, "Unknown opcode %u\n", opcode);
 			unknown_opcode(&tv, index, buf, pktlen);