Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1467446ybt; Thu, 2 Jul 2020 06:19:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFBzH7eOJOYfqoY/rYtgGEjmxMCA5RXbkFtxB/NlQ1NmugUI124U0NMVfgwFLrACaUcvj6 X-Received: by 2002:a17:906:444e:: with SMTP id i14mr15149836ejp.418.1593695978232; Thu, 02 Jul 2020 06:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593695978; cv=none; d=google.com; s=arc-20160816; b=LGCbeGdPi9NmvMdmEizF/LGDI5bjM1zYuQML7hoVpx4EEDVJReaEjvRdduHYeO7IvO MVXwCnzbrDCnYGqF2lddIxOjga/r/Y/kbchj9hXtIjAn/JbOuPs7mTDrh342IyoT+dhU fxXxRxWkIQGJ3y8RfSje3SXKzAz5j3oCr5rqcwdt6jAD2NxfWWyJWUP7LQO7szHBL3dp 7ocFSWo30sAOStsp9+s5WUSYoqn2HZ9WURvRwFkVo6gKaKm++ReM7dwx9KDG3NCLkDTM it7VtxGZgPQa8sRMT1rLTw5HH6XXigLrCr47MAfh76+Dzps7CCgnb6mcwKJUOn6DhOp1 Po1g== 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=AzWjlMLr8hSbdQmxLWBbDnql+M04aWuzSuGnVkZtltU=; b=ena/QT5wc7sCtsrq5YIblETvEgDv+fFECnaTNngtBQ4sVFUdMbz5pjAw2zZ7YI0N91 ntx/PqpE4Lch1AZdA4mqMiV2W0OTvgJM44Swvc3oVql2i7BoJbIsvwMEkXRMpbHnQQRG 3WMqTS/Vns2kM3LEEycodUWARzkXvdeOvtw/Yv4zpeZ0mvMJUesz02HNN/wN3f+YQcq2 WKBTQJAKLpekVoZ0sqU6pKhMdtj2H5Gs/lhMRMhsiR9gDS1hcIrX7/RozRqXtPSepZ09 2d6fTXm9nfpjfHHa4JasNRsAuPVNFJHQzcO0IvhemkzP0xPQTytAGv6vmmlBWYED8czT u4UA== 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 h1si1961159ejj.575.2020.07.02.06.18.57; Thu, 02 Jul 2020 06:19:38 -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 S1729150AbgGBNSo convert rfc822-to-8bit (ORCPT + 99 others); Thu, 2 Jul 2020 09:18:44 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:41205 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgGBNSo (ORCPT ); Thu, 2 Jul 2020 09:18:44 -0400 Received: from marcel-macpro.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 6AF6BCED12; Thu, 2 Jul 2020 15:28:38 +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 v2] Bluetooth: le_supported_roles experimental feature From: Marcel Holtmann In-Reply-To: <20200701220853.421445-1-alainm@chromium.org> Date: Thu, 2 Jul 2020 15:18:42 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <427B6E1C-178C-405D-88F8-899EC48AC8A9@holtmann.org> References: <20200701220853.421445-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_supported_roles 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 v2: > - Slight change of design based on offline feedback > > net/bluetooth/mgmt.c | 36 +++++++++++++++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c > index 5e9b9728eeac..c13fcc21745f 100644 > --- a/net/bluetooth/mgmt.c > +++ b/net/bluetooth/mgmt.c > @@ -3753,10 +3753,36 @@ static const u8 debug_uuid[16] = { > }; > #endif > > +/* 671b10b5-42c0-4696-9227-eb28d1b049d6 */ > +static const u8 le_supported_roles[16] = { > + 0xd6, 0x49, 0xb0, 0xd1, 0x28, 0xeb, 0x27, 0x92, > + 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, > +}; > + > +static u32 get_le_roles_flags(struct hci_dev *hdev) > +{ > + u32 flags = 0; > + > + /* Central connections supported */ > + if (hdev->le_states[4] & 0x08) > + flags |= BIT(0); > + > + /* Peripheral connections supported */ > + if (hdev->le_states[4] & 0x40) > + flags |= BIT(1); > + > + /* Simult central and peripheral connections supported */ > + if (test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks) && > + (hdev->le_states[3] & 0x10)) > + flags |= BIT(2); > + > + return flags; > +} this is not what we can do here. The flags are defined like this. The following bits are defined for the Flags parameter: 0 Feature active 1 Causes change in supported settings And I want these flags for generic handling of experimental features. Individual features can not overwrite it. So if you only want to support a the “read" functionality, then something like this please. if ((hdev->le_states[4] & 0x08) && /* Central */ (hdev->le_states[4] & 0x40) && /* Peripheral */ (hdev->le_states[3] & 0x10) && /* Simultaneous */ test_bit(HCI_QUIRK_VALID_LE_STATES, &hdev->quirks)) flags |= BIT(0); > + > 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; > > @@ -3774,6 +3800,14 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev, > } > #endif > > + if (hdev) { > + memcpy(rp->features[idx].uuid, le_supported_roles, > + sizeof(le_supported_roles)); > + And I would put it all here instead of a separate function. > + rp->features[idx].flags = cpu_to_le32(get_le_roles_flags(hdev)); > + ++idx; > + } > + > rp->feature_count = cpu_to_le16(idx); > > /* After reading the experimental features information, enable Regards Marcel