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 86a98e383SMarcel Holtmann typedef int (*hci_cmd_sync_work_func_t)(struct hci_dev *hdev, void *data); 96a98e383SMarcel Holtmann typedef void (*hci_cmd_sync_work_destroy_t)(struct hci_dev *hdev, void *data, 106a98e383SMarcel Holtmann int err); 116a98e383SMarcel Holtmann 126a98e383SMarcel Holtmann struct hci_cmd_sync_work_entry { 136a98e383SMarcel Holtmann struct list_head list; 146a98e383SMarcel Holtmann hci_cmd_sync_work_func_t func; 156a98e383SMarcel Holtmann void *data; 166a98e383SMarcel Holtmann hci_cmd_sync_work_destroy_t destroy; 176a98e383SMarcel Holtmann }; 186a98e383SMarcel Holtmann 196a98e383SMarcel Holtmann /* Function with sync suffix shall not be called with hdev->lock held as they 206a98e383SMarcel Holtmann * wait the command to complete and in the meantime an event could be received 216a98e383SMarcel Holtmann * which could attempt to acquire hdev->lock causing a deadlock. 226a98e383SMarcel Holtmann */ 236a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 246a98e383SMarcel Holtmann const void *param, u32 timeout); 256a98e383SMarcel Holtmann struct sk_buff *hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, 266a98e383SMarcel Holtmann const void *param, u32 timeout); 276a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, 286a98e383SMarcel Holtmann const void *param, u8 event, u32 timeout); 296a98e383SMarcel Holtmann struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, 306a98e383SMarcel Holtmann const void *param, u8 event, u32 timeout, 316a98e383SMarcel Holtmann struct sock *sk); 326a98e383SMarcel Holtmann int __hci_cmd_sync_status(struct hci_dev *hdev, u16 opcode, u32 plen, 336a98e383SMarcel Holtmann const void *param, u32 timeout); 346a98e383SMarcel Holtmann int __hci_cmd_sync_status_sk(struct hci_dev *hdev, u16 opcode, u32 plen, 356a98e383SMarcel Holtmann const void *param, u8 event, u32 timeout, 366a98e383SMarcel Holtmann struct sock *sk); 376a98e383SMarcel Holtmann 386a98e383SMarcel Holtmann void hci_cmd_sync_init(struct hci_dev *hdev); 396a98e383SMarcel Holtmann void hci_cmd_sync_clear(struct hci_dev *hdev); 40914b08b3SBenjamin Berg void hci_cmd_sync_cancel(struct hci_dev *hdev, int err); 41744451c1SBenjamin Berg void __hci_cmd_sync_cancel(struct hci_dev *hdev, int err); 426a98e383SMarcel Holtmann 436a98e383SMarcel Holtmann int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, 446a98e383SMarcel Holtmann void *data, hci_cmd_sync_work_destroy_t destroy); 45161510ccSLuiz Augusto von Dentz 46161510ccSLuiz Augusto von Dentz int hci_update_eir_sync(struct hci_dev *hdev); 47161510ccSLuiz Augusto von Dentz int hci_update_class_sync(struct hci_dev *hdev); 48cba6b758SLuiz Augusto von Dentz 49cba6b758SLuiz Augusto von Dentz int hci_update_eir_sync(struct hci_dev *hdev); 50cba6b758SLuiz Augusto von Dentz int hci_update_class_sync(struct hci_dev *hdev); 516f6ff38aSBrian Gix int hci_update_name_sync(struct hci_dev *hdev); 523244845cSBrian Gix int hci_write_ssp_mode_sync(struct hci_dev *hdev, u8 mode); 53cba6b758SLuiz Augusto von Dentz 54cba6b758SLuiz Augusto von Dentz int hci_update_random_address_sync(struct hci_dev *hdev, bool require_privacy, 55cba6b758SLuiz Augusto von Dentz bool rpa, u8 *own_addr_type); 56cba6b758SLuiz Augusto von Dentz 57cba6b758SLuiz Augusto von Dentz int hci_update_scan_rsp_data_sync(struct hci_dev *hdev, u8 instance); 58cba6b758SLuiz Augusto von Dentz int hci_update_adv_data_sync(struct hci_dev *hdev, u8 instance); 59cba6b758SLuiz Augusto von Dentz int hci_schedule_adv_instance_sync(struct hci_dev *hdev, u8 instance, 60cba6b758SLuiz Augusto von Dentz bool force); 61cba6b758SLuiz Augusto von Dentz 62cba6b758SLuiz Augusto von Dentz int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance); 63cba6b758SLuiz Augusto von Dentz int hci_start_ext_adv_sync(struct hci_dev *hdev, u8 instance); 64cba6b758SLuiz Augusto von Dentz int hci_enable_ext_advertising_sync(struct hci_dev *hdev, u8 instance); 65cba6b758SLuiz Augusto von Dentz int hci_enable_advertising_sync(struct hci_dev *hdev); 66abfeea47SLuiz Augusto von Dentz int hci_enable_advertising(struct hci_dev *hdev); 67cba6b758SLuiz Augusto von Dentz 68eca0ae4aSLuiz Augusto von Dentz int hci_start_per_adv_sync(struct hci_dev *hdev, u8 instance, u8 data_len, 69eca0ae4aSLuiz Augusto von Dentz u8 *data, u32 flags, u16 min_interval, 70eca0ae4aSLuiz Augusto von Dentz u16 max_interval, u16 sync_interval); 71eca0ae4aSLuiz Augusto von Dentz 72cba6b758SLuiz Augusto von Dentz int hci_remove_advertising_sync(struct hci_dev *hdev, struct sock *sk, 73cba6b758SLuiz Augusto von Dentz u8 instance, bool force); 74cba6b758SLuiz Augusto von Dentz int hci_disable_advertising_sync(struct hci_dev *hdev); 75*c249ea9bSBrian Gix int hci_clear_adv_instance_sync(struct hci_dev *hdev, struct sock *sk, 76*c249ea9bSBrian Gix u8 instance, bool force); 77e8907f76SLuiz Augusto von Dentz int hci_update_passive_scan_sync(struct hci_dev *hdev); 78ad383c2cSLuiz Augusto von Dentz int hci_update_passive_scan(struct hci_dev *hdev); 7947db6b42SBrian Gix int hci_read_rssi_sync(struct hci_dev *hdev, __le16 handle); 8047db6b42SBrian Gix int hci_read_tx_power_sync(struct hci_dev *hdev, __le16 handle, u8 type); 812f2eb0c9SBrian Gix int hci_write_sc_support_sync(struct hci_dev *hdev, u8 val); 825a750137SBrian Gix int hci_read_clock_sync(struct hci_dev *hdev, struct hci_cp_read_clock *cp); 83cf75ad8bSLuiz Augusto von Dentz 84353a0249SBrian Gix int hci_write_fast_connectable_sync(struct hci_dev *hdev, bool enable); 85451d95a9SBrian Gix int hci_update_scan_sync(struct hci_dev *hdev); 86bb876725SBrian Gix int hci_update_scan(struct hci_dev *hdev); 87353a0249SBrian Gix 88d81a494cSBrian Gix int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul); 89d81a494cSBrian Gix int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance, 90d81a494cSBrian Gix struct sock *sk); 91eca0ae4aSLuiz Augusto von Dentz int hci_remove_ext_adv_instance(struct hci_dev *hdev, u8 instance); 92f892244bSBrian Gix struct sk_buff *hci_read_local_oob_data_sync(struct hci_dev *hdev, bool ext, 93f892244bSBrian Gix struct sock *sk); 94d81a494cSBrian Gix 95d0b13706SLuiz Augusto von Dentz int hci_reset_sync(struct hci_dev *hdev); 96cf75ad8bSLuiz Augusto von Dentz int hci_dev_open_sync(struct hci_dev *hdev); 97cf75ad8bSLuiz Augusto von Dentz int hci_dev_close_sync(struct hci_dev *hdev); 98cf75ad8bSLuiz Augusto von Dentz 99cf75ad8bSLuiz Augusto von Dentz int hci_powered_update_sync(struct hci_dev *hdev); 100cf75ad8bSLuiz Augusto von Dentz int hci_set_powered_sync(struct hci_dev *hdev, u8 val); 101abfeea47SLuiz Augusto von Dentz 1022bd1b237SLuiz Augusto von Dentz int hci_update_discoverable_sync(struct hci_dev *hdev); 1032bd1b237SLuiz Augusto von Dentz int hci_update_discoverable(struct hci_dev *hdev); 1042bd1b237SLuiz Augusto von Dentz 105f056a657SLuiz Augusto von Dentz int hci_update_connectable_sync(struct hci_dev *hdev); 106f056a657SLuiz Augusto von Dentz 107abfeea47SLuiz Augusto von Dentz int hci_start_discovery_sync(struct hci_dev *hdev); 108abfeea47SLuiz Augusto von Dentz int hci_stop_discovery_sync(struct hci_dev *hdev); 109182ee45dSLuiz Augusto von Dentz 110182ee45dSLuiz Augusto von Dentz int hci_suspend_sync(struct hci_dev *hdev); 111182ee45dSLuiz Augusto von Dentz int hci_resume_sync(struct hci_dev *hdev); 1128e8b92eeSLuiz Augusto von Dentz 1138e8b92eeSLuiz Augusto von Dentz struct hci_conn; 1148e8b92eeSLuiz Augusto von Dentz 1151f7435c8SLuiz Augusto von Dentz int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason); 1161f7435c8SLuiz Augusto von Dentz 1178e8b92eeSLuiz Augusto von Dentz int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn); 11826afbd82SLuiz Augusto von Dentz 11926afbd82SLuiz Augusto von Dentz int hci_le_remove_cig_sync(struct hci_dev *hdev, u8 handle); 120eca0ae4aSLuiz Augusto von Dentz 121eca0ae4aSLuiz Augusto von Dentz int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason); 122eca0ae4aSLuiz Augusto von Dentz 123eca0ae4aSLuiz Augusto von Dentz int hci_le_big_terminate_sync(struct hci_dev *hdev, u8 handle); 124eca0ae4aSLuiz Augusto von Dentz 125eca0ae4aSLuiz Augusto von Dentz int hci_le_pa_terminate_sync(struct hci_dev *hdev, u16 handle); 126