Bluetooth: hci_sync: Add hci_le_create_conn_sync
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/3 Bluetooth: hci_sync: Add hci_le_create_conn_sync
From: Luiz Augusto von Dentz <[email protected]>
This adds hci_le_create_conn_sync and make hci_le_connect use it instead of queueing multiple commands which may conflict with the likes of hci_update_passive_scan which uses hci_cmd_sync_queue.
--- include/net/bluetooth/hci_core.h | 1 + include/net/bluetooth/hci_sync.h | 4 + net/bluetooth/hci_conn.c | 304 ++----------------------------- net/bluetooth/hci_request.c | 50 ----- net/bluetooth/hci_request.h | 2 - net/bluetooth/hci_sync.c | 295 ++++++++++++++++++++++++++++++ 6 files changed, 315 insertions(+), 341 deletions(-)
include/net/bluetooth/hci_core.h +1 -0
@@ -646,6 +646,7 @@ struct hci_conn {__u8 init_addr_type;bdaddr_t resp_addr;__u8 resp_addr_type; +bdaddr_t direct_rpa;__u8 adv_instance;__u16 handle;__u16 state;
include/net/bluetooth/hci_sync.h +4 -0
@@ -101,3 +101,7 @@ int hci_stop_discovery_sync(struct hci_dev *hdev);int hci_suspend_sync (struct hci_dev *hdev);int hci_resume_sync (struct hci_dev *hdev); + +struct hci_conn ; + +int hci_le_create_conn_sync (struct hci_dev *hdev,struct hci_conn *conn);
net/bluetooth/hci_conn.c +15 -289
350 lines not on this page · raw message
net/bluetooth/hci_request.c +0 -50
56 lines not on this page · raw message
net/bluetooth/hci_request.h +0 -2
@@ -80,8 +80,6 @@ void hci_req_add_le_passive_scan(struct hci_request *req);void hci_req_prepare_suspend (struct hci_dev *hdev,enum suspended_state next);void hci_req_disable_address_resolution (struct hci_dev *hdev); -void __hci_req_pause_adv_instances (struct hci_request *req); -int hci_req_resume_adv_instances (struct hci_dev *hdev);void hci_req_reenable_advertising (struct hci_dev *hdev);void __hci_req_enable_advertising (struct hci_request *req);void __hci_req_disable_advertising (struct hci_request *req);
net/bluetooth/hci_sync.c +295 -0
298 lines not on this page · raw message
Signature · 1 line
2.33.1
Luiz Augusto von Dentz
maintainerPATCH 2/3 Bluetooth: hci_sync: Add support for waiting specific LE subevents
From: Luiz Augusto von Dentz <[email protected]>
This adds support for waiting for specific LE subevents instead of waiting for the command status which may only indicate that the commands in in progress and a different event is used to complete the operation.
--- include/net/bluetooth/bluetooth.h | 1 + net/bluetooth/hci_event.c | 31 +++++++++++++++++++++---------- net/bluetooth/hci_sync.c | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-)
include/net/bluetooth/bluetooth.h +1 -0
@@ -412,6 +412,7 @@ struct bt_skb_cb {#define hci_skb_pkt_type (skb) bt_cb((skb))->pkt_type#define hci_skb_expect (skb) bt_cb((skb))->expect#define hci_skb_opcode (skb) bt_cb((skb))->hci.opcode +#define hci_skb_event (skb) bt_cb((skb))->hci.req_event#define hci_skb_sk (skb) bt_cb((skb))->hci.skstatic inline struct sk_buff *bt_skb_alloc (unsigned int len,gfp_t how)
net/bluetooth/hci_event.c +21 -10
@@ -4038,8 +4038,7 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, void *data,* (since for this kind of commands there will not be a command * complete event). */ -if (ev->status || - (hdev->sent_cmd && !bt_cb (hdev->sent_cmd)->hci.req_event)) +if (ev->status || (hdev->sent_cmd && !hci_skb_event (hdev->sent_cmd)))hci_req_cmd_complete (hdev, *opcode, ev->status, req_complete, req_complete_skb);
@@ -6448,13 +6447,24 @@ static const struct hci_le_ev { };static void hci_le_meta_evt (struct hci_dev *hdev,void *data, -struct sk_buff *skb) +struct sk_buff *skb,u16 *opcode,u8 *status, +hci_req_complete_t *req_complete, +hci_req_complete_skb_t *req_complete_skb) {struct hci_ev_le_meta *ev = data;const struct hci_le_ev *subev;bt_dev_dbg (hdev,"subevent 0x%2.2x" , ev->subevent); +/* Only match event if command OGF is for LE */ +if (hdev->sent_cmd && +hci_opcode_ogf (hci_skb_opcode (hdev->sent_cmd)) ==0x08 && +hci_skb_event (hdev->sent_cmd) == ev->subevent) { + *opcode =hci_skb_opcode (hdev->sent_cmd); +hci_req_cmd_complete (hdev, *opcode,0x00 , req_complete, + req_complete_skb); + } + subev = &hci_le_ev_table[ev->subevent];if (!subev->func)return ;
@@ -6748,8 +6758,8 @@ static const struct hci_ev {HCI_EV (HCI_EV_REMOTE_HOST_FEATURES , hci_remote_host_features_evt,sizeof (struct hci_ev_remote_host_features )),/* [0x3e = HCI_EV_LE_META] */ -HCI_EV_VL (HCI_EV_LE_META , hci_le_meta_evt, -sizeof (struct hci_ev_le_meta ),HCI_MAX_EVENT_SIZE ), +HCI_EV_REQ_VL (HCI_EV_LE_META , hci_le_meta_evt, +sizeof (struct hci_ev_le_meta ),HCI_MAX_EVENT_SIZE ), #if IS_ENABLED(CONFIG_BT_HS)/* [0x40 = HCI_EV_PHY_LINK_COMPLETE] */ HCI_EV(HCI_EV_PHY_LINK_COMPLETE, hci_phy_link_complete_evt,
@@ -6833,11 +6843,12 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) goto done; } -if (hdev->sent_cmd &&bt_cb (hdev->sent_cmd)->hci.req_event == event) { -struct hci_command_hdr *cmd_hdr = (void *) hdev->sent_cmd->data; - opcode =__le16_to_cpu (cmd_hdr->opcode); -hci_req_cmd_complete (hdev, opcode, status, &req_complete, - &req_complete_skb); +/* Only match event if command OGF is not for LE */ +if (hdev->sent_cmd && +hci_opcode_ogf (hci_skb_opcode (hdev->sent_cmd)) !=0x08 && +hci_skb_event (hdev->sent_cmd) == event) { +hci_req_cmd_complete (hdev,hci_skb_opcode (hdev->sent_cmd), + status, &req_complete, &req_complete_skb); req_evt = event; }
net/bluetooth/hci_sync.c +1 -1
@@ -103,7 +103,7 @@ static void hci_cmd_sync_add(struct hci_request *req, u16 opcode, u32 plen,if (skb_queue_empty (&req->cmd_q))bt_cb (skb)->hci.req_flags |=HCI_REQ_START ; -bt_cb (skb)->hci.req_event = event; +hci_skb_event (skb) = event;skb_queue_tail (&req->cmd_q, skb); }
Signature · 1 line
2.33.1
Luiz Augusto von Dentz
maintainerPATCH 3/3 Bluetooth: hci_sync: Wait for proper events when connecting LE
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
When using HCI_OP_LE_CREATE_CONN wait for HCI_EV_LE_CONN_COMPLETE before completing it and for HCI_OP_LE_EXT_CREATE_CONN wait for HCI_EV_LE_ENHANCED_CONN_COMPLETE before resuming advertising.
--- net/bluetooth/hci_sync.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/bluetooth/hci_sync.c +7 -4
@@ -5157,8 +5157,10 @@ int hci_le_ext_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, plen +=sizeof (*p); } -return __hci_cmd_sync_status (hdev,HCI_OP_LE_EXT_CREATE_CONN , - plen, data,HCI_CMD_TIMEOUT ); +return __hci_cmd_sync_status_sk (hdev,HCI_OP_LE_EXT_CREATE_CONN , + plen, data, +HCI_EV_LE_ENHANCED_CONN_COMPLETE , +HCI_CMD_TIMEOUT ,NULL ); }int hci_le_create_conn_sync (struct hci_dev *hdev,struct hci_conn *conn)
@@ -5262,8 +5264,9 @@ int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn) cp.min_ce_len =cpu_to_le16 (0x0000 ); cp.max_ce_len =cpu_to_le16 (0x0000 ); - err =__hci_cmd_sync_status (hdev,HCI_OP_LE_CREATE_CONN , -sizeof (cp), &cp,HCI_CMD_TIMEOUT ); + err =__hci_cmd_sync_status_sk (hdev,HCI_OP_LE_CREATE_CONN , +sizeof (cp), &cp,HCI_EV_LE_CONN_COMPLETE , +HCI_CMD_TIMEOUT ,NULL ); done:hci_resume_advertising_sync (hdev);
Signature · 1 line
2.33.1