Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1985912rbb; Tue, 27 Feb 2024 07:19:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUqRj3xp+zqVcf8uulAdcF0hRHOqdTrPkD54OR4EimO+R7f96E0vvaGkuPfazy1E51upU3KWKEHOctlQir0lMZSPTcMPcgRo5iyjXN5uA== X-Google-Smtp-Source: AGHT+IEhtam0bVmYEa99ElpWDWddOBOPgLJXEpCt/lN4eoNMPM4H5cuo3epDzwCi/XifJ1mNVcbi X-Received: by 2002:a17:90a:2f41:b0:29a:5ed9:ec97 with SMTP id s59-20020a17090a2f4100b0029a5ed9ec97mr8577398pjd.32.1709047154310; Tue, 27 Feb 2024 07:19:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709047154; cv=pass; d=google.com; s=arc-20160816; b=ks3Jin7PTaKQTcgzHcte4YKSShqkCA9lYXWuvG4hR/t+xO9X3TF+lLwVW81hXmoSue Cqtgoo8vRHmzwoh6Z8piEND7itLnWSlx1ghoxJBAB1RabHSIAUfyW33M1CQSIOzukx56 RPe5RwRt+gHh6s13OEm+H1Mujo3vd1PCv0cb1+RTtOXZf9CJ3FeTYyoUinmVzvRJAhAj fH4vF2xB/zeDeHWZHVsPOIAphoU1MVDzyn9qofmtljG+LRFGpoNzzc0ZWfdqVmjB3DVC Eqm9uX6wL5AXlnX9cSF1mAqvRsvpaWy3dhFs/T/B7/yRPM2/ihqLqYPhiq7X2jrQh08Z rmHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=bXvzMmiAQBkYjtoM4i7MxrToF6Q1C4jv7wnZl9wJ/YM=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=HeFM2w207mwoKe0cTbs29pHOplu94O/75fhMPtWknlIEFx/tgNTHjvmxX+0CRen6/q Mk7vacwPWK/lhb0NdPvLA3g9nlw/B6pbYFcUpoRmUwBhhw1fL5x5OFyFc57h1magDYE7 QMcmux7cNesdpOrafe+rWvpCgsHCD3pr5dS8ORKSsXS5CKXDT/IPMo/QhSd8g3q0mSvS 0mOhkIyMQ/nKpURFxRRwVTkU16RvDPbT63dIjWhyUrfmHm29hCrISIHMoJ2vPGepjhmd lNMuxnNaPU1MzRFdIQo3FKmYoxRBknTd3+6/p5B13WrVLddHKUdqzVjVfy4xgOe4Ns+9 QHkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HZ7301Dk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id nl17-20020a17090b385100b0029acb8396e9si3135124pjb.9.2024.02.27.07.19.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-2169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HZ7301Dk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-2169-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-2169-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 97E81285774 for ; Tue, 27 Feb 2024 15:15:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EDB1420DD; Tue, 27 Feb 2024 15:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HZ7301Dk" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EB671420B3 for ; Tue, 27 Feb 2024 15:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709046944; cv=none; b=q2iYZg1u/eq3JVZv2HTOXOJt4a2tW5sQ1O1X7AjNmk0m/aOPrtkY9GCqUhzc+SxrKUcV4LvVrBEuuFKotoSoa0gpqpLPPjJar2Lg5VaU3+irtKZ+JCEa2oLyhbuUae7W+y2SauKuK66FFJD6vZHP7QvuKVrwtWf2bzejw/3Pvqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709046944; c=relaxed/simple; bh=eSFD0jMX9QX3F36TXKIE36SpBbtzb+/+q2DtOdKZDt4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X2AyIgYYX+tbajcIQDd+PyOgFoArb3DrDT1SJCrQzkIA6lVH/MkySwL/E/ukn4FBaKBzGT+rGnsOM9x/7QvHsyyPrSIiFjqUfKW+GNNeVezs7mHZ56awUsR01dhsZ3B8WcCq2OVeZ516IAI0GZfJySS7bbZHM1ylv/CKUnGa/nY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HZ7301Dk; arc=none smtp.client-ip=209.85.128.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-607f8894550so31457357b3.1 for ; Tue, 27 Feb 2024 07:15:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709046942; x=1709651742; darn=vger.kernel.org; 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=bXvzMmiAQBkYjtoM4i7MxrToF6Q1C4jv7wnZl9wJ/YM=; b=HZ7301Dk/Dhdi+ftdMLjVCXYrEiHp9EZGKKx9MSxKedbtbEKMsBomth/NjrFSAvYkr 45Mg3YZk2UE4S0LBawqRnyPetfbhpvW5TAw/pn/F9WcYOhmcIzKZyWH4OoLXRVhqGcS8 UgBozU3LyOGPTd/LepeQZSJGMo3uW1WqACjyfMQ0fjw0U1mDZS6lJ9hiBPNUPz0zrjCk wV5xiQpemf/klcZVK1vo/WjpiQSGHPOMTnNWiB+A1whNa5xVRJwlUs2+5pzV3kEU0v5o dSm5+OLGQ/PXrEpftZbAe9AEKLK/HrV5+V1sD8ac4kqntlH2pRCsrEoPQYYJW/j1QVlb A8xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709046942; x=1709651742; 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=bXvzMmiAQBkYjtoM4i7MxrToF6Q1C4jv7wnZl9wJ/YM=; b=JERZDKySvFtbkXv86i2G1nU7TuGV944qhop18SWhjQoesvLOE7CC7Lo79rKyElKMG/ mTXU9qQjKVbz9YHsBfatLP4k//hc6Zn2pPU1EbOq0OALWmJGej4NgOHMZoqM3cz6wMJY jGPC9oEaydHCgZBcS3w57N4SAVLZ+bdRtB8jXAQpw58nVDWTK2gQSp+twytLHebpKrzO 5BfyH78msMb/3MP4lA22MFAAIiTJayWtTHeNzDpP3mFzczX9pcJlrdfgZdRgK55fhQNw jvESJFJffbIlMAwM/RJ5NBhy7HhgWcCCHP2a6/gV8N+GtMOIxTlTQDUsjWPs3uemO2E5 TezA== X-Gm-Message-State: AOJu0YxZQcnloTXCKtKoDfaw+v14qoIgjv2rVHe+QvueK/5SzZowoiEh 1AkM+kIZ+PGADg6lFgM/aKlHL/S2mW0sqGzjKh2urtYx7DF3UUZHLcwlqrVO X-Received: by 2002:a81:8352:0:b0:608:b64a:1517 with SMTP id t79-20020a818352000000b00608b64a1517mr2345623ywf.19.1709046941628; Tue, 27 Feb 2024 07:15:41 -0800 (PST) Received: from lvondent-mobl4.. (071-047-239-151.res.spectrum.com. [71.47.239.151]) by smtp.gmail.com with ESMTPSA id h28-20020a05612201dc00b004d335f1bdb7sm32726vko.37.2024.02.27.07.15.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 07:15:39 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v5 2/2] Bluetooth: hci_sync: Use QoS to determine which PHY to scan Date: Tue, 27 Feb 2024 10:15:37 -0500 Message-ID: <20240227151537.1884044-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227151537.1884044-1-luiz.dentz@gmail.com> References: <20240227151537.1884044-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz This used the hci_conn QoS to determine which PHY to scan when creating a PA Sync. Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_sync.c | 66 +++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index ab609089ac4c..6e16ebde854d 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -2758,6 +2758,14 @@ static u8 hci_update_accept_list_sync(struct hci_dev *hdev) return filter_policy; } +static void hci_le_scan_phy_params(struct hci_cp_le_scan_phy_params *cp, + u8 type, u16 interval, u16 window) +{ + cp->type = type; + cp->interval = cpu_to_le16(interval); + cp->window = cpu_to_le16(window); +} + static int hci_le_set_ext_scan_param_sync(struct hci_dev *hdev, u8 type, u16 interval, u16 window, u8 own_addr_type, u8 filter_policy) @@ -2765,7 +2773,7 @@ static int hci_le_set_ext_scan_param_sync(struct hci_dev *hdev, u8 type, struct hci_cp_le_set_ext_scan_params *cp; struct hci_cp_le_scan_phy_params *phy; u8 data[sizeof(*cp) + sizeof(*phy) * 2]; - u8 num_phy = 0; + u8 num_phy = 0x00; cp = (void *)data; phy = (void *)cp->data; @@ -2775,28 +2783,64 @@ static int hci_le_set_ext_scan_param_sync(struct hci_dev *hdev, u8 type, cp->own_addr_type = own_addr_type; cp->filter_policy = filter_policy; + /* Check if PA Sync is in progress then select the PHY based on the + * hci_conn.iso_qos. + */ + if (hci_dev_test_flag(hdev, HCI_PA_SYNC)) { + struct hci_cp_le_add_to_accept_list *sent; + + sent = hci_sent_cmd_data(hdev, HCI_OP_LE_ADD_TO_ACCEPT_LIST); + if (sent) { + struct hci_conn *conn; + + conn = hci_conn_hash_lookup_ba(hdev, ISO_LINK, + &sent->bdaddr); + if (conn) { + struct bt_iso_qos *qos = &conn->iso_qos; + + if (qos->bcast.in.phy & BT_ISO_PHY_1M || + qos->bcast.in.phy & BT_ISO_PHY_2M) { + cp->scanning_phys |= LE_SCAN_PHY_1M; + hci_le_scan_phy_params(phy, type, + interval, + window); + num_phy++; + phy++; + } + + if (qos->bcast.in.phy & BT_ISO_PHY_CODED) { + cp->scanning_phys |= LE_SCAN_PHY_CODED; + hci_le_scan_phy_params(phy, type, + interval, + window); + num_phy++; + phy++; + } + + if (num_phy) + goto done; + } + } + } + if (scan_1m(hdev) || scan_2m(hdev)) { cp->scanning_phys |= LE_SCAN_PHY_1M; - - phy->type = type; - phy->interval = cpu_to_le16(interval); - phy->window = cpu_to_le16(window); - + hci_le_scan_phy_params(phy, type, interval, window); num_phy++; phy++; } if (scan_coded(hdev)) { cp->scanning_phys |= LE_SCAN_PHY_CODED; - - phy->type = type; - phy->interval = cpu_to_le16(interval); - phy->window = cpu_to_le16(window); - + hci_le_scan_phy_params(phy, type, interval, window); num_phy++; phy++; } +done: + if (!num_phy) + return -EINVAL; + return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_EXT_SCAN_PARAMS, sizeof(*cp) + sizeof(*phy) * num_phy, data, HCI_CMD_TIMEOUT); -- 2.43.0