xref: /openbmc/linux/include/net/bluetooth/hci_sync.h (revision ca2478a7d974f38d29d27acb42a952c7f168916e)
16a98e383SMarcel Holtmann /* SPDX-License-Identifier: GPL-2.0 */
26a98e383SMarcel Holtmann /*
36a98e383SMarcel Holtmann  * BlueZ - Bluetooth protocol stack for Linux
46a98e383SMarcel Holtmann  *
56a98e383SMarcel Holtmann  * Copyright (C) 2021 Intel Corporation
66a98e383SMarcel Holtmann  */
76a98e383SMarcel Holtmann 
8a1f6c3aeSLuiz Augusto von Dentz #define UINT_PTR(_handle)		((void *)((uintptr_t)_handle))
9a1f6c3aeSLuiz Augusto von Dentz #define PTR_UINT(_ptr)			((uintptr_t)((void *)_ptr))
10a1f6c3aeSLuiz Augusto von Dentz 
116a98e383SMarcel Holtmann typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data);
126a98e383SMarcel Holtmann typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data,
136a98e383SMarcel Holtmann 					    int err);
146a98e383SMarcel Holtmann 
156a98e383SMarcel Holtmann struct hci_cmd_sync_work_entry {
166a98e383SMarcel Holtmann 	struct list_head list;
176a98e383SMarcel Holtmann 	hci_cmd_sync_work_func_t func;
186a98e383SMarcel Holtmann 	void *data;
196a98e383SMarcel Holtmann 	hci_cmd_sync_work_destroy_t destroy;
206a98e383SMarcel Holtmann };
216a98e383SMarcel Holtmann 
223fe318eeSBrian Gix struct adv_info;
236a98e383SMarcel Holtmann /* Function with sync suffix shall not be called with hdev->lock held as they
246a98e383SMarcel Holtmann  * wait the command to complete and in the meantime an event could be received
256a98e383SMarcel Holtmann  * which could attempt to acquire hdev->lock causing a deadlock.
266a98e383SMarcel Holtmann  */
276a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
286a98e383SMarcel Holtmann 			       const void *param, u32 timeout);
296a98e383SMarcel Holtmann struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen,
306a98e383SMarcel Holtmann 			     const void *param, u32 timeout);
316a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
326a98e383SMarcel Holtmann 				  const void *param, u8 event, u32 timeout);
336a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
346a98e383SMarcel Holtmann 				  const void *param, u8 event, u32 timeout,
356a98e383SMarcel Holtmann 				  struct sock *sk);
366a98e383SMarcel Holtmann int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen,
376a98e383SMarcel Holtmann 			  const void *param, u32 timeout);
386a98e383SMarcel Holtmann int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen,
396a98e383SMarcel Holtmann 			     const void *param, u8 event, u32 timeout,
406a98e383SMarcel Holtmann 			     struct sock *sk);
41b0fc1bd2SLuiz Augusto von Dentz int hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen,
42b0fc1bd2SLuiz Augusto von Dentz 			const void *param, u32 timeout);
436a98e383SMarcel Holtmann 
446a98e383SMarcel Holtmann void hci_cmd_sync_init(struct hci_dev *hdev);
456a98e383SMarcel Holtmann void hci_cmd_sync_clear(struct hci_dev *hdev);
46914b08b3SBenjamin Berg void hci_cmd_sync_cancel(struct hci_dev *hdev, int err);
470ce1229cSLuiz Augusto von Dentz void hci_cmd_sync_cancel_sync(struct hci_dev *hdev, int err);
486a98e383SMarcel Holtmann 
49d883a466SLuiz Augusto von Dentz int hci_cmd_sync_submit(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
50d883a466SLuiz Augusto von Dentz 			void *data, hci_cmd_sync_work_destroy_t destroy);
516a98e383SMarcel Holtmann int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
526a98e383SMarcel Holtmann 		       void *data, hci_cmd_sync_work_destroy_t destroy);
53d948e1ffSLuiz Augusto von Dentz int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
54d948e1ffSLuiz Augusto von Dentz 			    void *data, hci_cmd_sync_work_destroy_t destroy);
55*d56412eeSLuiz Augusto von Dentz int hci_cmd_sync_run(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
56*d56412eeSLuiz Augusto von Dentz 		     void *data, hci_cmd_sync_work_destroy_t destroy);
57*d56412eeSLuiz Augusto von Dentz int hci_cmd_sync_run_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
58*d56412eeSLuiz Augusto von Dentz 			  void *data, hci_cmd_sync_work_destroy_t destroy);
591499f799SLuiz Augusto von Dentz struct hci_cmd_sync_work_entry *
601499f799SLuiz Augusto von Dentz hci_cmd_sync_lookup_entry(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
611499f799SLuiz Augusto von Dentz 			  void *data, hci_cmd_sync_work_destroy_t destroy);
621499f799SLuiz Augusto von Dentz void hci_cmd_sync_cancel_entry(struct hci_dev *hdev,
631499f799SLuiz Augusto von Dentz 			       struct hci_cmd_sync_work_entry *entry);
641499f799SLuiz Augusto von Dentz bool hci_cmd_sync_dequeue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
651499f799SLuiz Augusto von Dentz 			  void *data, hci_cmd_sync_work_destroy_t destroy);
661499f799SLuiz Augusto von Dentz bool hci_cmd_sync_dequeue_once(struct hci_dev *hdev,
671499f799SLuiz Augusto von Dentz 			      hci_cmd_sync_work_func_t func, void *data,
681499f799SLuiz Augusto von Dentz 			      hci_cmd_sync_work_destroy_t destroy);
69161510ccSLuiz Augusto von Dentz 
70161510ccSLuiz Augusto von Dentz int hci_update_eir_sync(struct hci_dev *hdev);
71161510ccSLuiz Augusto von Dentz int hci_update_class_sync(struct hci_dev *hdev);
72cba6b758SLuiz Augusto von Dentz 
73cba6b758SLuiz Augusto von Dentz int hci_update_eir_sync(struct hci_dev *hdev);
74cba6b758SLuiz Augusto von Dentz int hci_update_class_sync(struct hci_dev *hdev);
756f6ff38aSBrian Gix int hci_update_name_sync(struct hci_dev *hdev);
763244845cSBrian Gix int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode);
77cba6b758SLuiz Augusto von Dentz 
783fe318eeSBrian Gix int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
793fe318eeSBrian Gix 			   bool use_rpa, struct adv_info *adv_instance,
803fe318eeSBrian Gix 			   u8 *own_addr_type, bdaddr_t *rand_addr);
813fe318eeSBrian Gix 
82cba6b758SLuiz Augusto von Dentz int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy,
83cba6b758SLuiz Augusto von Dentz 				   bool rpa, u8 *own_addr_type);
84cba6b758SLuiz Augusto von Dentz 
85cba6b758SLuiz Augusto von Dentz int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance);
86cba6b758SLuiz Augusto von Dentz int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance);
87651cd3d6SBrian Gix int hci_update_adv_data(struct hci_dev *hdev, u8 instance);
88cba6b758SLuiz Augusto von Dentz int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance,
89cba6b758SLuiz Augusto von Dentz 				   bool force);
90cba6b758SLuiz Augusto von Dentz 
91cba6b758SLuiz Augusto von Dentz int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance);
92cba6b758SLuiz Augusto von Dentz int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance);
93cba6b758SLuiz Augusto von Dentz int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance);
94cba6b758SLuiz Augusto von Dentz int hci_enable_advertising_sync(struct hci_dev *hdev);
95abfeea47SLuiz Augusto von Dentz int hci_enable_advertising(struct hci_dev *hdev);
96cba6b758SLuiz Augusto von Dentz 
97eca0ae4aSLuiz Augusto von Dentz int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len,
98eca0ae4aSLuiz Augusto von Dentz 			   u8 *data, u32 flags, u16 min_interval,
99eca0ae4aSLuiz Augusto von Dentz 			   u16 max_interval, u16 sync_interval);
100eca0ae4aSLuiz Augusto von Dentz 
101f03d3322SIulia Tanasescu int hci_disable_per_advertising_sync(struct hci_dev *hdev, u8 instance);
102f03d3322SIulia Tanasescu 
103cba6b758SLuiz Augusto von Dentz int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk,
104cba6b758SLuiz Augusto von Dentz 				u8 instance, bool force);
105cba6b758SLuiz Augusto von Dentz int hci_disable_advertising_sync(struct hci_dev *hdev);
106c249ea9bSBrian Gix int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk,
107c249ea9bSBrian Gix 				u8 instance, bool force);
108e8907f76SLuiz Augusto von Dentz int hci_update_passive_scan_sync(struct hci_dev *hdev);
109ad383c2cSLuiz Augusto von Dentz int hci_update_passive_scan(struct hci_dev *hdev);
11047db6b42SBrian Gix int hci_read_rssi_sync(struct hci_dev *hdev, __le16 handle);
11147db6b42SBrian Gix int hci_read_tx_power_sync(struct hci_dev *hdev, __le16 handle, u8 type);
1122f2eb0c9SBrian Gix int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val);
1135a750137SBrian Gix int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp);
114cf75ad8bSLuiz Augusto von Dentz 
115353a0249SBrian Gix int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable);
116451d95a9SBrian Gix int hci_update_scan_sync(struct hci_dev *hdev);
117bb876725SBrian Gix int hci_update_scan(struct hci_dev *hdev);
118353a0249SBrian Gix 
119d81a494cSBrian Gix int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul);
120d81a494cSBrian Gix int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance,
121d81a494cSBrian Gix 				     struct sock *sk);
122eca0ae4aSLuiz Augusto von Dentz int hci_remove_ext_adv_instance(struct hci_dev *hdev, u8 instance);
123f892244bSBrian Gix struct sk_buff *hci_read_local_oob_data_sync(struct hci_dev *hdev, bool ext,
124f892244bSBrian Gix 					     struct sock *sk);
125d81a494cSBrian Gix 
126d0b13706SLuiz Augusto von Dentz int hci_reset_sync(struct hci_dev *hdev);
127cf75ad8bSLuiz Augusto von Dentz int hci_dev_open_sync(struct hci_dev *hdev);
128cf75ad8bSLuiz Augusto von Dentz int hci_dev_close_sync(struct hci_dev *hdev);
129cf75ad8bSLuiz Augusto von Dentz 
130cf75ad8bSLuiz Augusto von Dentz int hci_powered_update_sync(struct hci_dev *hdev);
131cf75ad8bSLuiz Augusto von Dentz int hci_set_powered_sync(struct hci_dev *hdev, u8 val);
132abfeea47SLuiz Augusto von Dentz 
1332bd1b237SLuiz Augusto von Dentz int hci_update_discoverable_sync(struct hci_dev *hdev);
1342bd1b237SLuiz Augusto von Dentz int hci_update_discoverable(struct hci_dev *hdev);
1352bd1b237SLuiz Augusto von Dentz 
136f056a657SLuiz Augusto von Dentz int hci_update_connectable_sync(struct hci_dev *hdev);
137f056a657SLuiz Augusto von Dentz 
138abfeea47SLuiz Augusto von Dentz int hci_start_discovery_sync(struct hci_dev *hdev);
139abfeea47SLuiz Augusto von Dentz int hci_stop_discovery_sync(struct hci_dev *hdev);
140182ee45dSLuiz Augusto von Dentz 
141182ee45dSLuiz Augusto von Dentz int hci_suspend_sync(struct hci_dev *hdev);
142182ee45dSLuiz Augusto von Dentz int hci_resume_sync(struct hci_dev *hdev);
1438e8b92eeSLuiz Augusto von Dentz 
1448e8b92eeSLuiz Augusto von Dentz struct hci_conn;
1458e8b92eeSLuiz Augusto von Dentz 
1461f7435c8SLuiz Augusto von Dentz int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason);
1471f7435c8SLuiz Augusto von Dentz 
1487f74563eSPauli Virtanen int hci_le_create_cis_sync(struct hci_dev *hdev);
149c09b80beSLuiz Augusto von Dentz 
15026afbd82SLuiz Augusto von Dentz int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle);
151eca0ae4aSLuiz Augusto von Dentz 
152eca0ae4aSLuiz Augusto von Dentz int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason);
153eca0ae4aSLuiz Augusto von Dentz 
154eca0ae4aSLuiz Augusto von Dentz int hci_le_big_terminate_sync(struct hci_dev *hdev, u8 handle);
155eca0ae4aSLuiz Augusto von Dentz 
156eca0ae4aSLuiz Augusto von Dentz int hci_le_pa_terminate_sync(struct hci_dev *hdev, u16 handle);
157c57edb54SJonas Dreßler 
15898f66ea4SLuiz Augusto von Dentz int hci_connect_acl_sync(struct hci_dev *hdev, struct hci_conn *conn);
159d948e1ffSLuiz Augusto von Dentz 
160d948e1ffSLuiz Augusto von Dentz int hci_connect_le_sync(struct hci_dev *hdev, struct hci_conn *conn);
161d948e1ffSLuiz Augusto von Dentz 
162d948e1ffSLuiz Augusto von Dentz int hci_cancel_connect_sync(struct hci_dev *hdev, struct hci_conn *conn);
163