From patchwork Mon Aug 9 22:49:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 12427467 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84569C4338F for ; Mon, 9 Aug 2021 22:49:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6967160FDA for ; Mon, 9 Aug 2021 22:49:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233266AbhHIWuF (ORCPT ); Mon, 9 Aug 2021 18:50:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhHIWuF (ORCPT ); Mon, 9 Aug 2021 18:50:05 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52423C0613D3 for ; Mon, 9 Aug 2021 15:49:44 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id m24-20020a17090a7f98b0290178b1a81700so2338434pjl.4 for ; Mon, 09 Aug 2021 15:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=lRJUx9M9PkpSlRyma5IgNqqGSYHjUDuHJLU3o9RBpa4=; b=DtqOjSac15xS2dz3+eCOolSYnXSMljSIBgfkS7CIp6bBW4Ku6xkQBC4t56a5krEtoc ZM1N4thXEcKtMjG0iRz4bI89lxWrkReiZvmKBImW7GPiRhRvUb4RSvPVMwhr3LJFKNW4 gSryCpIL7/J+XXmWrcQPCm2EZ0o0r29+WKD/c51/2GUnnsBFBFrwdUzXIh3LzVyO8EaR +JLIH6HfXSsb+zn/xyOwMddfDSbjZqmwObPECaYstBEW02yLz6RaVjQi00uaVYa29gXb O0v0DIpBKCVz63em0We2Qz8XB7QPitXXoaajut0dD4NFoshqj0WDPghK0tCqZf5lmo/H wr7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=lRJUx9M9PkpSlRyma5IgNqqGSYHjUDuHJLU3o9RBpa4=; b=No4dXHDoH7zF6lDI/CBJIk1s/eVEB8xsgtR3fp++2dvqQDPkXC3X7O7am25sZYufHi SkH8AchngrTESI7lw5dLk+7+f8UaMV6YAdlB0rIUZuVrqzc+XpPZwwoDrezuK9ZSyuzv xbtnroYSA3ZiaNAepJX0zPacg9dCRFCjrUwWv5rYzrsVsv98EhsxOMDYk6bAc4AhalQ8 Be0xrRSjqbLxDjrPP0zzUi869bvFWoI35iKTwNn9k4OHzOB1K06QYR6lIrDFaDsk8xZK EA6WRaC5Jn1rQjzUbdTEF7oNiOyqlT1cS2xYWKjTM/SNKkqfkQrxP8SH6aAyXRT0ekBc T/qQ== X-Gm-Message-State: AOAM530bUCsZg/K32RCnLPQjradwLkMBPG0xQ86a/bQWqnq2IabICs8E E5zhqzOSqg3HtGYpEa6MCvxM4yN7oe4= X-Google-Smtp-Source: ABdhPJzA9PBNPabh8Jp0Yp+eWQqIsIa9gDTULoeTIC9ciJEG+pbrdqZY2WlEjHD5X2bSNZrBLgIkVA== X-Received: by 2002:a17:902:6904:b029:fb:42b6:e952 with SMTP id j4-20020a1709026904b02900fb42b6e952mr7682620plk.16.1628549383667; Mon, 09 Aug 2021 15:49:43 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id n35sm20826891pfv.152.2021.08.09.15.49.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:49:43 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2 1/5] monitor: Fix median packet size Date: Mon, 9 Aug 2021 15:49:38 -0700 Message-Id: <20210809224942.225915-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Calculating the median packet based on the current median + size / 2 does not account for last packet could smaller e.g. opp transfer could end with just 1 byte which would cut the median in a half, so this switch to more traditional means of calculating by doing total bytes sent / num of packets so each an every packet has the same weight. --- monitor/analyze.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index 839c2f7e9..5e0957ad1 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -61,6 +61,7 @@ struct hci_conn { unsigned long rx_num; unsigned long tx_num; unsigned long tx_num_comp; + size_t tx_bytes; struct timeval last_tx; struct timeval last_tx_comp; struct timeval tx_lat_min; @@ -99,6 +100,8 @@ static void conn_destroy(void *data) break; } + conn->tx_pkt_med = conn->tx_bytes / conn->tx_num; + printf(" Found %s connection with handle %u\n", str, conn->handle); printf(" BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", conn->bdaddr[5], conn->bdaddr[4], conn->bdaddr[3], @@ -485,16 +488,12 @@ static void acl_pkt(struct timeval *tv, uint16_t index, bool out, if (out) { conn->tx_num++; conn->last_tx = *tv; + 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; - if (conn->tx_pkt_med) { - conn->tx_pkt_med += (size + 1); - conn->tx_pkt_med /= 2; - } else - conn->tx_pkt_med = size; } else { conn->rx_num++; } From patchwork Mon Aug 9 22:49:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 12427469 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52444C432BE for ; Mon, 9 Aug 2021 22:49:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 341FE60FC2 for ; Mon, 9 Aug 2021 22:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236062AbhHIWuG (ORCPT ); Mon, 9 Aug 2021 18:50:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhHIWuF (ORCPT ); Mon, 9 Aug 2021 18:50:05 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09227C0613D3 for ; Mon, 9 Aug 2021 15:49:45 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id bo18so8256888pjb.0 for ; Mon, 09 Aug 2021 15:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=P3IDmVuKO7O3HkuAlMjxQDVH5awewBmJogAj+DT7iIw=; b=E3p4vgad15xlbMN8K80JFQfYcoWsulrcvv8gkwic2pEq1wlzPESdvdkR77y9iFDaMr 9yzLRQjtsHGyKrwr8vvrrg9BYthuv3bccOUGX7aFVj5hn8Bscjjg4LIlwIcg4wLn0CLV 4PPybBmaasnP+6sseH4UD6pDJCMyYAitIuisCPkSon7q+lM/TMaLrVmMTYjP92Cz9KvJ JYA2leDVKYgfge3HfLn5xDHZJNAzThk238jaRnPIhJpJVljGGSe4tJYJLlnlecpfhsXJ saSVLCkHEqrKFCojZV49aY5Bk32i+h3IgFkBaPD4/qKFo35hL+tyTbqavjwbOPqvQGmQ 2Dlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P3IDmVuKO7O3HkuAlMjxQDVH5awewBmJogAj+DT7iIw=; b=ujeNHCwefSjU/K5g22r5gHlewcg8mhfvXh8IYJ9dz+uUPuYNacrmihKmdXLyIQti0V z/nYPUR/sahZhyQew/r4YSbhLGCyFITtXSQBy7YF3vYB+n5GKRtjJvTbxHO0edc1G2gb ALugGbLr86SrAw2NCLKzCOzrQKMfL8jATNvJF7K27/hK3YeOID2wQo+G0iC83p+NAKAB 1HKCDCO9ycgg6ruq+h2LOyRLk4gT+loZ7Y8Hpv2d5ftAWO/8ULWONKhTWNHF8KOC80hO n0LQMHHbUyc2P8Y521zVXBz0t0Qp3jX2oXuyz9VRWunv31ShcViXWICga5acVdyuwCJJ gpHA== X-Gm-Message-State: AOAM533QKmzea900kb4Avi19KR/0UmgR733J23Jgt9YXTVflofP/UIK4 i505gSY4Lie9x/S6V/NOd3bDmJ8GAtU= X-Google-Smtp-Source: ABdhPJxz6Y/eBT9UNTifUUy6i2TrmlK/2AnaK39kIhO0nQTlV6rsudqrJFE8U+fCgVnSGkXPS0nyFg== X-Received: by 2002:a17:90a:ff94:: with SMTP id hf20mr12266491pjb.64.1628549384370; Mon, 09 Aug 2021 15:49:44 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id n35sm20826891pfv.152.2021.08.09.15.49.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:49:44 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2 2/5] monitor: Fix minimun packet latency Date: Mon, 9 Aug 2021 15:49:39 -0700 Message-Id: <20210809224942.225915-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210809224942.225915-1-luiz.dentz@gmail.com> References: <20210809224942.225915-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz It seems timer_sub can produce negative values leading to median packet latency to be negative e.g conn->last_tx_compl is ahead of conn->last_tx, in which case it should be discarded. --- monitor/analyze.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index 5e0957ad1..d504c8d84 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -386,8 +386,9 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv, if (timerisset(&conn->last_tx)) { timersub(&conn->last_tx_comp, &conn->last_tx, &res); - if (!timerisset(&conn->tx_lat_min) || - timercmp(&res, &conn->tx_lat_min, <)) + if ((!timerisset(&conn->tx_lat_min) || + timercmp(&res, &conn->tx_lat_min, <)) && + res.tv_sec >= 0 && res.tv_usec >= 0) conn->tx_lat_min = res; if (!timerisset(&conn->tx_lat_max) || @@ -408,6 +409,8 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv, tmp.tv_usec -= 1000000; } } + + conn->tx_lat_med = tmp; } else conn->tx_lat_med = res; From patchwork Mon Aug 9 22:49:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 12427471 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5317C4338F for ; Mon, 9 Aug 2021 22:49:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8EB860FC2 for ; Mon, 9 Aug 2021 22:49:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236674AbhHIWuI (ORCPT ); Mon, 9 Aug 2021 18:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbhHIWuG (ORCPT ); Mon, 9 Aug 2021 18:50:06 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E4BC0613D3 for ; Mon, 9 Aug 2021 15:49:46 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id j1so30304110pjv.3 for ; Mon, 09 Aug 2021 15:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=gdVERoANZ0tlHyrIe2eSl8nR3RSsn9oSS1Ntfv4qMVw=; b=lhjV55QQ5WIXsRp6oz+talGjUNIu8WZXtjvrIZAb0OKqbYFiM2sDN+PLmhPFA5rXq9 wWs3f8ZFvnod4iQy16OvmYgDaAT3spfEB1r5k5hzYdkL/razLGa9J6wLrUXrD8u1hjj/ X7xVSgnjy5oiQWTejvauR6GkZP6PnzolDC6sWAwFjlUVX66iDZg3XbZiUH8SNhaWhOPl qkfInn5UUTYSYYuWxgK2BRukBxtENJmW0CERRFvLQVsaG566EGGf0CfGwz/TFWyx1Hed o5OgwlP7x6zcD9d8khnvfpdF6oad+xRdmY/xv0UFiHr1MIjjz/AeCD7o+za8cfzgdXFO W7Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gdVERoANZ0tlHyrIe2eSl8nR3RSsn9oSS1Ntfv4qMVw=; b=DPw6GmODaoOQx18PY4W460P6ZsZ2urED8YuYJVhmiFurQSSvUmQaLfxzy5RYkoVPSy l38RKICYJh15Ql1xMeDrWQdmN6xaqBC97NSaRgGNd8y2366mdw8fLV6hrAiUTLomV2WO eN0hp22FnQDKKHRIdvv2hjdx+r0uqYIvv/HQuEl+j2IOZ+rOKPRQ5h6nfVGo+uDcDY3/ IVRgljOXVB8CHeNz9olUy+dQYSl8Wv76idpDtuQQYxg19HmFW/e5tFAtJukE1Srnncl6 mrr16xuAI1rhP6+HmIBfl6kNaAhk1e/cpQ6yHm+Q85lcJHLNAiyePhj+M57T0VdWYSZo /jBw== X-Gm-Message-State: AOAM532bWRz39lv2B2s6zdGNb6VN3xOlifH5BXHMZXO5OxqZJaJV0fF0 MCw6SznZmJfUpJKrPuSk9VNXnhH5n1g= X-Google-Smtp-Source: ABdhPJzTZ/a0Ty7NRKLWAP0QVuxEJerVSQHoRnuuZeXYu3kZbGdLpVeyyGWzYP0aMV8MY7alif2bOQ== X-Received: by 2002:a63:460d:: with SMTP id t13mr2800pga.41.1628549385351; Mon, 09 Aug 2021 15:49:45 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id n35sm20826891pfv.152.2021.08.09.15.49.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:49:44 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2 3/5] monitor: Fix not accouting for multiple outstanding packets Date: Mon, 9 Aug 2021 15:49:40 -0700 Message-Id: <20210809224942.225915-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210809224942.225915-1-luiz.dentz@gmail.com> References: <20210809224942.225915-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Analyze code was not accounting for the fact that multiple outstanding packets could be pending which will cause the last_tx to be overwritten but its latency would be calculated against the very first packet complete. --- monitor/analyze.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index d504c8d84..aae153f94 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -62,8 +62,7 @@ struct hci_conn { unsigned long tx_num; unsigned long tx_num_comp; size_t tx_bytes; - struct timeval last_tx; - struct timeval last_tx_comp; + struct queue *tx_queue; struct timeval tx_lat_min; struct timeval tx_lat_max; struct timeval tx_lat_med; @@ -121,6 +120,7 @@ static void conn_destroy(void *data) printf(" %u octets TX max packet size\n", conn->tx_pkt_max); printf(" %u octets TX median packet size\n", conn->tx_pkt_med); + queue_destroy(conn->tx_queue, free); free(conn); } @@ -133,6 +133,7 @@ static struct hci_conn *conn_alloc(struct hci_dev *dev, uint16_t handle, conn->handle = handle; conn->type = type; + conn->tx_queue = queue_new(); return conn; } @@ -372,6 +373,7 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv, uint16_t count = get_le16(data + 2); struct hci_conn *conn; struct timeval res; + struct timeval *last_tx; data += 4; size -= 4; @@ -381,10 +383,10 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv, continue; conn->tx_num_comp += count; - conn->last_tx_comp = *tv; - if (timerisset(&conn->last_tx)) { - timersub(&conn->last_tx_comp, &conn->last_tx, &res); + last_tx = queue_pop_head(conn->tx_queue); + if (last_tx) { + timersub(tv, last_tx, &res); if ((!timerisset(&conn->tx_lat_min) || timercmp(&res, &conn->tx_lat_min, <)) && @@ -414,7 +416,7 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv, } else conn->tx_lat_med = res; - timerclear(&conn->last_tx); + free(last_tx); } } } @@ -489,8 +491,12 @@ static void acl_pkt(struct timeval *tv, uint16_t index, bool out, return; if (out) { + struct timeval *last_tx; + conn->tx_num++; - conn->last_tx = *tv; + 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) From patchwork Mon Aug 9 22:49:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 12427473 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 835D9C432BE for ; Mon, 9 Aug 2021 22:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6547560FC2 for ; Mon, 9 Aug 2021 22:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236855AbhHIWuI (ORCPT ); Mon, 9 Aug 2021 18:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236329AbhHIWuH (ORCPT ); Mon, 9 Aug 2021 18:50:07 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C30DDC0613D3 for ; Mon, 9 Aug 2021 15:49:46 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id z3so18299811plg.8 for ; Mon, 09 Aug 2021 15:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=h5O23deTS/YJXaWeLzUnVmuu6XP6/UdUDz9XhtpcMXY=; b=sYXgHv/rqmWQx8m6P4xEGD9Phu13XhT8NgOf/2BzrZsaJOtRKozGSYDW6jNF0WdAce wj4+lKGSzYRXtVSvaWmEfG7NJo8HLb8TNdwPFES/iFophhZrghvfoWFuI0fSMh+MgyrG reOeRXhXHqH20s4UsEeYOY69rmJ2E1HlBslGsAsMqhlDqWEslc/Z3NVdDIjmNPDpPTvL eX+nPU1L0LnAmNbXmGFJXgLk8DFUIfaoYF8aennAmUF43H9DRohRK9AUHMTN1sfifmuG u3m5WbKwGhNT6gE809PHB5gxTDhraRgNw2xDCovNPuW8bRmjtCCpr8KSse0Pvlmsx6ZM ln9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h5O23deTS/YJXaWeLzUnVmuu6XP6/UdUDz9XhtpcMXY=; b=pN/lNdsWkBp9iywqoY2nbozuu0fYk+m47sKz5uXfPOw0TzdHE8a/3qOzyxfnRVj0nN mWEuodFayopKxOuX/HxhYjT6NgCxZVHgkphrqvEacjsrmbAaiuNqEsKk6wa3hPJI3raY nxkdnqQcfNUzxCm6ECJl5E3kTb5+Z9eqthil80PNlqRA2quAdTGXeAHUUILT73QgPkMK D57SlA9LxykXbvUEb6mZ96A4RIzrt9ydxAZ3e0hBpFQ5bR7QgBqdocsI8j0rAjzdV0oP aqHk5eD9P3h8SDYi9zmzOoHfMkBnktR1AeFDX6N+iM8PQWpDkdW++3i6tCVc2rRamir5 R5Kw== X-Gm-Message-State: AOAM530YmYspFt/DZ98VQPM891vM7wux4mDzpNjoVSy/48b0tHNUSG+G 9RIKYL/pNGyMtdHAn5k4lz0JaCEDmc4= X-Google-Smtp-Source: ABdhPJymKrXYfsWXl9SqPFUVAecIiTDLKOz3BN//k3yf/H3nWbwY8kk99GysBbzAaCJxEFZ1VlELfA== X-Received: by 2002:a17:902:848c:b029:12c:daf3:94f1 with SMTP id c12-20020a170902848cb029012cdaf394f1mr3403168plo.50.1628549386143; Mon, 09 Aug 2021 15:49:46 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id n35sm20826891pfv.152.2021.08.09.15.49.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:49:45 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2 4/5] monitor: Make --analyze output latencies in msec Date: Mon, 9 Aug 2021 15:49:41 -0700 Message-Id: <20210809224942.225915-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210809224942.225915-1-luiz.dentz@gmail.com> References: <20210809224942.225915-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz Milisecconds is probably the best unit to have since it is unlikely that the controller can respond in under 1 msec as well as most time sensitive connection e.g. A2DP, HFP, etc, also don't expect the latencies to be over 1 sec. --- monitor/analyze.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index aae153f94..bee05f467 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -110,12 +110,15 @@ static void conn_destroy(void *data) printf(" %lu RX packets\n", conn->rx_num); printf(" %lu TX packets\n", conn->tx_num); printf(" %lu TX completed packets\n", conn->tx_num_comp); - printf(" %ld.%06ld seconds min latency\n", - conn->tx_lat_min.tv_sec, conn->tx_lat_min.tv_usec); - printf(" %ld.%06ld seconds max latency\n", - conn->tx_lat_max.tv_sec, conn->tx_lat_max.tv_usec); - printf(" %ld.%06ld seconds median latency\n", - conn->tx_lat_med.tv_sec, conn->tx_lat_med.tv_usec); + printf(" %ld msec min latency\n", + conn->tx_lat_min.tv_sec * 1000 + + conn->tx_lat_min.tv_usec / 1000); + printf(" %ld msec max latency\n", + conn->tx_lat_max.tv_sec * 1000 + + conn->tx_lat_max.tv_usec / 1000); + printf(" %ld msec median latency\n", + conn->tx_lat_med.tv_sec * 1000 + + conn->tx_lat_med.tv_usec / 1000); printf(" %u octets TX min packet size\n", conn->tx_pkt_min); printf(" %u octets TX max packet size\n", conn->tx_pkt_max); printf(" %u octets TX median packet size\n", conn->tx_pkt_med); From patchwork Mon Aug 9 22:49:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 12427475 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9462C4338F for ; Mon, 9 Aug 2021 22:49:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCD246101E for ; Mon, 9 Aug 2021 22:49:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236866AbhHIWuJ (ORCPT ); Mon, 9 Aug 2021 18:50:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236861AbhHIWuI (ORCPT ); Mon, 9 Aug 2021 18:50:08 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE6DEC0613D3 for ; Mon, 9 Aug 2021 15:49:47 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id j1so30304174pjv.3 for ; Mon, 09 Aug 2021 15:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=y+RSEjmtvT3+m2SS+ib166a8ULm55XL3JqmWHCKZeOs=; b=vYDxbVpRURACrQR0eOZm/Zm8rL3HbAt7BgBGFxZjxdBj61WWmne8qRRj7vDOpKZZ6N ohLiQaavthb/k34T+6mzGA0GjlrdRYRjyQMVUjRY7iDH+ZjoB2F2heF8VyhSz1WcULVQ 6DX7F8sUVCFstxHmfhqpLJogKv6+bT/+hsfdqf9z1qTpS8cVcLaOuqLLsukWp1GlWp9u ifEmbllDBy2Lp+Ur6Rzk+UV+DV43J9+FHFwzTpS+QqJ2lG30NBgjC0fDlerE/RHbcxLG BH18WVaIsBCamAWkKZfW0EWIb1uXP4Gj8B/YwtdopV8KMWJ1KULpZV3cydCZ73Un7Da/ w11g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y+RSEjmtvT3+m2SS+ib166a8ULm55XL3JqmWHCKZeOs=; b=Dp8iWiHDQH8zRvXWwnlLWGM7iTSzulH6w/peskGj+0lKROSszJjZwlwWPBgHUyETGx da3ZQN/or8RngKmlHAc6pmgVpGNDuyP8TrTAr+Ll3FbfQkj/wSNW5EyuJt6FIRDn5k5z gFI05XIe+pmCDx4iivBFMItlC9I+VQlcrIlIl9EWBgbx71bPvfcldeilioZQmgnnffVp Y9YKmAtpQTyk1zG5GGQeiO/g5wjd6bc8j4Cq+z7e0nEtOOwY16hHmKY5++xRVR72lgGT d70CMuk6p/m4l90maqu8gzNNrlZ38b1pZDaGWaZcmjIPv/o0XklbV6KqrhvG1nax6Rxf 9uJw== X-Gm-Message-State: AOAM533WHi4wvoZtb8hovt/6FuX7ho5ARWUQA9A9CEgsSes+7F0QP4Yl yjB04jRIK832cmjoob+QF5DJ3MF5Veo= X-Google-Smtp-Source: ABdhPJx4D/jrEqkMsQtvwhIekXwdUJinzB7OBG2wbwuJ50vB8a3kf3Hy9VS9BdHgDLpsZIXJhe55Dw== X-Received: by 2002:a65:5ac8:: with SMTP id d8mr444593pgt.34.1628549387037; Mon, 09 Aug 2021 15:49:47 -0700 (PDT) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id n35sm20826891pfv.152.2021.08.09.15.49.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 15:49:46 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2 5/5] monitor: Make --analyze print address OUI Date: Mon, 9 Aug 2021 15:49:42 -0700 Message-Id: <20210809224942.225915-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210809224942.225915-1-luiz.dentz@gmail.com> References: <20210809224942.225915-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This makes analyze.c use packet_print_addr which does take care of decoding OUI portion of the address. --- monitor/analyze.c | 30 ++++++++++++----------- monitor/broadcom.c | 2 +- monitor/intel.c | 10 ++++---- monitor/l2cap.c | 60 +--------------------------------------------- monitor/lmp.c | 2 +- monitor/packet.c | 9 ++++--- monitor/packet.h | 2 +- 7 files changed, 29 insertions(+), 86 deletions(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index bee05f467..4755c6ca6 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -13,6 +13,7 @@ #include #endif +#define _GNU_SOURCE #include #include #include @@ -23,7 +24,9 @@ #include "src/shared/queue.h" #include "src/shared/btsnoop.h" #include "monitor/bt.h" -#include "analyze.h" +#include "monitor/display.h" +#include "monitor/packet.h" +#include "monitor/analyze.h" struct hci_dev { uint16_t index; @@ -102,26 +105,25 @@ static void conn_destroy(void *data) conn->tx_pkt_med = conn->tx_bytes / conn->tx_num; printf(" Found %s connection with handle %u\n", str, conn->handle); - printf(" BD_ADDR %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", - conn->bdaddr[5], conn->bdaddr[4], conn->bdaddr[3], - conn->bdaddr[2], conn->bdaddr[1], conn->bdaddr[0]); + /* TODO: Store address type */ + packet_print_addr("Address", conn->bdaddr, 0x00); if (!conn->setup_seen) - printf(" Connection setup missing\n"); - printf(" %lu RX packets\n", conn->rx_num); - printf(" %lu TX packets\n", conn->tx_num); - printf(" %lu TX completed packets\n", conn->tx_num_comp); - printf(" %ld msec min latency\n", + print_field("Connection setup missing"); + print_field("%lu RX packets", conn->rx_num); + print_field("%lu TX packets", conn->tx_num); + print_field("%lu TX completed packets", conn->tx_num_comp); + print_field("%ld msec min latency", conn->tx_lat_min.tv_sec * 1000 + conn->tx_lat_min.tv_usec / 1000); - printf(" %ld msec max latency\n", + print_field("%ld msec max latency", conn->tx_lat_max.tv_sec * 1000 + conn->tx_lat_max.tv_usec / 1000); - printf(" %ld msec median latency\n", + print_field("%ld msec median latency", conn->tx_lat_med.tv_sec * 1000 + conn->tx_lat_med.tv_usec / 1000); - printf(" %u octets TX min packet size\n", conn->tx_pkt_min); - printf(" %u octets TX max packet size\n", conn->tx_pkt_max); - printf(" %u octets TX median packet size\n", conn->tx_pkt_med); + print_field("%u octets TX min packet size", conn->tx_pkt_min); + print_field("%u octets TX max packet size", conn->tx_pkt_max); + print_field("%u octets TX median packet size", conn->tx_pkt_med); queue_destroy(conn->tx_queue, free); free(conn); diff --git a/monitor/broadcom.c b/monitor/broadcom.c index b144032c3..5ee4ba04a 100644 --- a/monitor/broadcom.c +++ b/monitor/broadcom.c @@ -233,7 +233,7 @@ static void status_rsp(const void *data, uint8_t size) static void write_bd_addr_cmd(const void *data, uint8_t size) { - packet_print_addr("Address", data, false); + packet_print_addr("Address", data, 0x00); } static void update_uart_baud_rate_cmd(const void *data, uint8_t size) diff --git a/monitor/intel.c b/monitor/intel.c index e9984bfe3..728bff587 100644 --- a/monitor/intel.c +++ b/monitor/intel.c @@ -233,7 +233,7 @@ static void print_version_tlv_min_fw(const struct intel_version_tlv *tlv, static void print_version_tlv_otp_bdaddr(const struct intel_version_tlv *tlv, char *type_str) { - packet_print_addr(type_str, tlv->val, false); + packet_print_addr(type_str, tlv->val, 0x00); } static void print_version_tlv_unknown(const struct intel_version_tlv *tlv, @@ -535,7 +535,7 @@ static void write_bd_data_cmd(const void *data, uint8_t size) { uint8_t features[8]; - packet_print_addr("Address", data, false); + packet_print_addr("Address", data, 0x00); packet_hexdump(data + 6, 6); memcpy(features, data + 12, 8); @@ -553,13 +553,13 @@ static void read_bd_data_rsp(const void *data, uint8_t size) uint8_t status = get_u8(data); print_status(status); - packet_print_addr("Address", data + 1, false); + packet_print_addr("Address", data + 1, 0x00); packet_hexdump(data + 7, size - 7); } static void write_bd_address_cmd(const void *data, uint8_t size) { - packet_print_addr("Address", data, false); + packet_print_addr("Address", data, 0x00); } static void act_deact_traces_cmd(const void *data, uint8_t size) @@ -1119,7 +1119,7 @@ static void sco_rejected_via_lmp_evt(const void *data, uint8_t size) { uint8_t reason = get_u8(data + 6); - packet_print_addr("Address", data, false); + packet_print_addr("Address", data, 0x00); packet_print_error("Reason", reason); } diff --git a/monitor/l2cap.c b/monitor/l2cap.c index f16f82532..083e53561 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -2749,63 +2749,6 @@ static void att_packet(uint16_t index, bool in, uint16_t handle, opcode_data->func(&frame); } -static void print_addr(const uint8_t *addr, uint8_t addr_type) -{ - const char *str; - - switch (addr_type) { - case 0x00: - print_field("Address: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", - addr[5], addr[4], addr[3], - addr[2], addr[1], addr[0]); - break; - case 0x01: - switch ((addr[5] & 0xc0) >> 6) { - case 0x00: - str = "Non-Resolvable"; - break; - case 0x01: - str = "Resolvable"; - break; - case 0x03: - str = "Static"; - break; - default: - str = "Reserved"; - break; - } - - print_field("Address: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X" - " (%s)", addr[5], addr[4], addr[3], - addr[2], addr[1], addr[0], str); - break; - default: - print_field("Address: %2.2X-%2.2X-%2.2X-%2.2X-%2.2X-%2.2X", - addr[5], addr[4], addr[3], - addr[2], addr[1], addr[0]); - break; - } -} - -static void print_addr_type(uint8_t addr_type) -{ - const char *str; - - switch (addr_type) { - case 0x00: - str = "Public"; - break; - case 0x01: - str = "Random"; - break; - default: - str = "Reserved"; - break; - } - - print_field("Address type: %s (0x%2.2x)", str, addr_type); -} - static void print_smp_io_capa(uint8_t io_capa) { const char *str; @@ -3038,8 +2981,7 @@ static void smp_ident_addr_info(const struct l2cap_frame *frame) { const struct bt_l2cap_smp_ident_addr_info *pdu = frame->data; - print_addr_type(pdu->addr_type); - print_addr(pdu->addr, pdu->addr_type); + packet_print_addr("Address", pdu->addr, pdu->addr_type); keys_update_identity_addr(pdu->addr, pdu->addr_type); } diff --git a/monitor/lmp.c b/monitor/lmp.c index 0d17f5c98..037adf2e2 100644 --- a/monitor/lmp.c +++ b/monitor/lmp.c @@ -310,7 +310,7 @@ static void slot_offset(const void *data, uint8_t size) const struct bt_lmp_slot_offset *pdu = data; print_field("Offset: %u usec", le16_to_cpu(pdu->offset)); - packet_print_addr("Address", pdu->bdaddr, false); + packet_print_addr("Address", pdu->bdaddr, 0x00); } static void page_scan_mode_req(const void *data, uint8_t size) diff --git a/monitor/packet.c b/monitor/packet.c index 025b7e9b0..9e849acc0 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -713,10 +713,9 @@ static void print_addr_resolve(const char *label, const uint8_t *addr, } } -static void print_addr(const char *label, const uint8_t *addr, - uint8_t addr_type) +static void print_addr(const char *label, const uint8_t *addr, uint8_t type) { - print_addr_resolve(label, addr, addr_type, true); + print_addr_resolve(label, addr, type, true); } static void print_bdaddr(const uint8_t *bdaddr) @@ -3780,9 +3779,9 @@ static void print_eir(const uint8_t *eir, uint8_t eir_len, bool le) packet_hexdump(eir, eir_len - len); } -void packet_print_addr(const char *label, const void *data, bool random) +void packet_print_addr(const char *label, const void *data, uint8_t type) { - print_addr(label ? : "Address", data, random ? 0x01 : 0x00); + print_addr(label ? : "Address", data, type); } void packet_print_handle(uint16_t handle) diff --git a/monitor/packet.h b/monitor/packet.h index f859fa945..34f988e86 100644 --- a/monitor/packet.h +++ b/monitor/packet.h @@ -37,7 +37,7 @@ void packet_print_error(const char *label, uint8_t error); void packet_print_version(const char *label, uint8_t version, const char *sublabel, uint16_t subversion); void packet_print_company(const char *label, uint16_t company); -void packet_print_addr(const char *label, const void *data, bool random); +void packet_print_addr(const char *label, const void *data, uint8_t type); void packet_print_handle(uint16_t handle); void packet_print_rssi(const char *label, int8_t rssi); void packet_print_ad(const void *data, uint8_t size);