Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp495434ybt; Fri, 19 Jun 2020 06:52:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzkmzusN3EsJsi7qSQMIcjNeeGVQPdcyX9dNJbuiSdfk5VkKzeeDRqUHNX585jOZF9ur9o X-Received: by 2002:a50:cfc4:: with SMTP id i4mr3373841edk.252.1592574744598; Fri, 19 Jun 2020 06:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592574744; cv=none; d=google.com; s=arc-20160816; b=EOpbs6efMQX6ON3SuR8nDDLy2RF5Ph5kDvjS4whOcVl+WFCex20DumT2Tm0wlfyk/3 +3qYS0+K6m9R/7axbH7zPRYSsxJT+CTMrqvnEwtdG+2UpFZ+PmXDWaKl66uha+mzpRlu RE0ygTe24XxPMw1abGiRfNqB4GFU5NcilaN8NmxMde/Eh09o/fK8OLDCo0GBSdgpE4MM UDTM67+0Vwic7GsMmE7K4WG+ZsRQt+2wQu1KbnsEIKHsySTuTBBDcivit6P2vobWy7Bh jQYF/Je1cfXf9jCB38tWiF2iObl/Bb67Z0ado8FzLNM/sEwKhpdVWM+hcG6lgTNPPS1c lINw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3yzZHNveLLaMTC7TQkPBlj9DDnRWHO4rYcE3FVmW81w=; b=gtiE49xVtwpCvO58YqW3Mi/ejAm8aS6F74b5COyScTx2b4DfpxbLq5qhF6P2DtezOn FibFzITvtEDm9PydyKTQaeiZtpgDFhtDaaHCQW35GzB1j10OUpNPJStvtdEKpr0gtDv7 0pcsuzCXVAktqBI0MrbJODxclwo2zzG5XAkOBngVseGKYqYbKFgn66ZOovyymilDZxz0 HLQNbwxhlgFv370s46Pwm3REGSvTx4pAY4cbn+ZhhaLkvQWTfdAWMNnTdgnG8kzLpe1e g/T/icqJddyOd3DW52h0DRc/Yny+I2keauH+oTmVT0sz7PIoz7YPsds29nNsySACwSSQ P3SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xck8+ufY; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh21si3976026ejb.181.2020.06.19.06.51.36; Fri, 19 Jun 2020 06:52:24 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=Xck8+ufY; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732994AbgFSNuo (ORCPT + 99 others); Fri, 19 Jun 2020 09:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732879AbgFSNuo (ORCPT ); Fri, 19 Jun 2020 09:50:44 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 984CCC06174E for ; Fri, 19 Jun 2020 06:50:43 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id n23so11564295ljh.7 for ; Fri, 19 Jun 2020 06:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3yzZHNveLLaMTC7TQkPBlj9DDnRWHO4rYcE3FVmW81w=; b=Xck8+ufYn7gXA+pU02Ox5iOUzYkldKutTnbZRUA58Y6ghuJDZy8XUMXkVeIyoozzVy 7NI7BT68YGl5McZs9BkeOqdEz7DZ5Onp7tvFelZvzf6B2Mb5tq2NccWjBCfCymn38C8h UaciIki3QtNstHRYtBRUowvGUh98mK4+Tp3HBAIgHFiI2fQ/h2rOw4mmFTOcCDUNSKJo 2mxg5mVSr1tmeUdWeuxX1P7h5+W2AO118roK/ZqECTJ2exeWkzTp+8asqrPKh243JVM6 FD31SVsNi2YW2tCXrL/f7uhWcwt3b1vVGD1RXL7JxnYNk4Kcf4xk2FEaPTn69QskDXE6 RRgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3yzZHNveLLaMTC7TQkPBlj9DDnRWHO4rYcE3FVmW81w=; b=UobPojBltD31SSIC/hhLN4DtCJfgD1H33AS9kvm1Bwt0vZdwbTZN4C185QcEDa39av HZcPKkAnFt1sbIQTI8R+ZYRvSjZw1a/HXshdXRvodMfsYqAjPr8OEYFymLrnG0IYlxlK BJKdkBvPjAuZmvn7meahlSxqp4G6IOwej8UHD6ZD7NrPbbKqAd+OoWII8hFiSujc8Sf8 S9LjZQxPvb34xWy/AW90uJlwngWn5p4v96QCjJ0ut8TI4Z7Hc9xT1OK20Gnvd6jDfnsa maPystFsAIKBzDuJ5sLUu08ycl7WY6AkMjGWlIuo9LlmGKr+ylZNr4cYNkBJSjPZLSZf m1gA== X-Gm-Message-State: AOAM530LP7BJ4+DRQ1M44adM8M+EMnUyzsfLOdDXDufSX09G6uUik2f4 XvpQcUQYdYZ0exv+TTIAyvEvAe3eKWzNQ+0MlsJtVtg0 X-Received: by 2002:a2e:890d:: with SMTP id d13mr1959225lji.75.1592574641747; Fri, 19 Jun 2020 06:50:41 -0700 (PDT) MIME-Version: 1.0 References: <20200618210659.142284-1-alainm@chromium.org> In-Reply-To: From: Alain Michaud Date: Fri, 19 Jun 2020 09:50:30 -0400 Message-ID: Subject: Re: [PATCH v1] bluetooth: use configured params for ext adv To: Marcel Holtmann Cc: Alain Michaud , BlueZ , Abhishek Pandit-Subedi , Daniel Winkler Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Marcel, On Fri, Jun 19, 2020 at 3:46 AM Marcel Holtmann wrote= : > > Hi Alain, > > please use =E2=80=9CBluetooth: =E2=80=9C prefix for the subject. ack. > > > > When the extended advertisement feature is enabled, a hardcoded min and > > max interval of 0x8000 is used. This patches fixes this issue by using > > the configured min/max value. > > > > This was validated by setting min/max in main.conf and making sure the > > right setting is applied: > > > > < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) ple= n > > 25 #93 [hci0] 10.953011 > > =E2=80=A6 > > Min advertising interval: 181.250 msec (0x0122) > > Max advertising interval: 181.250 msec (0x0122) > > =E2=80=A6 > > > > Reviewed-by: Abhishek Pandit-Subedi > > Reviewed-by: Daniel Winkler > > > > Signed-off-by: Alain Michaud > > The Reviewed-by lines go after your Signed-off-by. ack. > > > > --- > > > > net/bluetooth/hci_request.c | 10 ++++++---- > > 1 file changed, 6 insertions(+), 4 deletions(-) > > > > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c > > index 29decd7e8051..08818b9bf89f 100644 > > --- a/net/bluetooth/hci_request.c > > +++ b/net/bluetooth/hci_request.c > > @@ -1799,8 +1799,9 @@ int __hci_req_setup_ext_adv_instance(struct hci_r= equest *req, u8 instance) > > int err; > > struct adv_info *adv_instance; > > bool secondary_adv; > > - /* In ext adv set param interval is 3 octets */ > > - const u8 adv_interval[3] =3D { 0x00, 0x08, 0x00 }; > > + /* In ext adv set param interval is 3 octets in le format */ > > + const __le32 min_adv_interval =3D cpu_to_le32(hdev->le_adv_min_in= terval); > > + const __le32 max_adv_interval =3D cpu_to_le32(hdev->le_adv_max_in= terval); > > Scrap the const here. I'd like to understand why it isn't prefered to use const when you don't intend to modify it in the code. > > > And it is wrong since your hdev->le_adv_{min,max}_interval is actually __= u16. So that first needs to be extended to a __u16 value. The macro actually leads to a function call that has a __u32 as a parameter so the __u16 gets upcasted to a __u32 already. > > > That said, if we have this in the Load Default System Configuration list,= we should extended it to __le32 there as well. I agree, this means the range of default system configuration may not be sufficient to accept all possible values that the newer command supports, although I think this is a separate issue from what this patch is trying to solve. > > > > if (instance > 0) { > > adv_instance =3D hci_find_adv_instance(hdev, instance); > > @@ -1833,8 +1834,9 @@ int __hci_req_setup_ext_adv_instance(struct hci_r= equest *req, u8 instance) > > > > memset(&cp, 0, sizeof(cp)); > > > > - memcpy(cp.min_interval, adv_interval, sizeof(cp.min_interval)); > > - memcpy(cp.max_interval, adv_interval, sizeof(cp.max_interval)); > > + /* take least significant 3 bytes */ > > + memcpy(cp.min_interval, &min_adv_interval, sizeof(cp.min_interval= )); > > + memcpy(cp.max_interval, &max_adv_interval, sizeof(cp.max_interval= )); > > This is dangerous and I think it actually break in case of unaligned acce= ss platforms. Since it is in le format already and the 3 bytes from the cmd struct are raw, I'm not sure how this can be dangerous. It effectively yields the exact same results as your suggestions below. > > > In this case I prefer to actually do this manually. > > /* In ext adv min interval is 3 octets */ > cp.min_interval[0] =3D cp.min_interval & 0xff; > cp.min_interval[1] =3D (cp.min_interval & 0xff00) >> 8; > cp.min_interval[2] =3D (cp.min_interval & 0xff0000) >> 12= ; > > Regards > > Marcel >