Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp786424ybt; Mon, 6 Jul 2020 23:44:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnDC2EB3Z3ir2FnNp29Cl1+iJAKIMHzcuHtefLbOTvDfWetnBuEgSgi5Vc2w1WzaesXjfo X-Received: by 2002:aa7:d4c1:: with SMTP id t1mr51927511edr.253.1594104285914; Mon, 06 Jul 2020 23:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594104285; cv=none; d=google.com; s=arc-20160816; b=WggfD2IM2o6zEZ5WySdifoM88EAHHa5wamgVgb1Css1XUviFYePVYCHllAwDXc+FMb z3KeRO/QURvHcZskR9U/ehXHzw9k28t7O2EwObfUQf2/Y3S3EPLvUr0Yzqc/YYZk/4Z9 oUiEa497nHJRlctsZ54VWVc1xX5f+tcXq0LCOgHzP0wRyUD0yy50lnF0n9UueXR2Ebsa DVp1NMsi8bkwHAZUa0H80R2siFVV9hvoCXkFCut2tc4D9lqZ9bri60Td8f3mWdd3O3/1 5ZqKPBkA7L8MJkGMORJTvM0R1kLSYTItDSGgpdPeJP1F5A4+wyGcilFk1RMDDQiY85U0 Yg+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=BuxJ76vOc+TJbYQkmzJVGVV5a5UVU3LEU5LcH+nzIJg=; b=vEjSJDIo75TYuSzgbaVRcr3nXiEktnKG6ffTHRmof8EVUBH8TpU6QiVzJhJ9dTAhpn KSwmEml4/8zhtIBBK0IsUTcSlMtrAehtGby5/M1yhGnSdLvMaxoIQ07rhJSRkL0Eh11k OqUMMbxIotviPCRZYudThgJOg9fiO9500wNe+HttdFnC6SsPKJ50PENKUtE//G6FHW1g min2yGgfHukkie77n7TlBjtum5+xwmp4EglAyZV6tZZ9dlbvLTN7j/BQEWI8mx3hOEAV T4EQ8Vl6CKMpG+aD9gePcC/yZtl9A9/E2XSpDYOk35bmKYbvDcNsQ3kb5PXi9+KGC3Sj 4L5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si14636427edv.451.2020.07.06.23.44.12; Mon, 06 Jul 2020 23:44:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgGGGoH convert rfc822-to-8bit (ORCPT + 99 others); Tue, 7 Jul 2020 02:44:07 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:43446 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbgGGGoH (ORCPT ); Tue, 7 Jul 2020 02:44:07 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 790BFCECE5; Tue, 7 Jul 2020 08:54:02 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v3] Bluetooth: le_simult_central_peripheral experimental feature From: Marcel Holtmann In-Reply-To: <20200706154449.3828193-1-alainm@chromium.org> Date: Tue, 7 Jul 2020 08:43:35 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <0175E6D3-8547-4633-B9A8-2AB15CE25C5B@holtmann.org> References: <20200706154449.3828193-1-alainm@chromium.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alain, > This patch adds an le_simult_central_peripheral features which allows a > clients to determine if the controller is able to support peripheral and > central connections separately and at the same time. > > Signed-off-by: Alain Michaud > --- > > Changes in v3: > - Back to the original design of V1 and integrated Marcel's feedback. > > Changes in v2: > - Slight change of design based on offline feedback > > net/bluetooth/mgmt.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 5e9b9728eeac..b34e6f3c07ec 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3753,12 +3753,19 @@ static const u8 debug_uuid[16] = { > }; > #endif > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > +static const u8 le_simult_central_peripheral[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > +}; > + > static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > void *data, u16 data_len) > { > - char buf[42]; > + char buf[44]; > struct mgmt_rp_read_exp_features_info *rp = (void *)buf; > u16 idx = 0; > + u32 flags; > > bt_dev_dbg(hdev, "sock %p", sk); > > @@ -3766,7 +3773,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > > #ifdef CONFIG_BT_FEATURE_DEBUG > if (!hdev) { > - u32 flags = bt_dbg_get() ? BIT(0) : 0; > + flags = bt_dbg_get() ? BIT(0) : 0; I was trying to contain the used variables in the scope here so that we don’t get funny kernel warnings about unused or uninitialized variables when options are not selected and we eventually add more here. > > memcpy(rp->features[idx].uuid, debug_uuid, 16); > rp->features[idx].flags = cpu_to_le32(flags); > @@ -3774,6 +3781,19 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + flags = 0; > + memcpy(rp->features[idx].uuid, le_simult_central_peripheral, > + sizeof(le_simult_central_peripheral)); > + > + if (hdev && test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > + (hdev->le_states[4] & 0x08) && /* Central */ > + (hdev->le_states[4] & 0x40) && /* Peripheral */ > + (hdev->le_states[3] & 0x10) /* Simultaneous */) > + flags |= BIT(0); > + > + rp->features[idx].flags = cpu_to_le32(flags); > + idx++; > + > rp->feature_count = cpu_to_le16(idx); You do actually need to wrap this in if (hdev) { } so that a) this looks cleanly and b) this is only reported when the is provided. The experimental feature command is special since it can be used per hdev or globally. > > /* After reading the experimental features information, enable > -- > 2.27.0.212.ge8ba1cc988-goog > Regards Marcel