linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Fix - Remove adv set for directed advertising
@ 2020-02-18 14:48 Sathish Narsimman
  2020-02-20  7:37 ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Sathish Narsimman @ 2020-02-18 14:48 UTC (permalink / raw)
  To: linux-bluetooth, nsathish41; +Cc: Sathish Narsimman

Extended advertising Data is set during bluetooth initialization
by default which causes InvalidHCICommandParameters when setting
Extended advertising parameters.

As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
advertising_event_property LE_LEGACY_ADV_DIRECT_IND does not
supports advertising data when the advertising set already
contains some, the controller shall return erroc code
'InvalidHCICommandParameters(0x12).

So it is required to remove adv set for handle 0x00. since we use
instance 0 for directed adv.

Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com>
---
 include/net/bluetooth/hci.h |  2 ++
 net/bluetooth/hci_conn.c    | 10 ++++++++++
 net/bluetooth/hci_request.c |  5 +++++
 net/bluetooth/hci_request.h |  1 +
 4 files changed, 18 insertions(+)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6293bdd7d862..0d7e36c54733 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -1724,6 +1724,8 @@ struct hci_cp_le_set_ext_scan_rsp_data {
 
 #define LE_SET_ADV_DATA_NO_FRAG		0x01
 
+#define HCI_OP_LE_REMOVE_ADV_SET	0x203c
+
 #define HCI_OP_LE_CLEAR_ADV_SETS	0x203d
 
 #define HCI_OP_LE_SET_ADV_SET_RAND_ADDR	0x2035
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 65fa44cbe514..1887da39a93d 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -898,6 +898,16 @@ static void hci_req_directed_advertising(struct hci_request *req,
 		cp.peer_addr_type = conn->dst_type;
 		bacpy(&cp.peer_addr, &conn->dst);
 
+		/* As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
+		 * advertising_event_property LE_LEGACY_ADV_DIRECT_IND
+		 * does not supports advertising data when the advertising set already
+		 * contains some, the controller shall return erroc code 'Invalid
+		 * HCI Command Parameters(0x12).
+		 * So it is required to remove adv set for handle 0x00. since we use
+		 * instance 0 for directed adv.
+		 */
+		hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(cp.handle), &cp.handle);
+
 		hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp);
 
 		if (own_addr_type == ADDR_LE_DEV_RANDOM &&
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index 2a1b64dbf76e..63da7acbb48c 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1550,6 +1550,11 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
 	return 0;
 }
 
+void __hci_req_remove_adv_set(struct hci_request *req, u8 handle)
+{
+	hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(handle), &handle);
+}
+
 void __hci_req_clear_ext_adv_sets(struct hci_request *req)
 {
 	hci_req_add(req, HCI_OP_LE_CLEAR_ADV_SETS, 0, NULL);
diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
index a7019fbeadd3..8dd40c6c33c8 100644
--- a/net/bluetooth/hci_request.h
+++ b/net/bluetooth/hci_request.h
@@ -84,6 +84,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk,
 int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance);
 int __hci_req_start_ext_adv(struct hci_request *req, u8 instance);
 int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance);
+void __hci_req_remove_adv_set(struct hci_request *req, u8 handle);
 void __hci_req_clear_ext_adv_sets(struct hci_request *req);
 int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
 			   bool use_rpa, struct adv_info *adv_instance,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: Fix - Remove adv set for directed advertising
  2020-02-18 14:48 [PATCH] Bluetooth: Fix - Remove adv set for directed advertising Sathish Narsimman
@ 2020-02-20  7:37 ` Marcel Holtmann
  2020-02-24  5:25   ` Sathish Narasimman
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2020-02-20  7:37 UTC (permalink / raw)
  To: Sathish Narsimman; +Cc: linux-bluetooth, Sathish Narsimman

Hi Sathish,

