diff mbox series

[BlueZ,v2,2/5] monitor/analyze: Use conn_pkt_tx on acl_pkt

Message ID 20230801232135.535733-2-luiz.dentz@gmail.com (mailing list archive)
State Superseded
Headers show
Series [BlueZ,v2,1/5] monitor: Add TX frame number and speed estimation | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Luiz Augusto von Dentz Aug. 1, 2023, 11:21 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes use of conn_pkt_tx also on acl_pkt like other connections.
---
 monitor/analyze.c | 49 ++++++++++++++++++-----------------------------
 1 file changed, 19 insertions(+), 30 deletions(-)
diff mbox series

Patch

diff --git a/monitor/analyze.c b/monitor/analyze.c
index db026190701d..a016e26e31ac 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -600,6 +600,24 @@  static void event_pkt(struct timeval *tv, uint16_t index,
 	}
 }
 
+static void conn_pkt_tx(struct hci_conn *conn, struct timeval *tv,
+					uint16_t size)
+{
+	struct timeval *last_tx;
+
+	conn->tx_num++;
+
+	last_tx = new0(struct timeval, 1);
+	memcpy(last_tx, tv, sizeof(*tv));
+	queue_push_tail(conn->tx_queue, last_tx);
+	conn->tx_bytes += size;
+
+	if (!conn->tx_pkt_min || size < conn->tx_pkt_min)
+		conn->tx_pkt_min = size;
+	if (!conn->tx_pkt_max || size > conn->tx_pkt_max)
+		conn->tx_pkt_max = size;
+}
+
 static void acl_pkt(struct timeval *tv, uint16_t index, bool out,
 					const void *data, uint16_t size)
 {
@@ -637,39 +655,12 @@  static void acl_pkt(struct timeval *tv, uint16_t index, bool out,
 	}
 
 	if (out) {
-		struct timeval *last_tx;
-
-		conn->tx_num++;
-		last_tx = new0(struct timeval, 1);
-		memcpy(last_tx, tv, sizeof(*tv));
-		queue_push_tail(conn->tx_queue, last_tx);
-		conn->tx_bytes += size;
-
-		if (!conn->tx_pkt_min || size < conn->tx_pkt_min)
-			conn->tx_pkt_min = size;
-		if (!conn->tx_pkt_max || size > conn->tx_pkt_max)
-			conn->tx_pkt_max = size;
+		conn_pkt_tx(conn, tv, size);
 	} else {
 		conn->rx_num++;
 	}
 }
 
-static void conn_pkt_tx(struct hci_conn *conn, struct timeval *tv,
-					uint16_t size)
-{
-	struct timeval *last_tx;
-
-	last_tx = new0(struct timeval, 1);
-	memcpy(last_tx, tv, sizeof(*tv));
-	queue_push_tail(conn->tx_queue, last_tx);
-	conn->tx_bytes += size;
-
-	if (!conn->tx_pkt_min || size < conn->tx_pkt_min)
-		conn->tx_pkt_min = size;
-	if (!conn->tx_pkt_max || size > conn->tx_pkt_max)
-		conn->tx_pkt_max = size;
-}
-
 static void sco_pkt(struct timeval *tv, uint16_t index, bool out,
 					const void *data, uint16_t size)
 {
@@ -690,7 +681,6 @@  static void sco_pkt(struct timeval *tv, uint16_t index, bool out,
 		return;
 
 	if (out) {
-		conn->tx_num++;
 		conn_pkt_tx(conn, tv, size - sizeof(*hdr));
 	} else {
 		conn->rx_num++;
@@ -778,7 +768,6 @@  static void iso_pkt(struct timeval *tv, uint16_t index, bool out,
 		return;
 
 	if (out) {
-		conn->tx_num++;
 		conn_pkt_tx(conn, tv, size - sizeof(*hdr));
 	} else {
 		conn->rx_num++;