* [RFC 0/4] Periodic Inquiry Handling
@ 2012-03-20 2:32 Andre Guedes
2012-03-20 2:32 ` [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Andre Guedes @ 2012-03-20 2:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
Hi all,
This patch series implements some Marcel's considerations about Periodic
Inquiry handling.
The main points are:
* Track if periodic inquiry enabled or not;
* Fail start discovery if periodic inquiry is enabled;
* Ignore inquiry result events from periodic inquiry.
These considerations were given in "[PATCH v4 01/14] Bluetooth: Periodic
Inquiry and mgmt discovering event" email.
BR,
Andre
Andre Guedes (4):
Bluetooth: Add Periodic Inquiry command complete handler
Bluetooth: Add HCI_PINQUIRY to dev_flags
Bluetooth: Check HCI_PINQUIRY in start_discovery
Bluetooth: Ignore inquiry results from periodic inquiry
include/net/bluetooth/hci.h | 3 +++
net/bluetooth/hci_event.c | 30 +++++++++++++++++++++++++++++-
net/bluetooth/mgmt.c | 6 ++++++
3 files changed, 38 insertions(+), 1 deletion(-)
--
1.7.9.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler
2012-03-20 2:32 [RFC 0/4] Periodic Inquiry Handling Andre Guedes
@ 2012-03-20 2:32 ` Andre Guedes
2012-03-20 15:50 ` Marcel Holtmann
2012-03-20 2:32 ` [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags Andre Guedes
` (2 subsequent siblings)
3 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-03-20 2:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch adds a handler function to Periodic Inquiry command
complete event.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_event.c | 11 +++++++++++
2 files changed, 13 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index dbbb593..d74645e 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -324,6 +324,8 @@ struct hci_cp_inquiry {
#define HCI_OP_INQUIRY_CANCEL 0x0402
+#define HCI_OP_PERIODIC_INQ 0x0403
+
#define HCI_OP_EXIT_PERIODIC_INQ 0x0404
#define HCI_OP_CREATE_CONN 0x0405
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 04d39f4..af0c5a2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -70,6 +70,13 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
hci_conn_check_pending(hdev);
}
+static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ __u8 status = *((__u8 *) skb->data);
+
+ BT_DBG("%s status 0x%x", hdev->name, status);
+}
+
static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
{
__u8 status = *((__u8 *) skb->data);
@@ -2154,6 +2161,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
hci_cc_inquiry_cancel(hdev, skb);
break;
+ case HCI_OP_PERIODIC_INQ:
+ hci_cc_periodic_inq(hdev, skb);
+ break;
+
case HCI_OP_EXIT_PERIODIC_INQ:
hci_cc_exit_periodic_inq(hdev, skb);
break;
--
1.7.9.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags
2012-03-20 2:32 [RFC 0/4] Periodic Inquiry Handling Andre Guedes
2012-03-20 2:32 ` [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
@ 2012-03-20 2:32 ` Andre Guedes
2012-03-20 15:53 ` Marcel Holtmann
2012-03-20 2:32 ` [RFC 3/4] Bluetooth: Check HCI_PINQUIRY in start_discovery Andre Guedes
2012-03-20 2:32 ` [RFC 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
3 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-03-20 2:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch adds the HCI_PINQUIRY flag to dev_flags. This flag tracks
if periodic inquiry is enabled or not.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
---
include/net/bluetooth/hci.h | 1 +
net/bluetooth/hci_event.c | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index d74645e..b3e89bf 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -102,6 +102,7 @@ enum {
HCI_DISCOVERABLE,
HCI_LINK_SECURITY,
HCI_PENDING_CLASS,
+ HCI_PINQUIRY,
};
/* HCI ioctl defines */
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index af0c5a2..4d13843 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -75,6 +75,11 @@ static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
__u8 status = *((__u8 *) skb->data);
BT_DBG("%s status 0x%x", hdev->name, status);
+
+ if (status)
+ return;
+
+ set_bit(HCI_PINQUIRY, &hdev->dev_flags);
}
static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
@@ -86,6 +91,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
if (status)
return;
+ clear_bit(HCI_PINQUIRY, &hdev->dev_flags);
+
hci_conn_check_pending(hdev);
}
@@ -200,7 +207,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
hci_req_complete(hdev, HCI_OP_RESET, status);
/* Reset all non-persistent flags */
- hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS));
+ hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS) |
+ BIT(HCI_PINQUIRY));
hdev->discovery.state = DISCOVERY_STOPPED;
}
--
1.7.9.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 3/4] Bluetooth: Check HCI_PINQUIRY in start_discovery
2012-03-20 2:32 [RFC 0/4] Periodic Inquiry Handling Andre Guedes
2012-03-20 2:32 ` [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
2012-03-20 2:32 ` [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags Andre Guedes
@ 2012-03-20 2:32 ` Andre Guedes
2012-03-20 15:54 ` Marcel Holtmann
2012-03-20 2:32 ` [RFC 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
3 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-03-20 2:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch adds a HCI_PINQUIRY check to start_discovery. If
periodic inquiry is enabled, we fail MGMT Start Discovery
command with MGMT_STATUS_BUSY code.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
---
net/bluetooth/mgmt.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index b8f9016..a3365ba 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2317,6 +2317,12 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev,
goto failed;
}
+ if (test_bit(HCI_PINQUIRY, &hdev->dev_flags)) {
+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
+ MGMT_STATUS_BUSY);
+ goto failed;
+ }
+
if (hdev->discovery.state != DISCOVERY_STOPPED) {
err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
MGMT_STATUS_BUSY);
--
1.7.9.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC 4/4] Bluetooth: Ignore inquiry results from periodic inquiry
2012-03-20 2:32 [RFC 0/4] Periodic Inquiry Handling Andre Guedes
` (2 preceding siblings ...)
2012-03-20 2:32 ` [RFC 3/4] Bluetooth: Check HCI_PINQUIRY in start_discovery Andre Guedes
@ 2012-03-20 2:32 ` Andre Guedes
2012-03-20 15:55 ` Marcel Holtmann
3 siblings, 1 reply; 10+ messages in thread
From: Andre Guedes @ 2012-03-20 2:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: andre.guedes
This patch changes inquiry result function handlers so they ignore
inquiry result events if periodic inquiry is enabled.
Signed-off-by: Andre Guedes <aguedespe@gmail.com>
---
net/bluetooth/hci_event.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 4d13843..f1b9f2e 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1723,6 +1723,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
if (!num_rsp)
return;
+ if (test_bit(HCI_PINQUIRY, &hdev->dev_flags))
+ return;
+
hci_dev_lock(hdev);
for (; num_rsp; num_rsp--, info++) {
@@ -2824,6 +2827,9 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
if (!num_rsp)
return;
+ if (test_bit(HCI_PINQUIRY, &hdev->dev_flags))
+ return;
+
hci_dev_lock(hdev);
if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
@@ -2995,6 +3001,9 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
if (!num_rsp)
return;
+ if (test_bit(HCI_PINQUIRY, &hdev->dev_flags))
+ return;
+
hci_dev_lock(hdev);
for (; num_rsp; num_rsp--, info++) {
--
1.7.9.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler
2012-03-20 2:32 ` [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
@ 2012-03-20 15:50 ` Marcel Holtmann
0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2012-03-20 15:50 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth, andre.guedes
Hi Andre,
> This patch adds a handler function to Periodic Inquiry command
> complete event.
>
> Signed-off-by: Andre Guedes <aguedespe@gmail.com>
> ---
> include/net/bluetooth/hci.h | 2 ++
> net/bluetooth/hci_event.c | 11 +++++++++++
> 2 files changed, 13 insertions(+)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags
2012-03-20 2:32 ` [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags Andre Guedes
@ 2012-03-20 15:53 ` Marcel Holtmann
2012-03-21 2:21 ` Andre Guedes
0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2012-03-20 15:53 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth, andre.guedes
Hi Andre,
> This patch adds the HCI_PINQUIRY flag to dev_flags. This flag tracks
> if periodic inquiry is enabled or not.
>
> Signed-off-by: Andre Guedes <aguedespe@gmail.com>
> ---
> include/net/bluetooth/hci.h | 1 +
> net/bluetooth/hci_event.c | 10 +++++++++-
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index d74645e..b3e89bf 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -102,6 +102,7 @@ enum {
> HCI_DISCOVERABLE,
> HCI_LINK_SECURITY,
> HCI_PENDING_CLASS,
> + HCI_PINQUIRY,
call this HCI_PERIODIC_INQ. Since PINQUIRY is horrible to distinguish
from INQUIRY.
> };
>
> /* HCI ioctl defines */
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index af0c5a2..4d13843 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -75,6 +75,11 @@ static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
> __u8 status = *((__u8 *) skb->data);
>
> BT_DBG("%s status 0x%x", hdev->name, status);
> +
> + if (status)
> + return;
> +
> + set_bit(HCI_PINQUIRY, &hdev->dev_flags);
> }
>
> static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
> @@ -86,6 +91,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
> if (status)
> return;
>
> + clear_bit(HCI_PINQUIRY, &hdev->dev_flags);
> +
> hci_conn_check_pending(hdev);
> }
>
> @@ -200,7 +207,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
> hci_req_complete(hdev, HCI_OP_RESET, status);
>
> /* Reset all non-persistent flags */
> - hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS));
> + hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS) |
> + BIT(HCI_PINQUIRY));
And as homework for another patch, we should have a simple mask define
for persistent or non-persistent flags that is defined right next to the
enum. This will otherwise get out of control.
>
> hdev->discovery.state = DISCOVERY_STOPPED;
> }
Other than the flag name change, this looks fine.
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC 3/4] Bluetooth: Check HCI_PINQUIRY in start_discovery
2012-03-20 2:32 ` [RFC 3/4] Bluetooth: Check HCI_PINQUIRY in start_discovery Andre Guedes
@ 2012-03-20 15:54 ` Marcel Holtmann
0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2012-03-20 15:54 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth, andre.guedes
Hi Andre,
> This patch adds a HCI_PINQUIRY check to start_discovery. If
> periodic inquiry is enabled, we fail MGMT Start Discovery
> command with MGMT_STATUS_BUSY code.
>
> Signed-off-by: Andre Guedes <aguedespe@gmail.com>
> ---
> net/bluetooth/mgmt.c | 6 ++++++
> 1 file changed, 6 insertions(+)
besides the pending flag name change, this is fine as well.
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC 4/4] Bluetooth: Ignore inquiry results from periodic inquiry
2012-03-20 2:32 ` [RFC 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
@ 2012-03-20 15:55 ` Marcel Holtmann
0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2012-03-20 15:55 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth, andre.guedes
Hi Andre,
> This patch changes inquiry result function handlers so they ignore
> inquiry result events if periodic inquiry is enabled.
>
> Signed-off-by: Andre Guedes <aguedespe@gmail.com>
> ---
> net/bluetooth/hci_event.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
also flag name change here as well please.
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags
2012-03-20 15:53 ` Marcel Holtmann
@ 2012-03-21 2:21 ` Andre Guedes
0 siblings, 0 replies; 10+ messages in thread
From: Andre Guedes @ 2012-03-21 2:21 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth, andre.guedes
Hi Marcel,
On Tue, Mar 20, 2012 at 12:53 PM, Marcel Holtmann <marcel@holtmann.org> wro=
te:
> Hi Andre,
>
>> This patch adds the HCI_PINQUIRY flag to dev_flags. This flag tracks
>> if periodic inquiry is enabled or not.
>>
>> Signed-off-by: Andre Guedes <aguedespe@gmail.com>
>> ---
>> =A0include/net/bluetooth/hci.h | =A0 =A01 +
>> =A0net/bluetooth/hci_event.c =A0 | =A0 10 +++++++++-
>> =A02 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index d74645e..b3e89bf 100644
>> --- a/include/net/bluetooth/hci.h
>> +++ b/include/net/bluetooth/hci.h
>> @@ -102,6 +102,7 @@ enum {
>> =A0 =A0 =A0 HCI_DISCOVERABLE,
>> =A0 =A0 =A0 HCI_LINK_SECURITY,
>> =A0 =A0 =A0 HCI_PENDING_CLASS,
>> + =A0 =A0 HCI_PINQUIRY,
>
> call this HCI_PERIODIC_INQ. Since PINQUIRY is horrible to distinguish
> from INQUIRY.
Ok, I'll rename it.
>> =A0};
>>
>> =A0/* HCI ioctl defines */
>> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
>> index af0c5a2..4d13843 100644
>> --- a/net/bluetooth/hci_event.c
>> +++ b/net/bluetooth/hci_event.c
>> @@ -75,6 +75,11 @@ static void hci_cc_periodic_inq(struct hci_dev *hdev,=
struct sk_buff *skb)
>> =A0 =A0 =A0 __u8 status =3D *((__u8 *) skb->data);
>>
>> =A0 =A0 =A0 BT_DBG("%s status 0x%x", hdev->name, status);
>> +
>> + =A0 =A0 if (status)
>> + =A0 =A0 =A0 =A0 =A0 =A0 return;
>> +
>> + =A0 =A0 set_bit(HCI_PINQUIRY, &hdev->dev_flags);
>> =A0}
>>
>> =A0static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_=
buff *skb)
>> @@ -86,6 +91,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *h=
dev, struct sk_buff *skb)
>> =A0 =A0 =A0 if (status)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 return;
>>
>> + =A0 =A0 clear_bit(HCI_PINQUIRY, &hdev->dev_flags);
>> +
>> =A0 =A0 =A0 hci_conn_check_pending(hdev);
>> =A0}
>>
>> @@ -200,7 +207,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struc=
t sk_buff *skb)
>> =A0 =A0 =A0 hci_req_complete(hdev, HCI_OP_RESET, status);
>>
>> =A0 =A0 =A0 /* Reset all non-persistent flags */
>> - =A0 =A0 hdev->dev_flags &=3D ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLAS=
S));
>> + =A0 =A0 hdev->dev_flags &=3D ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLAS=
S) |
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 BIT(HCI_PINQUIRY));
>
> And as homework for another patch, we should have a simple mask define
> for persistent or non-persistent flags that is defined right next to the
> enum. This will otherwise get out of control.
>
>>
>> =A0 =A0 =A0 hdev->discovery.state =3D DISCOVERY_STOPPED;
>> =A0}
>
> Other than the flag name change, this looks fine.
>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
I'm gonna rename the flag, fix subsequent patches and send a new
version of this series as PATCH.
BR,
Andre
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-03-21 2:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-20 2:32 [RFC 0/4] Periodic Inquiry Handling Andre Guedes
2012-03-20 2:32 ` [RFC 1/4] Bluetooth: Add Periodic Inquiry command complete handler Andre Guedes
2012-03-20 15:50 ` Marcel Holtmann
2012-03-20 2:32 ` [RFC 2/4] Bluetooth: Add HCI_PINQUIRY to dev_flags Andre Guedes
2012-03-20 15:53 ` Marcel Holtmann
2012-03-21 2:21 ` Andre Guedes
2012-03-20 2:32 ` [RFC 3/4] Bluetooth: Check HCI_PINQUIRY in start_discovery Andre Guedes
2012-03-20 15:54 ` Marcel Holtmann
2012-03-20 2:32 ` [RFC 4/4] Bluetooth: Ignore inquiry results from periodic inquiry Andre Guedes
2012-03-20 15:55 ` Marcel Holtmann
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).