> Extended advertising Data is set during bluetooth initialization
> by default which causes InvalidHCICommandParameters when setting
> Extended advertising parameters.
> 
> As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
> advertising_event_property LE_LEGACY_ADV_DIRECT_IND does not
> supports advertising data when the advertising set already
> contains some, the controller shall return erroc code
> 'InvalidHCICommandParameters(0x12).
> 
> So it is required to remove adv set for handle 0x00. since we use
> instance 0 for directed adv.
> 
> Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com>
> ---
> include/net/bluetooth/hci.h |  2 ++
> net/bluetooth/hci_conn.c    | 10 ++++++++++
> net/bluetooth/hci_request.c |  5 +++++
> net/bluetooth/hci_request.h |  1 +
> 4 files changed, 18 insertions(+)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 6293bdd7d862..0d7e36c54733 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -1724,6 +1724,8 @@ struct hci_cp_le_set_ext_scan_rsp_data {
> 
> #define LE_SET_ADV_DATA_NO_FRAG		0x01
> 
> +#define HCI_OP_LE_REMOVE_ADV_SET	0x203c
> +
> #define HCI_OP_LE_CLEAR_ADV_SETS	0x203d
> 
> #define HCI_OP_LE_SET_ADV_SET_RAND_ADDR	0x2035
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 65fa44cbe514..1887da39a93d 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -898,6 +898,16 @@ static void hci_req_directed_advertising(struct hci_request *req,
> 		cp.peer_addr_type = conn->dst_type;
> 		bacpy(&cp.peer_addr, &conn->dst);
> 
> +		/* As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
> +		 * advertising_event_property LE_LEGACY_ADV_DIRECT_IND
> +		 * does not supports advertising data when the advertising set already
> +		 * contains some, the controller shall return erroc code 'Invalid
> +		 * HCI Command Parameters(0x12).
> +		 * So it is required to remove adv set for handle 0x00. since we use
> +		 * instance 0 for directed adv.
> +		 */
> +		hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(cp.handle), &cp.handle);
> +
> 		hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp);
> 
> 		if (own_addr_type == ADDR_LE_DEV_RANDOM &&
> diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
> index 2a1b64dbf76e..63da7acbb48c 100644
> --- a/net/bluetooth/hci_request.c
> +++ b/net/bluetooth/hci_request.c
> @@ -1550,6 +1550,11 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
> 	return 0;
> }
> 
> +void __hci_req_remove_adv_set(struct hci_request *req, u8 handle)
> +{
> +	hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(handle), &handle);
> +}
> +
> void __hci_req_clear_ext_adv_sets(struct hci_request *req)
> {
> 	hci_req_add(req, HCI_OP_LE_CLEAR_ADV_SETS, 0, NULL);
> diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
> index a7019fbeadd3..8dd40c6c33c8 100644
> --- a/net/bluetooth/hci_request.h
> +++ b/net/bluetooth/hci_request.h
> @@ -84,6 +84,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk,
> int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance);
> int __hci_req_start_ext_adv(struct hci_request *req, u8 instance);
> int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance);
> +void __hci_req_remove_adv_set(struct hci_request *req, u8 handle);

I don’t get this part of the patch. It is actually not used.

Regards

Marcel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: Fix - Remove adv set for directed advertising
  2020-02-20  7:37 ` Marcel Holtmann
@ 2020-02-24  5:25   ` Sathish Narasimman
  0 siblings, 0 replies; 3+ messages in thread
From: Sathish Narasimman @ 2020-02-24  5:25 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Bluez mailing list, Sathish Narsimman

Hi Marcel

