From: Marcel Holtmann <marcel@holtmann.org>
To: Andre Guedes <andre.guedes@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2 5/9] Bluetooth: LE scan infra-structure
Date: Mon, 28 Nov 2011 17:24:02 +0100 [thread overview]
Message-ID: <1322497442.29909.36.camel@aeonflux> (raw)
In-Reply-To: <1322265226-6404-6-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
> This patch does the proper init of the structs required to carry
> out LE scan and implement the LE scan work.
>
> The LE scan work sends the commands (Set LE Scan Parameters and Set
> LE Scan Enable) to the controller in order to start LE scanning. If
> commands were executed successfully the le_scan_timer is set to
> disable the ongoing scanning after some amount of time.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> include/net/bluetooth/hci.h | 1 +
> net/bluetooth/hci_core.c | 38 ++++++++++++++++++++++++++++++++++++++
> net/bluetooth/hci_event.c | 5 +++++
> 3 files changed, 44 insertions(+), 0 deletions(-)
combine patch 4 and 5 since the split is weird.
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index b7c6452..6e2b88f 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -130,6 +130,7 @@ enum {
> #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */
> #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */
> #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */
> +#define HCI_LE_SCAN_TIMEOUT (3000) /* 3 seconds */
>
> /* HCI data types */
> #define HCI_COMMAND_PKT 0x01
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 28ef2ac..8e96e3b 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -981,6 +981,33 @@ static void hci_power_on(struct work_struct *work)
> mgmt_index_added(hdev);
> }
>
> +static void le_scan_req(struct hci_dev *hdev, unsigned long opt)
> +{
> + struct le_scan_params *params = (void *) opt;
> +
> + if (test_bit(HCI_LE_SCAN, &hdev->dev_flags))
> + return;
> +
> + send_le_scan_param_cmd(hdev, params->type, params->interval,
> + params->window);
> + send_le_scan_enable_cmd(hdev, 1);
> +}
> +
> +static void hci_le_scan(struct work_struct *work)
> +{
> + struct hci_dev *hdev = container_of(work, struct hci_dev, le_scan);
> + struct le_scan_params *params = &hdev->le_scan_params;
> + int err;
> +
> + err = hci_request(hdev, le_scan_req, (unsigned long) params,
> + msecs_to_jiffies(HCI_LE_SCAN_TIMEOUT));
> + if (err < 0)
> + return;
> +
> + mod_timer(&hdev->le_scan_timer, jiffies +
> + msecs_to_jiffies(params->timeout));
> +}
> +
> static void hci_power_off(struct work_struct *work)
> {
> struct hci_dev *hdev = container_of(work, struct hci_dev,
> @@ -1447,6 +1474,13 @@ int hci_add_adv_entry(struct hci_dev *hdev,
> return 0;
> }
>
> +static void le_scan_timeout(unsigned long arg)
> +{
> + struct hci_dev *hdev = (void *) arg;
> +
> + send_le_scan_enable_cmd(hdev, 0);
> +}
> +
> /* Register HCI device */
> int hci_register_dev(struct hci_dev *hdev)
> {
> @@ -1500,6 +1534,8 @@ int hci_register_dev(struct hci_dev *hdev)
> skb_queue_head_init(&hdev->raw_q);
>
> setup_timer(&hdev->cmd_timer, hci_cmd_timer, (unsigned long) hdev);
> + setup_timer(&hdev->le_scan_timer, le_scan_timeout,
> + (unsigned long) hdev);
>
> for (i = 0; i < NUM_REASSEMBLY; i++)
> hdev->reassembly[i] = NULL;
> @@ -1526,6 +1562,7 @@ int hci_register_dev(struct hci_dev *hdev)
> (unsigned long) hdev);
>
> INIT_WORK(&hdev->power_on, hci_power_on);
> + INIT_WORK(&hdev->le_scan, hci_le_scan);
> INIT_DELAYED_WORK(&hdev->power_off, hci_power_off);
>
> INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off);
I am beginning to question how many work structs we really want here.
And more important that we need to ensure that they are scheduled from
the main workqueue that we have per HCI controller.
And while at this, we might wanna actually move away from tasklets
finally so that we actually can sleep and can reduce the number of work
structs here. I am open for ideas.
Regards
Marcel
next prev parent reply other threads:[~2011-11-28 16:24 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-25 23:53 [PATCH v2 0/9] LE-Only discovery procedure support Andre Guedes
2011-11-25 23:53 ` [PATCH v2 1/9] Bluetooth: Add dev_flags to struct hci_dev Andre Guedes
2011-11-28 16:17 ` Marcel Holtmann
2011-11-25 23:53 ` [PATCH v2 2/9] Bluetooth: LE Set Scan Parameter Command Andre Guedes
2011-11-28 16:17 ` Marcel Holtmann
2011-12-02 12:19 ` Gustavo Padovan
2011-11-25 23:53 ` [PATCH v2 3/9] Bluetooth: Add helper functions to send LE scan commands Andre Guedes
2011-11-28 16:19 ` Marcel Holtmann
2011-11-25 23:53 ` [PATCH v2 4/9] Bluetooth: Add structs to implement LE scan Andre Guedes
2011-11-25 23:53 ` [PATCH v2 5/9] Bluetooth: LE scan infra-structure Andre Guedes
2011-11-28 16:24 ` Marcel Holtmann [this message]
2011-11-30 18:11 ` Andre Guedes
2011-12-02 10:02 ` Query on Media Interface "RegisterPlayer" and Dbus signal "TrackChanged" Jaganath
2011-12-02 11:07 ` Luiz Augusto von Dentz
2011-12-05 13:03 ` sathish
2011-12-06 6:21 ` Chethan T N
2011-11-25 23:53 ` [PATCH v2 6/9] Bluetooth: Add LE scan functions to hci_core Andre Guedes
2011-11-28 16:28 ` Marcel Holtmann
2011-11-30 18:11 ` Andre Guedes
2011-11-25 23:53 ` [PATCH v2 7/9] Bluetooth: Add 'eir_len' param to mgmt_device_found() Andre Guedes
2011-11-27 6:37 ` Ganir, Chen
2011-11-28 11:08 ` Anderson Lizardo
2011-11-28 14:06 ` Andre Guedes
2011-11-25 23:53 ` [PATCH v2 8/9] Bluetooth: Report LE devices Andre Guedes
2011-11-25 23:53 ` [PATCH v2 9/9] Bluetooth: Support LE-Only discovery procedure Andre Guedes
2011-11-27 6:44 ` Ganir, Chen
2011-11-28 14:51 ` Andre Guedes
2011-11-29 9:14 ` Johan Hedberg
2011-11-30 6:43 ` Ganir, Chen
2011-11-30 11:27 ` Johan Hedberg
2011-11-30 11:38 ` Ganir, Chen
2011-11-30 11:44 ` Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322497442.29909.36.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=andre.guedes@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).