monitor/analyze: Fix not dequeing TX packet properly
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 28 Jul 2023 21:48:43 +0000 (14:48 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:03 +0000 (19:04 +0530)
num_completed_packets_evt contain a count for how many packets have been
completed per handle.

monitor/analyze.c

index 676de6b..0546d3e 100755 (executable)
@@ -534,6 +534,7 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv,
                struct hci_conn *conn;
                struct timeval res;
                struct timeval *last_tx;
+               int j;
 
                data += 4;
                size -= 4;
@@ -544,15 +545,17 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv,
 
                conn->tx_num_comp += count;
 
-               last_tx = queue_pop_head(conn->tx_queue);
-               if (last_tx) {
-                       timersub(tv, last_tx, &res);
+               for (j = 0; j < count; j++) {
+                       last_tx = queue_pop_head(conn->tx_queue);
+                       if (last_tx) {
+                               timersub(tv, last_tx, &res);
 
-                       packet_latency_add(&conn->tx_l, &res);
+                               packet_latency_add(&conn->tx_l, &res);
 
-                       plot_add(conn->plot, &res, count);
+                               plot_add(conn->plot, &res, count);
 
-                       free(last_tx);
+                               free(last_tx);
+                       }
                }
        }
 }