Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp264589rwo; Tue, 1 Aug 2023 16:52:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlGGCtqirC2Y1c++rF2SB4T0Y0zhjW3nrt9Wj0VV++stP2pNB6p1UB5hV90LjwlRUEkRz11D X-Received: by 2002:a2e:a169:0:b0:2b6:ddab:506a with SMTP id u9-20020a2ea169000000b002b6ddab506amr3668143ljl.34.1690933977565; Tue, 01 Aug 2023 16:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690933977; cv=none; d=google.com; s=arc-20160816; b=G9I7SQNhKs9FRzGPt259cmD4JkhGYtsytCpGdS2L5De9sZK9inDiADOogDNJ970fNo lCfdrOFCdhk9la0fx9mQ5j6m+Y0Pa6b09jA6HwVsZi7wdpl760XvMHWmEZYUHVugXsGt OwDVAEqV8ZFdyBETYNsC3pkgt0AgiUgDVm5tg+x5ZBGPXWpYpN1ehl8yoZj4uBAUDTS6 P1UaCDD4hJRpWz3jwzmlc+4r3i2HbScFLFqgREuVBZSgMvBtEsLfy+GgxVB4hs8grAKO vI7vhlZ4Xwb/U/WH3x+lGdpAxekd2TnSm6mcqWxJLXYPaw9m6sJ2UKk2Qf/VtqOlnv3+ YDHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=FVMcQ/mN4qzoaXflcSf8aSfstIOnnWhVxxJ+tu9PHtI=; fh=V2LL5OuZUBGeSu6TXDWykcThOoazTGUpkln19rrO2KM=; b=zsl/tXlWQ4kelMQmX3fCVETdcRWvQX5ARx191rl7nF+PkrMQeFxEP6xbNf2quGuJnZ zn9VWTF2qbNbDTq+YYJi3vmBRrNV72jRBAUX3zMWeznhXXvUvMJAqovTIZheaiykj1p2 qQtzf1ysQiRM59IjzlOA6E59ZJCWTqXJY0RC+OX0pHxDoX8vNAIngj2S4ESxPCeKtaqf p1PKSIovUgMCthD8DIyn1VKURLB4DGsBZsKK0cx1IinM6cV4Bmd3K7oWYsBbhLZ6/EOe poa+jOhf38oNA/OXQVO7ZoNy68gJLp8tQEunfhETgs4IQHaUMssIojQwFN9/MfS8bo8w lCmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Ivie46mR; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020aa7dad1000000b005218cf5ed80si2915005eds.439.2023.08.01.16.52.34; Tue, 01 Aug 2023 16:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Ivie46mR; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbjHAXcC (ORCPT + 99 others); Tue, 1 Aug 2023 19:32:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbjHAXbv (ORCPT ); Tue, 1 Aug 2023 19:31:51 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF87268E for ; Tue, 1 Aug 2023 16:31:44 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-790ca0ed6d3so31921239f.3 for ; Tue, 01 Aug 2023 16:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690932703; x=1691537503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FVMcQ/mN4qzoaXflcSf8aSfstIOnnWhVxxJ+tu9PHtI=; b=Ivie46mRW9uSTezbQ8QV5LZ2qxLXoONT1Ypjj606L4Yz9VpEvA9C48iCcQiZQgJeNg Lh601km2DrO4993f7Ymtx7Gutlme4Brjbjb42pjHIwHY3fc07cdqfK3XOdFzHtCxYWq9 S01nab6kEv1LaTggO2wWl5lPQTe2sppHBG7Aqhfc7UE9SKz49jNHOcuQ0BOWzZyIyzTj FDzyop87QDIMVfuDaSDDS7u1T6cpQDxyvVkZkpeq3LnbVwqZlnME0IO+l8BrEyHtta10 pe7w4g+7NlVsfahktn4eyJ63U2Km5Ad8Lry074roFuQ7MIB8cIL0blrgxlLTfGvBIMmU XYfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690932703; x=1691537503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FVMcQ/mN4qzoaXflcSf8aSfstIOnnWhVxxJ+tu9PHtI=; b=Kw7aEs3YY0GvysVkQAnVttEUP6pdNGCN6ZkcRNk4oKf8cRO3z/owKMCWo/GaUeFanj lWbAzVFR+mE1MxpLBVm6ITPYyNs9zH8jCXkt2QRpsYE2sNX9LEzqzaXuozHKFFrPKM99 8VtpGCjYzCThZteOBifxTQ3xXQlcu/+Z5a38S7SoNnsUM7R5ktlqxNbjCSO2WetB6qJh eOqFwcxO9ft777KnPZ8y1UQx7afV73zwb1wXztb0i5+JPbyk7GJW564cFMUjafhMJZ4r Y5h5n6kpBK3Vur8Q96YJYdPzBGfsjq76xme39dMPnrEVliuq6IoXUeLQ8j/mVRMqYCx1 BHcA== X-Gm-Message-State: ABy/qLZmKFT6yUXrOJ/4y+WhRfjRO2qoo5e1bm3W4SuAgvO8xCVFxJ7N X1eRSckKRMKSb+WmgN0rJAmE+IwFKVs= X-Received: by 2002:a6b:4a14:0:b0:783:4e11:76d7 with SMTP id w20-20020a6b4a14000000b007834e1176d7mr11245553iob.21.1690932703004; Tue, 01 Aug 2023 16:31:43 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-236-201-58.hsd1.or.comcast.net. [71.236.201.58]) by smtp.gmail.com with ESMTPSA id d20-20020a5d9bd4000000b00790af7745b1sm1286269ion.20.2023.08.01.16.31.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 16:31:41 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v3 4/5] monitor: Add connection tracking for SCO/ISO with -a/--analyze Date: Tue, 1 Aug 2023 16:31:34 -0700 Message-ID: <20230801233135.537864-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230801233135.537864-1-luiz.dentz@gmail.com> References: <20230801233135.537864-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds proper connection tracking to SCO/ISO connection by handling the events that establishes them. --- monitor/analyze.c | 108 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/monitor/analyze.c b/monitor/analyze.c index 89b0382825dc..d0ad70d5dc74 100644 --- a/monitor/analyze.c +++ b/monitor/analyze.c @@ -253,7 +253,9 @@ static void conn_destroy(void *data) TV_MSEC(conn->tx_l.med)); print_field("%u-%u octets (~%u octets) TX packet size", conn->tx_pkt_min, conn->tx_pkt_max, conn->tx_pkt_med); - print_field("~%lld Kb/s TX transfer speed", + + if (TV_MSEC(conn->tx_l.total)) + print_field("~%lld Kb/s TX transfer speed", conn->tx_bytes * 8 / TV_MSEC(conn->tx_l.total)); plot_draw(conn->plot); @@ -595,9 +597,110 @@ static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv, } } +static void evt_sync_conn_complete(struct hci_dev *dev, struct timeval *tv, + const void *data, uint16_t size) +{ + const struct bt_hci_evt_sync_conn_complete *evt = data; + struct hci_conn *conn; + + if (evt->status) + return; + + conn = conn_lookup_type(dev, le16_to_cpu(evt->handle), evt->link_type); + if (!conn) + return; + + memcpy(conn->bdaddr, evt->bdaddr, 6); + conn->setup_seen = true; +} + +static void evt_le_cis_established(struct hci_dev *dev, struct timeval *tv, + struct iovec *iov) +{ + const struct bt_hci_evt_le_cis_established *evt; + struct hci_conn *conn; + + evt = util_iov_pull_mem(iov, sizeof(*evt)); + if (!evt || evt->status) + return; + + conn = conn_lookup_type(dev, le16_to_cpu(evt->conn_handle), + CONN_LE_ISO); + if (!conn) + return; + + conn->setup_seen = true; +} + +static void evt_le_big_complete(struct hci_dev *dev, struct timeval *tv, + struct iovec *iov) +{ + const struct bt_hci_evt_le_big_complete *evt; + int i; + + evt = util_iov_pull_mem(iov, sizeof(*evt)); + if (!evt || evt->status) + return; + + for (i = 0; i < evt->num_bis; i++) { + struct hci_conn *conn; + uint16_t handle; + + if (!util_iov_pull_le16(iov, &handle)) + return; + + conn = conn_lookup_type(dev, handle, CONN_LE_ISO); + if (conn) + conn->setup_seen = true; + } +} + +static void evt_le_big_sync_established(struct hci_dev *dev, struct timeval *tv, + struct iovec *iov) +{ + const struct bt_hci_evt_le_big_sync_estabilished *evt; + int i; + + evt = util_iov_pull_mem(iov, sizeof(*evt)); + if (!evt || evt->status) + return; + + for (i = 0; i < evt->num_bis; i++) { + struct hci_conn *conn; + uint16_t handle; + + if (!util_iov_pull_le16(iov, &handle)) + return; + + conn = conn_lookup_type(dev, handle, CONN_LE_ISO); + if (conn) + conn->setup_seen = true; + } +} + static void evt_le_meta_event(struct hci_dev *dev, struct timeval *tv, const void *data, uint16_t size) { + struct iovec iov = { + .iov_base = (void *)data, + .iov_len = size, + }; + uint8_t subevt; + + if (!util_iov_pull_u8(&iov, &subevt)) + return; + + switch (subevt) { + case BT_HCI_EVT_LE_CIS_ESTABLISHED: + evt_le_cis_established(dev, tv, &iov); + break; + case BT_HCI_EVT_LE_BIG_COMPLETE: + evt_le_big_complete(dev, tv, &iov); + break; + case BT_HCI_EVT_LE_BIG_SYNC_ESTABILISHED: + evt_le_big_sync_established(dev, tv, &iov); + break; + } } static void event_pkt(struct timeval *tv, uint16_t index, @@ -629,6 +732,9 @@ static void event_pkt(struct timeval *tv, uint16_t index, case BT_HCI_EVT_NUM_COMPLETED_PACKETS: evt_num_completed_packets(dev, tv, data, size); break; + case BT_HCI_EVT_SYNC_CONN_COMPLETE: + evt_sync_conn_complete(dev, tv, data, size); + break; case BT_HCI_EVT_LE_META_EVENT: evt_le_meta_event(dev, tv, data, size); break; -- 2.41.0