Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp668444ybg; Wed, 10 Jun 2020 10:26:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJmCK7mrUYonvY5IYqCJdPUblpHDMk/DJ28y+t/SVIv8pGRngG4opDBLhjSB0aL53fDXUF X-Received: by 2002:a17:906:c828:: with SMTP id dd8mr4595966ejb.550.1591809998285; Wed, 10 Jun 2020 10:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591809998; cv=none; d=google.com; s=arc-20160816; b=DiwxR5VHkRggLZYGJmoGn9LwW+FQuAL+PGTJnXTYyz5sNnsWTcMOgUgdFJsoARQBsH ZZ9EAoR0lz2tQD5yNYFbNJmUpcnDKUYqXQI7oxTFxO3vWb+TUrsOEp3spe+vc1ZWot8e rD1fclqSILhUMz1UKgZEKPU3BS+Iekn5eVWvDsBRrX7rnJyBZKkKR1H4ibhpe9XYgD0c jl7wrysRoe2e39gCy8D+k0CKvmA9nA+203ssiT8YOucQZrk52HWFW3POBTzZPMxeLdvc 6mzedVVxApMXY+zuz+8iTj/XxSrezoX7qdVHFJI32cb8TWLUeR2i1TRJZEhra0U9BCWm ra7Q== 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=PyQCzVc22nnXzNwMh8UTnaN46Px2d6dwNGDbLt9UvpI=; b=n+dZiC81WkJycfOrETmMuZty+HAjcv1nZRsIrVx/yixkz0hKwg/fvx6Dhk3AdirnnK JnM6AyhXJKcY3SDDWFNXLC2jL2Zc4ODho5NKdU9wCBr50kDi0+k27MORQ+9Es8CPiJF5 AnH9WhZxDEtOxwneHLoyCoR61Qk5+++htnY/GG0K4PrJPd9PCiZ2R1lq/AvDpeuKBJBQ g65EzO06T8wZAWXOkSZaW+ZXKbOG+3ABBxl2FmP69Mvel72XJUjdDUFaSQgG6600UFGr fyEx0oBqLtvmsgq7Yqojo1CbQttw+TkxBtUJnZRbwjFt+BLW4BWqq9jxBhAdqNS9Ua82 eyiw== 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 l15si408252ejc.97.2020.06.10.10.26.12; Wed, 10 Jun 2020 10:26: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 S1728009AbgFJQ7L convert rfc822-to-8bit (ORCPT + 99 others); Wed, 10 Jun 2020 12:59:11 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:54762 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgFJQ7L (ORCPT ); Wed, 10 Jun 2020 12:59:11 -0400 Received: from [192.168.1.91] (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id EDAE8CECE8; Wed, 10 Jun 2020 19:08:58 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH v1 3/3] bluetooth: implement read/set default system parameters mgmt From: Marcel Holtmann In-Reply-To: Date: Wed, 10 Jun 2020 18:58:38 +0200 Cc: Alain Michaud , BlueZ , Abhishek Pandit-Subedi Content-Transfer-Encoding: 8BIT Message-Id: References: <20200609140351.153833-1-alainm@chromium.org> <20200609140351.153833-4-alainm@chromium.org> <4CD6CBD8-0EC4-47F1-8B05-5AC8BB78B97A@holtmann.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 implements the read default system parameters and the set >>> default system parameters mgmt commands. >>> >>> Reviewed-by: Abhishek Pandit-Subedi >>> Signed-off-by: Alain Michaud >>> --- >>> >>> net/bluetooth/mgmt.c | 429 +++++++++++++++++++++++++++++++++++++++++++ >>> 1 file changed, 429 insertions(+) >> >> I have the feeling that we want to create a net/bluetooth/mgmt_config.c to move all the configuration parameters parsing and handling into a separate. I have the feeling that otherwise mgmt.c will grow quickly. > ok, I'll send out a v2 that split it out in mgmt_config.c/h > >> >>> >>> diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c >>> index 9e8a3cccc6ca..98a4193c8e66 100644 >>> --- a/net/bluetooth/mgmt.c >>> +++ b/net/bluetooth/mgmt.c >>> @@ -111,6 +111,8 @@ static const u16 mgmt_commands[] = { >>> MGMT_OP_READ_SECURITY_INFO, >>> MGMT_OP_READ_EXP_FEATURES_INFO, >>> MGMT_OP_SET_EXP_FEATURE, >>> + MGMT_OP_READ_DEFAULT_SYSTEM_PARAMETERS, >>> + MGMT_OP_SET_DEFAULT_SYSTEM_PARAMETERS, >>> }; >> >> Please also add the OP_READ_ command to mgmt_untrusted_commands array. > ACK. >> >>> static const u16 mgmt_events[] = { >>> @@ -3849,6 +3851,431 @@ static int set_exp_feature(struct sock *sk, struct hci_dev *hdev, >>> MGMT_STATUS_NOT_SUPPORTED); >>> } >>> >>> +static int read_default_system_parameters(struct sock *sk, struct hci_dev *hdev, >>> + void *data, u16 data_len) >>> +{ >>> + struct { >>> + struct mgmt_system_parameter_tlv entry; >>> + union { >>> + /* This is a simplification for now since all values >>> + * are 16 bits. In the future, this code may need >>> + * refactoring to account for variable length values >>> + * and properly calculate the required buffer size. >>> + */ >>> + u16 value; >>> + }; >>> + } __packed params[] = { >>> + /* Please see mgmt-api.txt for documentation of these values */ >>> + { >>> + { 0x0000, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_page_scan_type) } >>> + }, >>> + { >>> + { 0x0001, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_page_scan_int) } >>> + }, >>> + { >>> + { 0x0002, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_page_scan_window) } >>> + }, >>> + { >>> + { 0x0003, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_inq_scan_type) } >>> + }, >>> + { >>> + { 0x0004, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_inq_scan_int) } >>> + }, >>> + { >>> + { 0x0005, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_inq_scan_window) } >>> + }, >>> + { >>> + { 0x0006, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_br_lsto) } >>> + }, >>> + { >>> + { 0x0007, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_page_timeout) } >>> + }, >>> + { >>> + { 0x0008, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->sniff_min_interval) } >>> + }, >>> + { >>> + { 0x0009, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->sniff_max_interval) } >>> + }, >>> + { >>> + { 0x000a, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_adv_min_interval) } >>> + }, >>> + { >>> + { 0x000b, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_adv_max_interval) } >>> + }, >>> + { >>> + { 0x000c, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->def_multi_adv_rotation_duration) } >>> + }, >>> + { >>> + { 0x000d, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_interval) } >>> + }, >>> + { >>> + { 0x000e, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_window) } >>> + }, >>> + { >>> + { 0x000f, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_int_suspend) } >>> + }, >>> + { >>> + { 0x0010, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_window_suspend) } >>> + }, >>> + { >>> + { 0x0011, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_int_discovery) } >>> + }, >>> + { >>> + { 0x0012, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_window_discovery) } >>> + }, >>> + { >>> + { 0x0013, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_int_adv_monitor) } >>> + }, >>> + { >>> + { 0x0014, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_window_adv_monitor) } >>> + }, >>> + { >>> + { 0x0015, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_int_connect) } >>> + }, >>> + { >>> + { 0x0016, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_scan_window_connect) } >>> + }, >>> + { >>> + { 0x0017, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_conn_min_interval) } >>> + }, >>> + { >>> + { 0x0018, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_conn_max_interval) } >>> + }, >>> + { >>> + { 0x0019, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_conn_latency) } >>> + }, >>> + { >>> + { 0x001a, sizeof(__u16) }, >>> + { cpu_to_le16(hdev->le_supv_timeout) } >>> + }, >> >> This is creative and I like it. However I would take it one step further. Define a macro similar USB_DEVICE etc. so you get a simpler table. >> >> { HDEV_PARAM(0x0018, le_conn_max_interval) }, >> { HDEV_PARAM(0x0019, le_conn_latency) }, >> { } >> >> > Ok, that makes sense, I'll think of something for v2. > >>> + }; >>> + struct mgmt_rp_read_default_system_parameters *rp = (void *)params; >>> + >>> + bt_dev_dbg(hdev, "sock %p", sk); >>> + >>> + return mgmt_cmd_complete(sk, hdev->id, >>> + MGMT_OP_READ_DEFAULT_SYSTEM_PARAMETERS, >>> + 0, rp, sizeof(params)); >> >> Please introduce HCI_MGMT_SYSTEM_CONFIG_EVENTS and send them out as described in mgmt-api.txt > Looks like you added this after my original proposal to mgmt-api.txt. > I'd like to propose this is also implemented in a separate patch. feel free to add it as a separate patch. See the Experimental Feature commands + event on how this could be done. Regards Marcel