10857dd3bSJohan Hedberg /* 20857dd3bSJohan Hedberg BlueZ - Bluetooth protocol stack for Linux 30857dd3bSJohan Hedberg Copyright (C) 2014 Intel Corporation 40857dd3bSJohan Hedberg 50857dd3bSJohan Hedberg This program is free software; you can redistribute it and/or modify 60857dd3bSJohan Hedberg it under the terms of the GNU General Public License version 2 as 70857dd3bSJohan Hedberg published by the Free Software Foundation; 80857dd3bSJohan Hedberg 90857dd3bSJohan Hedberg THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 100857dd3bSJohan Hedberg OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 110857dd3bSJohan Hedberg FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 120857dd3bSJohan Hedberg IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 130857dd3bSJohan Hedberg CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 140857dd3bSJohan Hedberg WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 150857dd3bSJohan Hedberg ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 160857dd3bSJohan Hedberg OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 170857dd3bSJohan Hedberg 180857dd3bSJohan Hedberg ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 190857dd3bSJohan Hedberg COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 200857dd3bSJohan Hedberg SOFTWARE IS DISCLAIMED. 210857dd3bSJohan Hedberg */ 220857dd3bSJohan Hedberg 231b422066SMichał Narajowski #include <asm/unaligned.h> 241b422066SMichał Narajowski 25*161510ccSLuiz Augusto von Dentz #define HCI_REQ_DONE 0 26*161510ccSLuiz Augusto von Dentz #define HCI_REQ_PEND 1 27*161510ccSLuiz Augusto von Dentz #define HCI_REQ_CANCELED 2 28*161510ccSLuiz Augusto von Dentz 29b504430cSJohan Hedberg #define hci_req_sync_lock(hdev) mutex_lock(&hdev->req_lock) 30b504430cSJohan Hedberg #define hci_req_sync_unlock(hdev) mutex_unlock(&hdev->req_lock) 31be91cd05SJohan Hedberg 326a98e383SMarcel Holtmann #define HCI_REQ_DONE 0 336a98e383SMarcel Holtmann #define HCI_REQ_PEND 1 346a98e383SMarcel Holtmann #define HCI_REQ_CANCELED 2 356a98e383SMarcel Holtmann 360857dd3bSJohan Hedberg struct hci_request { 370857dd3bSJohan Hedberg struct hci_dev *hdev; 380857dd3bSJohan Hedberg struct sk_buff_head cmd_q; 390857dd3bSJohan Hedberg 400857dd3bSJohan Hedberg /* If something goes wrong when building the HCI request, the error 410857dd3bSJohan Hedberg * value is stored in this field. 420857dd3bSJohan Hedberg */ 430857dd3bSJohan Hedberg int err; 440857dd3bSJohan Hedberg }; 450857dd3bSJohan Hedberg 460857dd3bSJohan Hedberg void hci_req_init(struct hci_request *req, struct hci_dev *hdev); 47f17d858eSJaganath Kanakkassery void hci_req_purge(struct hci_request *req); 48f80c5dadSJoão Paulo Rechi Vita bool hci_req_status_pend(struct hci_dev *hdev); 490857dd3bSJohan Hedberg int hci_req_run(struct hci_request *req, hci_req_complete_t complete); 50e6214487SJohan Hedberg int hci_req_run_skb(struct hci_request *req, hci_req_complete_skb_t complete); 51*161510ccSLuiz Augusto von Dentz void hci_req_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode, 52*161510ccSLuiz Augusto von Dentz struct sk_buff *skb); 530857dd3bSJohan Hedberg void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, 540857dd3bSJohan Hedberg const void *param); 550857dd3bSJohan Hedberg void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, 560857dd3bSJohan Hedberg const void *param, u8 event); 57e6214487SJohan Hedberg void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status, 58e6214487SJohan Hedberg hci_req_complete_t *req_complete, 59e6214487SJohan Hedberg hci_req_complete_skb_t *req_complete_skb); 600857dd3bSJohan Hedberg 61a1d01db1SJohan Hedberg int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req, 62be91cd05SJohan Hedberg unsigned long opt), 634ebeee2dSJohan Hedberg unsigned long opt, u32 timeout, u8 *hci_status); 64a1d01db1SJohan Hedberg int __hci_req_sync(struct hci_dev *hdev, int (*func)(struct hci_request *req, 65be91cd05SJohan Hedberg unsigned long opt), 664ebeee2dSJohan Hedberg unsigned long opt, u32 timeout, u8 *hci_status); 67be91cd05SJohan Hedberg 680857dd3bSJohan Hedberg struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode, u32 plen, 690857dd3bSJohan Hedberg const void *param); 700857dd3bSJohan Hedberg 715c49bcceSSathish Narasimman void hci_req_add_le_scan_disable(struct hci_request *req, bool rpa_le_conn); 720857dd3bSJohan Hedberg void hci_req_add_le_passive_scan(struct hci_request *req); 730857dd3bSJohan Hedberg 745fc16cc4SJohan Hedberg void hci_request_setup(struct hci_dev *hdev); 755fc16cc4SJohan Hedberg void hci_request_cancel_all(struct hci_dev *hdev); 76