-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bluetooth: Add helper for serialized HCI command execution
The usage of __hci_cmd_sync() within the hdev->setup() callback allows for a nice and simple serialized execution of HCI commands. More importantly it allows for result processing before issueing the next command. With the current usage of hci_req_run() it is possible to batch up commands and execute them, but it is impossible to react to their results or errors. This is an attempt to generalize the hdev->setup() handling and provide a simple way of running multiple HCI commands from a single function context. There are multiple struct work that are decdicated to certain tasks already used right now. It is add a lot of bloat to hci_dev struct and extra handling code. So it might be possible to put all of these behind a common HCI command infrastructure and just execute the HCI commands from the same work context in a serialized fashion. For example updating the white list and resolving list can be done now without having to know the list size ahead of time. Also preparing for suspend or resume shouldn't require a state machine anymore. There are other tasks that should be simplified as well. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
- Loading branch information
Marcel Holtmann
committed
Oct 29, 2021
1 parent
2128939
commit 6a98e38
Showing
7 changed files
with
385 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* BlueZ - Bluetooth protocol stack for Linux | ||
* | ||
* Copyright (C) 2021 Intel Corporation | ||
*/ | ||
|
||
typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data); | ||
typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data, | ||
int err); | ||
|
||
struct hci_cmd_sync_work_entry { | ||
struct list_head list; | ||
hci_cmd_sync_work_func_t func; | ||
void *data; | ||
hci_cmd_sync_work_destroy_t destroy; | ||
}; | ||
|
||
/* Function with sync suffix shall not be called with hdev->lock held as they | ||
* wait the command to complete and in the meantime an event could be received | ||
* which could attempt to acquire hdev->lock causing a deadlock. | ||
*/ | ||
struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
const void *param, u32 timeout); | ||
struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
const void *param, u32 timeout); | ||
struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
const void *param, u8 event, u32 timeout); | ||
struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
const void *param, u8 event, u32 timeout, | ||
struct sock *sk); | ||
int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
const void *param, u32 timeout); | ||
int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
const void *param, u8 event, u32 timeout, | ||
struct sock *sk); | ||
|
||
void hci_cmd_sync_init(struct hci_dev *hdev); | ||
void hci_cmd_sync_clear(struct hci_dev *hdev); | ||
|
||
int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, | ||
void *data, hci_cmd_sync_work_destroy_t destroy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.