Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp16915488rwd; Mon, 26 Jun 2023 17:34:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6md/PLPj/Ji3QZ1iZ1C/Z17UAjC1DssKmdf8RGOKjvXrSxLwLrPzF8pBuiqjM3XeKsNKV3 X-Received: by 2002:a17:902:b214:b0:1ac:750e:33ef with SMTP id t20-20020a170902b21400b001ac750e33efmr5231490plr.3.1687826051358; Mon, 26 Jun 2023 17:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687826051; cv=none; d=google.com; s=arc-20160816; b=oFwxxTYGWJwlKOC2I97a6KH7Vp+Twgj4kYTd/YziurO5Z7P2v8AAksPsPEyc2xespb MwlBwZ3Fnd080Sy2V1vTAC5gcTmZj1Jo4l1hvn0kYD1Slf3vD1vQpJEI18O6MRmEwJ/y oO/IKuv82eeCN7BDdbkJG5qQO1JA/JZnNbUr7oYZ0k1j1pSrj/zDhso9k1xigWnW9+he 1WcWY4CGDMNaxQg9jUeeYTz4+2ddUdYsNRwY3L6qfME6NQf+TdhYWFSFQqvfY3qO0yCU s9vEscI4D7qOL7D5K0OIm7pdIBUAmw93xqoMef2InzDaYly6HZ9wW+3PLqJ/s/6krB7D 3QIw== 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 :message-id:date:subject:to:from:dkim-signature; bh=amEudiRBJEwgOHfrj8/QOr9vZYNBUy0UYt+Ok7aslmU=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=Hu9q9qVae1ZhlyteRECc3BX3CccP0A4zweAr0i9TFpBW924asBC8LVeE4mYPzRz0mg FDcxa6LiPLAQtaFmfxPnHz5gnp81d6MesQZ9IrvjxIno815dcXMjoGWfBKlESi44gvgZ 0Jb9X3fRSmMiAZ7bHtlZR/iFP2qAS9BcmbzgC8rAHzW6dHcJsqyyD4BY1qL+TYkhtRdp tAO75fN3+ildh4pNmdhk8762HNLBjmgeKnlIfBky7qkb9yD79dOqujHi/sYi2kLfXfV8 Pj+hftRGB46A6Eu6As2B9PYo0bhaV+SZt+8OUk9cagI1Vw4ie9VI/iZk6xQkjGMUjGi6 +rgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=T8GVKebN; 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 e3-20020a170902f10300b001b7f9862cdfsi3736155plb.257.2023.06.26.17.33.46; Mon, 26 Jun 2023 17:34:11 -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=T8GVKebN; 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 S229623AbjF0Abs (ORCPT + 99 others); Mon, 26 Jun 2023 20:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbjF0Abr (ORCPT ); Mon, 26 Jun 2023 20:31:47 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C81DD9 for ; Mon, 26 Jun 2023 17:31:46 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-668709767b1so2377330b3a.2 for ; Mon, 26 Jun 2023 17:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687825905; x=1690417905; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=amEudiRBJEwgOHfrj8/QOr9vZYNBUy0UYt+Ok7aslmU=; b=T8GVKebN9PwOruFIKCIZSoTV+ARXw9Zi3sE4/75IGoKj9KOoY95u4CK9EssqcZnp0I oiUE9bjND7pWZNsNE5MIx5BpxnZB3aVAqdEiELnNAopTb/STm5kdfoKRiH90Catnq2As Mwb7ZBobsv+4kfaIIHAO4RUINcD8qzlYZnB6sMcQ5ctF0tqyUj2slUXxzb2IxAszxXGm VRyLPaGa0j3lTXbnyYwdOVm6/qjQY33RsTabc0EcR1tYl7yGGRIdRgIeR6A+JQ7UFoup AaWmRADLCK0NvsbbPiTXBET24zrh9rRvU1tWJEnHnmY/nZQL+WARX7x9lf1iDYWQIyZU T5iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687825905; x=1690417905; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=amEudiRBJEwgOHfrj8/QOr9vZYNBUy0UYt+Ok7aslmU=; b=BpkYizklCUEyIXSeNe64Rh0ixrEZzz3xZkBXe7icRn5XvphvPAHY7m5PUAbP9LEuPT JyJLZTGeeylC/dp6f42voKxfj58BQQH2dY9EPu/7ToJf5lmpa8r/crW7cKX0L/2VqcgW w5x8Gsl3Zy5hxa5m0sg3bbByJ7qpWo5o5wtP8GAHXdVL71JTU5nAa0eE4qyUIFKaOaqa CNO+GRepsmNCRRvDamgYgYt1MDTBSux6EbrYr/3kd5fUe6uonZrJxw79/J2KeY8EDfXW JUQ7+OiL6LLL2RDW+5EegjbJHlSQuE3mV0LCiHn9xdM3o1wPm4LzFUeDb7S7aNI/5n24 g0ng== X-Gm-Message-State: AC+VfDxM06avMwISAHRB0HzPE5UNEvajZTpmqpb/McA13A3ipP8YkEu6 Q2mzTLKFdUDzx8nNInSqk+E42VnboEVSs0Ub X-Received: by 2002:a05:6a21:7881:b0:121:ef3f:ed0b with SMTP id bf1-20020a056a21788100b00121ef3fed0bmr20892915pzc.60.1687825905015; Mon, 26 Jun 2023 17:31:45 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id y7-20020a17090322c700b001b3a21fbb4fsm4750582plg.12.2023.06.26.17.31.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 17:31:44 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v5] Bluetooth: hci_event: Fix parsing of CIS Established Event Date: Mon, 26 Jun 2023 17:31:42 -0700 Message-Id: <20230627003142.2274828-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 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 The ISO Interval on CIS Established Event uses 1.25 ms slots: BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 2304: Time = N * 1.25 ms In addition to that this always update the QoS settings based on CIS Established Event. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_event.c | 45 ++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index b1aefe4bb751..77cbf13037b3 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 = data; struct hci_conn *conn; + struct bt_iso_qos *qos; bool pending = false; u16 handle = __le16_to_cpu(ev->handle); @@ -6846,21 +6847,39 @@ static void hci_le_cis_estabilished_evt(struct hci_dev *hdev, void *data, pending = test_and_clear_bit(HCI_CONN_CREATE_CIS, &conn->flags); - if (conn->role == HCI_ROLE_SLAVE) { - __le32 interval; + qos = &conn->iso_qos; - memset(&interval, 0, sizeof(interval)); + /* Convert ISO Interval (1.25 ms slots) to SDU Interval (us) */ + qos->ucast.in.interval = le16_to_cpu(ev->interval) * 1250; + qos->ucast.out.interval = qos->ucast.in.interval; - memcpy(&interval, ev->c_latency, sizeof(ev->c_latency)); - conn->iso_qos.ucast.in.interval = le32_to_cpu(interval); - memcpy(&interval, ev->p_latency, sizeof(ev->p_latency)); - conn->iso_qos.ucast.out.interval = le32_to_cpu(interval); - conn->iso_qos.ucast.in.latency = le16_to_cpu(ev->interval); - conn->iso_qos.ucast.out.latency = le16_to_cpu(ev->interval); - conn->iso_qos.ucast.in.sdu = le16_to_cpu(ev->c_mtu); - conn->iso_qos.ucast.out.sdu = le16_to_cpu(ev->p_mtu); - conn->iso_qos.ucast.in.phy = ev->c_phy; - conn->iso_qos.ucast.out.phy = ev->p_phy; + switch (conn->role) { + case HCI_ROLE_SLAVE: + /* Convert Transport Latency (us) to Latency (msec) */ + qos->ucast.in.latency = + DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), + 1000); + qos->ucast.out.latency = + DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), + 1000); + qos->ucast.in.sdu = le16_to_cpu(ev->c_mtu); + qos->ucast.out.sdu = le16_to_cpu(ev->p_mtu); + qos->ucast.in.phy = ev->c_phy; + qos->ucast.out.phy = ev->p_phy; + break; + case HCI_ROLE_MASTER: + /* Convert Transport Latency (us) to Latency (msec) */ + qos->ucast.out.latency = + DIV_ROUND_CLOSEST(get_unaligned_le24(ev->c_latency), + 1000); + qos->ucast.in.latency = + DIV_ROUND_CLOSEST(get_unaligned_le24(ev->p_latency), + 1000); + qos->ucast.out.sdu = le16_to_cpu(ev->c_mtu); + qos->ucast.in.sdu = le16_to_cpu(ev->p_mtu); + qos->ucast.out.phy = ev->c_phy; + qos->ucast.in.phy = ev->p_phy; + break; } if (!ev->status) { -- 2.40.1