Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9909773rwd; Wed, 21 Jun 2023 13:33:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6EntB9zZzG/kxMqaiH8dRAvKGGLW0CFjIqPmb5nXgi4CITP71Z1WJ3V8RnMMrWrmNApY0w X-Received: by 2002:a17:902:d489:b0:1b0:3a03:50d0 with SMTP id c9-20020a170902d48900b001b03a0350d0mr20282170plg.26.1687379636436; Wed, 21 Jun 2023 13:33:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687379636; cv=pass; d=google.com; s=arc-20160816; b=SqX9L2j1GJJSHypJ29mrMB8yKqCN5MT6TxvNvfTpt94dcP6P7PMdWel5V+rLeykJxU M/MAxWRfO50eUN14AloMCuckmMO2NU7P+cqH3VFhEygW2LwEXwriDM88h0ZJmMaRi4+a sX9A005d8c3HnrV/AZ72x+CXreMq4adSFRfpM8GrbSJvYy/xokfQWDXwpga04c6Zdzsh YWJKwmZVZYCDrogBsY7hfDPjwsfbAbIhdrwGcSSs4iUiR+S+P8uFKSt8buDK40HwvGOy g099KicyRYaK/rhaaG5YgaYr/qz9/UUa49BCSmUyXIcrUFPCXdOLtne41a3acdmvlPr0 MyJA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id:dkim-signature; bh=uXeEVG+xQhvVQ6S2htfYFX/cZ92tXBntMV9plGcFKQw=; b=YCG1LAu1Ib7dS/4k0YLdYog/BjFQLYo1A7pTt5ExsHtYmH1gu52RqX6sYcq1seRj22 q4CAIxEX93yV39zN4n+z+vpc2mFa6QjrgCIcB1eBxi5WPWOILQXAtqvFB95xuFJ54dXz 9nQ+8fY5s/0JDvYTLYgvsRVB01wA7izC1mXSkgOYClrKnR5slenYnKtWqm94Jo0CGhoT 1+JnB6s/Hl8/nSNirdUOooy8RqCp+GQWXnIDSovwq8CW5HgyfIM52SJyxKLvozZGy/lM sY+Y9BOIIaotAuntosY1RM0yiOQKWllKjAmS5dy1oA+QEke7BIJEU2dfoU+KoP7jAZJt kkmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b="uWuPW+z/"; arc=pass (i=1); 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a170902d50a00b001ac5896c746si1675977plg.329.2023.06.21.13.33.39; Wed, 21 Jun 2023 13:33:56 -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=@iki.fi header.s=meesny header.b="uWuPW+z/"; arc=pass (i=1); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229504AbjFUUdV (ORCPT + 99 others); Wed, 21 Jun 2023 16:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjFUUdU (ORCPT ); Wed, 21 Jun 2023 16:33:20 -0400 Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E21519A3 for ; Wed, 21 Jun 2023 13:33:16 -0700 (PDT) Received: from [192.168.1.195] (91-152-120-101.elisa-laajakaista.fi [91.152.120.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav@iki.fi) by meesny.iki.fi (Postfix) with ESMTPSA id 4QmZvS4h8QzyYc; Wed, 21 Jun 2023 23:33:08 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1687379588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uXeEVG+xQhvVQ6S2htfYFX/cZ92tXBntMV9plGcFKQw=; b=uWuPW+z/SolElG401hO7m1ym81YOEqBWdFKyscBv4gAG8s4AF34FcIqiVlR4IICR2B4/LG ckcsfZu9qNSGbBRtNZEqxndP0I/y+IyNSRIRS/PyKo0rtZkmLHem2c4MMc80lFgEJdSRoD 2prY5DcPzUYOZfb5qid49JOy/WjrZ60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1687379588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uXeEVG+xQhvVQ6S2htfYFX/cZ92tXBntMV9plGcFKQw=; b=p4oCbEpqKiV557QKkExgP9JEls7LXHIc1DtVLjiBli4drm+MzydYkIPPaBpRxRCc8Ox60d tuweSAwwOk/KJUY/dsRBJ8kr9CJuy26UEUqS3kUvxj2T0rw/rWa835sQue7/607hsE5pR9 nTiKWEge+7jgECI45ndroWyjdf1Sq1k= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav@iki.fi smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1687379588; a=rsa-sha256; cv=none; b=JNIlgVO8K/xZTWLAzMfme5DGJ6z25hm6RVhVURHuJ59Sso39rjYF/tqKjtp/ujXh70Qr4c +O++ELPvfu1I0CWZC47cVYN8zS6gv3czwhQqEeJhdRub/p3SJ464u+MN4P9GDZw48dr5Zj HBZMgnHUEk+rPj5XDAC/CDXDY3yvcSc= Message-ID: <66add9bf780aca773d41cce3ea42589388de2543.camel@iki.fi> Subject: Re: [PATCH v2] Bluetooth: hci_event: Fix parsing of CIS Established Event From: Pauli Virtanen To: Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org Date: Wed, 21 Jun 2023 23:33:08 +0300 In-Reply-To: <20230621195407.977001-1-luiz.dentz@gmail.com> References: <20230621195407.977001-1-luiz.dentz@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.3 (3.48.3-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=no 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 Hi Luiz, ke, 2023-06-21 kello 12:54 -0700, Luiz Augusto von Dentz kirjoitti: > From: Luiz Augusto von Dentz >=20 > The ISO Interval on CIS Established Event uses 1.25 ms slots: >=20 > BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E > page 2304: >=20 > Time =3D N * 1.25 ms >=20 > In addition to that this always update the QoS settings based on CIS > Established Event. >=20 > Signed-off-by: Luiz Augusto von Dentz > --- > net/bluetooth/hci_event.c | 36 +++++++++++++++++++++++------------- > 1 file changed, 23 insertions(+), 13 deletions(-) >=20 > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c > index b1aefe4bb751..6fca6d9f1b34 100644 > --- a/net/bluetooth/hci_event.c > +++ b/net/bluetooth/hci_event.c > @@ -6822,6 +6822,7 @@ static void hci_le_cis_estabilished_evt(struct hci_= dev *hdev, void *data, > { > struct hci_evt_le_cis_established *ev =3D data; > struct hci_conn *conn; > + struct bt_iso_qos *qos; > bool pending =3D false; > u16 handle =3D __le16_to_cpu(ev->handle); > =20 > @@ -6846,21 +6847,30 @@ static void hci_le_cis_estabilished_evt(struct hc= i_dev *hdev, void *data, > =20 > pending =3D test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); > =20 > - if (conn->role =3D=3D HCI_ROLE_SLAVE) { > - __le32 interval; > + qos =3D &conn->iso_qos; > =20 > - memset(&interval, 0, sizeof(interval)); > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > + qos->ucast.in.latency =3D le16_to_cpu(ev->interval) * 125 / 100; > + /* Convert ISO Interval (1.25 ms slots) to latency (ms) */ > + qos->ucast.out.latency =3D le16_to_cpu(ev->interval) * 125 / 100; > =20 > - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); > - conn->iso_qos.ucast.in.interval =3D le32_to_cpu(interval); > - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); > - conn->iso_qos.ucast.out.interval =3D le32_to_cpu(interval); > - conn->iso_qos.ucast.in.latency =3D le16_to_cpu(ev->interval); > - conn->iso_qos.ucast.out.latency =3D le16_to_cpu(ev->interval); > - conn->iso_qos.ucast.in.sdu =3D le16_to_cpu(ev->c_mtu); > - conn->iso_qos.ucast.out.sdu =3D le16_to_cpu(ev->p_mtu); > - conn->iso_qos.ucast.in.phy =3D ev->c_phy; > - conn->iso_qos.ucast.out.phy =3D ev->p_phy; > + switch (conn->role) { > + case HCI_ROLE_SLAVE: > + qos->ucast.in.interval =3D get_unaligned_le24(ev->c_latency); > + qos->ucast.out.interval =3D get_unaligned_le24(ev->p_latency); > + qos->ucast.in.sdu =3D le16_to_cpu(ev->c_mtu); > + qos->ucast.out.sdu =3D le16_to_cpu(ev->p_mtu); > + qos->ucast.in.phy =3D ev->c_phy; > + qos->ucast.out.phy =3D ev->p_phy; > + break; Are the ucast.latency and ucast.interval the right way around here? When I trying to use this in userspace, I expected ucast.interval contains the ISO interval, because in Set CIG Parameters we use ucast.interval to specify the SDU_Interval, and ucast.latency is used for the Transport_Latency_C_To_P and Transport_Latency_P_To_C. With real numbers the event (AX210<->AX210) looks like this > HCI Event: LE Meta Event (0x3e) plen 29 #3493 [hci0] 486.97= 8955 LE Connected Isochronous Stream Established (0x19) Status: Success (0x00) Connection Handle: 2560 CIG Synchronization Delay: 4020 us (0x000fb4) CIS Synchronization Delay: 4020 us (0x000fb4) Central to Peripheral Latency: 94020 us (0x016f44) Peripheral to Central Latency: 94020 us (0x016f44) Central to Peripheral PHY: LE 2M (0x02) Peripheral to Central PHY: LE 2M (0x02) Number of Subevents: 2 Central to Peripheral Burst Number: 1 Peripheral to Central Burst Number: 1 Central to Peripheral Flush Timeout: 10 Peripheral to Central Flush Timeout: 10 Central to Peripheral MTU: 240 Peripheral to Central MTU: 120 ISO Interval: 8 > + case HCI_ROLE_MASTER: > + qos->ucast.out.interval =3D get_unaligned_le24(ev->c_latency); > + qos->ucast.in.interval =3D get_unaligned_le24(ev->p_latency); > + qos->ucast.out.sdu =3D le16_to_cpu(ev->c_mtu); > + qos->ucast.in.sdu =3D le16_to_cpu(ev->p_mtu); > + qos->ucast.out.phy =3D ev->c_phy; > + qos->ucast.in.phy =3D ev->p_phy; > + break; > } > =20 > if (!ev->status) { --=20 Pauli Virtanen