Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp252761ybt; Fri, 19 Jun 2020 00:47:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznexQSi196w8KQjzDHBOsRqtS2BfsSwpufbrtzjG9H9gXQVXsaLp2fSKwrdNlbPUuNIIyt X-Received: by 2002:a17:906:3c4c:: with SMTP id i12mr2354637ejg.464.1592552826330; Fri, 19 Jun 2020 00:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592552826; cv=none; d=google.com; s=arc-20160816; b=jeLY6sXLi8T/UzITw8fnhvnEPDiE54/1b4xS5an0rfl/QwmG+2EaMhXe+eHwUcbwRA fXRsgdPgcefnhmbSKx8/oghbfPDC01iq+5ZJ4EiTDfXM9t6GM4N2nnHDp9JAnWbbXUfW BXerH7ZP2mXIkfEQ+H+1RNjiUvkCP3Fvx5hvRn5cLxD5N7DppnUnV0gGjOg+CmIuidUs apqfP5+u75Y6BmE8SmFlLjIFEMMGKSyVA9/TY8PUTUJo7K5PPS/gdpd5wLKGuEE4SVVD 5FasRMg+Rr7TWd4DEPIaXFWrGPaX8h/Vt9xl9FBR+0RbeDOi0+3dwYwV/GuaNBdCFKoP 1UBw== 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=o0XmK69/hUVyWMrITe1vaGRJBcNeOnLEFXRc0tohkb0=; b=yxUmsNSl6TutShxMLOIWkW+3IYZjOBWFVLPIKqzZsZ+oVTB+Bxxv3FKKNzFUUaTNjb 6p5p9NWReqDEtgW7o4O74rySPfRZsrkGMqZWRv0hllShfzGkb1vDeb6Z0RMMCfXR5IWz SRwfIGxmzeNlivyu1+ElRgatHvx8/tVkeN8dXncSWBGa0fs7jZIcUb4Ho2gxwDXDeFaw EVpt5uLsIZiCEHbgGSjDLb+ojQAofeGp3W/zwYA745Zlt9lhkhgsUUiIjZ661QFJEI2a URpleshxK7YTbJjLayLovzLtbtcSPpJSNbcJPsEC0+/CcTV5grMCqx8/4JX0bF8ligcj 9GzA== 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 k18si4119081edk.48.2020.06.19.00.46.39; Fri, 19 Jun 2020 00:47:06 -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 S1730861AbgFSHp6 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 19 Jun 2020 03:45:58 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:50376 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730830AbgFSHp6 (ORCPT ); Fri, 19 Jun 2020 03:45:58 -0400 Received: from marcel-macbook.fritz.box (p5b3d2638.dip0.t-ipconnect.de [91.61.38.56]) by mail.holtmann.org (Postfix) with ESMTPSA id 08BF4CECF0; Fri, 19 Jun 2020 09:55:47 +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 v1] bluetooth: use configured params for ext adv From: Marcel Holtmann In-Reply-To: <20200618210659.142284-1-alainm@chromium.org> Date: Fri, 19 Jun 2020 09:45:55 +0200 Cc: linux-bluetooth@vger.kernel.org, Abhishek Pandit-Subedi , Daniel Winkler Content-Transfer-Encoding: 8BIT Message-Id: References: <20200618210659.142284-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, please use “Bluetooth: “ prefix for the subject. > 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) plen > 25 #93 [hci0] 10.953011 > … > Min advertising interval: 181.250 msec (0x0122) > Max advertising interval: 181.250 msec (0x0122) > … > > Reviewed-by: Abhishek Pandit-Subedi > Reviewed-by: Daniel Winkler > > Signed-off-by: Alain Michaud The Reviewed-by lines go after your Signed-off-by. > --- > > 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_request *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] = { 0x00, 0x08, 0x00 }; > + /* In ext adv set param interval is 3 octets in le format */ > + const __le32 min_adv_interval = cpu_to_le32(hdev->le_adv_min_interval); > + const __le32 max_adv_interval = cpu_to_le32(hdev->le_adv_max_interval); Scrap the const here. 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. That said, if we have this in the Load Default System Configuration list, we should extended it to __le32 there as well. > if (instance > 0) { > adv_instance = hci_find_adv_instance(hdev, instance); > @@ -1833,8 +1834,9 @@ int __hci_req_setup_ext_adv_instance(struct hci_request *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 access platforms. In this case I prefer to actually do this manually. /* In ext adv min interval is 3 octets */ cp.min_interval[0] = cp.min_interval & 0xff; cp.min_interval[1] = (cp.min_interval & 0xff00) >> 8; cp.min_interval[2] = (cp.min_interval & 0xff0000) >> 12; Regards Marcel