On Thu, Feb 20, 2020 at 1:07 PM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Sathish,
>
> > Extended advertising Data is set during bluetooth initialization
> > by default which causes InvalidHCICommandParameters when setting
> > Extended advertising parameters.
> >
> > As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
> > advertising_event_property LE_LEGACY_ADV_DIRECT_IND does not
> > supports advertising data when the advertising set already
> > contains some, the controller shall return erroc code
> > 'InvalidHCICommandParameters(0x12).
> >
> > So it is required to remove adv set for handle 0x00. since we use
> > instance 0 for directed adv.
> >
> > Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com>
> > ---
> > include/net/bluetooth/hci.h |  2 ++
> > net/bluetooth/hci_conn.c    | 10 ++++++++++
> > net/bluetooth/hci_request.c |  5 +++++
> > net/bluetooth/hci_request.h |  1 +
> > 4 files changed, 18 insertions(+)
> >
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 6293bdd7d862..0d7e36c54733 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -1724,6 +1724,8 @@ struct hci_cp_le_set_ext_scan_rsp_data {
> >
> > #define LE_SET_ADV_DATA_NO_FRAG               0x01
> >
> > +#define HCI_OP_LE_REMOVE_ADV_SET     0x203c
> > +
> > #define HCI_OP_LE_CLEAR_ADV_SETS      0x203d
> >
> > #define HCI_OP_LE_SET_ADV_SET_RAND_ADDR       0x2035
> > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> > index 65fa44cbe514..1887da39a93d 100644
> > --- a/net/bluetooth/hci_conn.c
> > +++ b/net/bluetooth/hci_conn.c
> > @@ -898,6 +898,16 @@ static void hci_req_directed_advertising(struct hci_request *req,
> >               cp.peer_addr_type = conn->dst_type;
> >               bacpy(&cp.peer_addr, &conn->dst);
> >
> > +             /* As per Core Spec 5.2 Vol 2, PART E, Sec 7.8.53, for
> > +              * advertising_event_property LE_LEGACY_ADV_DIRECT_IND
> > +              * does not supports advertising data when the advertising set already
> > +              * contains some, the controller shall return erroc code 'Invalid
> > +              * HCI Command Parameters(0x12).
> > +              * So it is required to remove adv set for handle 0x00. since we use
> > +              * instance 0 for directed adv.
> > +              */
> > +             hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(cp.handle), &cp.handle);
> > +
> >               hci_req_add(req, HCI_OP_LE_SET_EXT_ADV_PARAMS, sizeof(cp), &cp);
> >
> >               if (own_addr_type == ADDR_LE_DEV_RANDOM &&
> > diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
> > index 2a1b64dbf76e..63da7acbb48c 100644
> > --- a/net/bluetooth/hci_request.c
> > +++ b/net/bluetooth/hci_request.c
> > @@ -1550,6 +1550,11 @@ int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
> >       return 0;
> > }
> >
> > +void __hci_req_remove_adv_set(struct hci_request *req, u8 handle)
> > +{
> > +     hci_req_add(req, HCI_OP_LE_REMOVE_ADV_SET, sizeof(handle), &handle);
> > +}
> > +
> > void __hci_req_clear_ext_adv_sets(struct hci_request *req)
> > {
> >       hci_req_add(req, HCI_OP_LE_CLEAR_ADV_SETS, 0, NULL);
> > diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
> > index a7019fbeadd3..8dd40c6c33c8 100644
> > --- a/net/bluetooth/hci_request.h
> > +++ b/net/bluetooth/hci_request.h
> > @@ -84,6 +84,7 @@ void hci_req_clear_adv_instance(struct hci_dev *hdev, struct sock *sk,
> > int __hci_req_setup_ext_adv_instance(struct hci_request *req, u8 instance);
> > int __hci_req_start_ext_adv(struct hci_request *req, u8 instance);
> > int __hci_req_enable_ext_advertising(struct hci_request *req, u8 instance);
> > +void __hci_req_remove_adv_set(struct hci_request *req, u8 handle);
>
> I don’t get this part of the patch. It is actually not used.
>
> Regards
>
> Marcel
>

it is a mistake. corected and updated the right patch set v2

Regards
Sathish N

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-24  5:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 14:48 [PATCH] Bluetooth: Fix - Remove adv set for directed advertising Sathish Narsimman
2020-02-20  7:37 ` Marcel Holtmann
2020-02-24  5:25   ` Sathish Narasimman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).