Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * BlueZ - Bluetooth protocol stack for Linux
4 *
5 * Copyright (C) 2021 Intel Corporation
6 */
7
8#define UINT_PTR(_handle) ((void *)((uintptr_t)_handle))
9#define PTR_UINT(_ptr) ((uintptr_t)((void *)_ptr))
10
11#define HCI_REQ_DONE 0
12#define HCI_REQ_PEND 1
13#define HCI_REQ_CANCELED 2
14
15#define hci_req_sync_lock(hdev) mutex_lock(&hdev->req_lock)
16#define hci_req_sync_unlock(hdev) mutex_unlock(&hdev->req_lock)
17
18struct hci_request {
19 struct hci_dev *hdev;
20 struct sk_buff_head cmd_q;
21
22 /* If something goes wrong when building the HCI request, the error
23 * value is stored in this field.
24 */
25 int err;
26};
27
28typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data);
29typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data,
30 int err);
31
32struct hci_cmd_sync_work_entry {
33 struct list_head list;
34 hci_cmd_sync_work_func_t func;
35 void *data;
36 hci_cmd_sync_work_destroy_t destroy;
37};
38
39struct adv_info;
40
41struct sk_buff *hci_cmd_sync_alloc(struct hci_dev *hdev, u16 opcode, u32 plen,
42 const void *param, struct sock *sk);
43
44/* Function with sync suffix shall not be called with hdev->lock held as they
45 * wait the command to complete and in the meantime an event could be received
46 * which could attempt to acquire hdev->lock causing a deadlock.
47 */
48struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
49 const void *param, u32 timeout);
50struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
51 const void *param, u32 timeout);
52struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
53 const void *param, u8 event, u32 timeout);
54struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
55 const void *param, u8 event, u32 timeout,
56 struct sock *sk);
57int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen,
58 const void *param, u32 timeout);
59int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
60 const void *param, u8 event, u32 timeout,
61 struct sock *sk);
62int hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen,
63 const void *param, u32 timeout);
64
65void hci_cmd_sync_init(struct hci_dev *hdev);
66void hci_cmd_sync_clear(struct hci_dev *hdev);
67void hci_cmd_sync_cancel(struct hci_dev *hdev, int err);
68void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err);
69
70int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
71 void *data, hci_cmd_sync_work_destroy_t destroy);
72int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
73 void *data, hci_cmd_sync_work_destroy_t destroy);
74int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
75 void *data, hci_cmd_sync_work_destroy_t destroy);
76struct hci_cmd_sync_work_entry *
77hci_cmd_sync_lookup_entry(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
78 void *data, hci_cmd_sync_work_destroy_t destroy);
79void hci_cmd_sync_cancel_entry(struct hci_dev *hdev,
80 struct hci_cmd_sync_work_entry *entry);
81bool hci_cmd_sync_dequeue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
82 void *data, hci_cmd_sync_work_destroy_t destroy);
83bool hci_cmd_sync_dequeue_once(struct hci_dev *hdev,
84 hci_cmd_sync_work_func_t func, void *data,
85 hci_cmd_sync_work_destroy_t destroy);
86
87int hci_update_eir_sync(struct hci_dev *hdev);
88int hci_update_class_sync(struct hci_dev *hdev);
89
90int hci_update_eir_sync(struct hci_dev *hdev);
91int hci_update_class_sync(struct hci_dev *hdev);
92int hci_update_name_sync(struct hci_dev *hdev);
93int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode);
94
95int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
96 bool use_rpa, struct adv_info *adv_instance,
97 u8 *own_addr_type, bdaddr_t *rand_addr);
98
99int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
100 bool rpa, u8 *own_addr_type);
101
102int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance);
103int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance);
104int hci_update_adv_data(struct hci_dev *hdev, u8 instance);
105int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
106 bool force);
107
108int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance);
109int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance);
110int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance);
111int hci_enable_advertising_sync(struct hci_dev *hdev);
112int hci_enable_advertising(struct hci_dev *hdev);
113
114int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len,
115 u8 *data, u32 flags, u16 min_interval,
116 u16 max_interval, u16 sync_interval);
117
118int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);
119
120int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
121 u8 instance, bool force);
122int hci_disable_advertising_sync(struct hci_dev *hdev);
123int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
124 u8 instance, bool force);
125int hci_update_passive_scan_sync(struct hci_dev *hdev);
126int hci_update_passive_scan(struct hci_dev *hdev);
127int hci_read_rssi_sync(struct hci_dev *hdev, __le16 handle);
128int hci_read_tx_power_sync(struct hci_dev *hdev, __le16 handle, u8 type);
129int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val);
130int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp);
131
132int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable);
133int hci_update_scan_sync(struct hci_dev *hdev);
134int hci_update_scan(struct hci_dev *hdev);
135
136int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul);
137int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance,
138 struct sock *sk);
139int hci_remove_ext_adv_instance(struct hci_dev *hdev, u8 instance);
140struct sk_buff *hci_read_local_oob_data_sync(struct hci_dev *hdev, bool ext,
141 struct sock *sk);
142
143int hci_reset_sync(struct hci_dev *hdev);
144int hci_dev_open_sync(struct hci_dev *hdev);
145int hci_dev_close_sync(struct hci_dev *hdev);
146
147int hci_powered_update_sync(struct hci_dev *hdev);
148int hci_set_powered_sync(struct hci_dev *hdev, u8 val);
149
150int hci_update_discoverable_sync(struct hci_dev *hdev);
151int hci_update_discoverable(struct hci_dev *hdev);
152
153int hci_update_connectable_sync(struct hci_dev *hdev);
154
155int hci_inquiry_sync(struct hci_dev *hdev, u8 length, u8 num_rsp);
156
157int hci_start_discovery_sync(struct hci_dev *hdev);
158int hci_stop_discovery_sync(struct hci_dev *hdev);
159
160int hci_suspend_sync(struct hci_dev *hdev);
161int hci_resume_sync(struct hci_dev *hdev);
162
163struct hci_conn;
164struct hci_conn_params;
165
166int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason);
167
168int hci_le_create_cis_sync(struct hci_dev *hdev);
169
170int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle);
171
172int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason);
173
174int hci_le_big_terminate_sync(struct hci_dev *hdev, u8 handle);
175
176int hci_le_pa_terminate_sync(struct hci_dev *hdev, u16 handle);
177
178int hci_connect_acl_sync(struct hci_dev *hdev, struct hci_conn *conn);
179
180int hci_connect_le_sync(struct hci_dev *hdev, struct hci_conn *conn);
181
182int hci_cancel_connect_sync(struct hci_dev *hdev, struct hci_conn *conn);
183int hci_le_conn_update_sync(struct hci_dev *hdev, struct hci_conn *conn,
184 struct hci_conn_params *params);