Bluetooth: Add error handling logic of LE data batching 24/233624/3 accepted/tizen/unified/20200528.132937 submit/tizen/20200526.073613
authorDeokhyun Kim <dukan.kim@samsung.com>
Mon, 4 May 2020 08:18:11 +0000 (17:18 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 18 May 2020 02:29:18 +0000 (11:29 +0900)
Change-Id: Idb111d65552ef484cdf5a5f4d795d94a2c165db9
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c

index 7e987d2..670c8cf 100644 (file)
@@ -1831,6 +1831,7 @@ void mgmt_le_set_phy_complete(struct hci_dev *hdev);
 
 bool hci_le_set_phy(struct hci_conn *conn,
                                u8 tx_phy, u8 rx_phy, u16 phy_opt);
+void mgmt_le_batching_failed(struct hci_dev *hdev, u8 status);
 void mgmt_get_le_batching_buffer_complete(struct hci_dev *hdev,
                        u8 status, u16 buf_size);
 void mgmt_set_le_batching_param_complete(struct hci_dev *hdev, u8 status);
index bf850dd..f2a7e73 100644 (file)
@@ -1598,8 +1598,12 @@ static void hci_cc_le_batching(struct hci_dev *hdev,
        struct hci_rp_le_batching *rp = (void *) skb->data;
        struct hci_rp_get_le_batching_buffer *rp2 = (void *) skb->data;
 
-       BT_DBG("%s status 0x%2.2x subcode 0x%2.2x",
-               hdev->name, rp->status, rp->subcode);
+       BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
+
+       if (rp->status) {
+               mgmt_le_batching_failed(hdev, rp->status);
+               return;
+       }
 
        switch (rp->subcode) {
        case LE_BATCHING_SUBCODE_GET_BUFFER:
index cb0c6ed..59a035c 100644 (file)
@@ -5031,6 +5031,40 @@ unlock:
 
 }
 
+void mgmt_le_batching_failed(struct hci_dev *hdev, u8 status)
+{
+       struct mgmt_pending_cmd *cmd;
+       u16 mgmt_cmd;
+
+       cmd = pending_find(MGMT_OP_GET_LE_BATCHING_BUFFER, hdev);
+       if (cmd) {
+               mgmt_cmd = MGMT_OP_GET_LE_BATCHING_BUFFER;
+               goto found;
+       }
+       cmd = pending_find(MGMT_OP_SET_LE_BATCHING_PARAM, hdev);
+       if (cmd) {
+               mgmt_cmd = MGMT_OP_SET_LE_BATCHING_PARAM;
+               goto found;
+       }
+       cmd = pending_find(MGMT_OP_SET_LE_BATCHING_ENABLE, hdev);
+       if (cmd) {
+               mgmt_cmd = MGMT_OP_SET_LE_BATCHING_ENABLE;
+               goto found;
+       }
+
+       BT_ERR("cmd not found in the pending list");
+       return;
+
+found:
+       if (status) {
+               mgmt_cmd_status(cmd->sk, hdev->id, mgmt_cmd,
+                          mgmt_status(status));
+       }
+
+       mgmt_cmd_complete(cmd->sk, hdev->id, mgmt_cmd, status, NULL, 0);
+       mgmt_pending_remove(cmd);
+}
+
 void mgmt_get_le_batching_buffer_complete(struct hci_dev *hdev,
                        u8 status, u16 buf_size)
 {
@@ -5084,7 +5118,9 @@ static int get_le_batching_buffer(struct sock *sk, struct hci_dev *hdev,
 
        cp_en.subcode = LE_BATCHING_SUBCODE_GET_BUFFER;
 
-       if (pending_find(MGMT_OP_GET_LE_BATCHING_BUFFER, hdev)) {
+       if (pending_find(MGMT_OP_GET_LE_BATCHING_BUFFER, hdev) ||
+               pending_find(MGMT_OP_SET_LE_BATCHING_PARAM, hdev) ||
+               pending_find(MGMT_OP_SET_LE_BATCHING_ENABLE, hdev)) {
                BT_DBG("%s", hdev->name);
                err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_GET_LE_BATCHING_BUFFER,
                                MGMT_STATUS_BUSY);
@@ -5180,7 +5216,9 @@ static int set_le_batching_param(struct sock *sk, struct hci_dev *hdev,
        cp_en.pkt_th = cp->pkt_th;
        cp_en.timeout = cp->timeout;
 
-       if (pending_find(MGMT_OP_SET_LE_BATCHING_PARAM, hdev)) {
+       if (pending_find(MGMT_OP_GET_LE_BATCHING_BUFFER, hdev) ||
+               pending_find(MGMT_OP_SET_LE_BATCHING_PARAM, hdev) ||
+               pending_find(MGMT_OP_SET_LE_BATCHING_ENABLE, hdev)) {
                BT_DBG("%s", hdev->name);
                err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE_BATCHING_PARAM,
                                MGMT_STATUS_BUSY);
@@ -5277,7 +5315,9 @@ static int set_le_batching_enable(struct sock *sk, struct hci_dev *hdev,
        cp_en.cid = L2CAP_CID_ATT;
        cp_en.enable = cp->enable;
 
-       if (pending_find(MGMT_OP_SET_LE_BATCHING_ENABLE, hdev)) {
+       if (pending_find(MGMT_OP_GET_LE_BATCHING_BUFFER, hdev) ||
+               pending_find(MGMT_OP_SET_LE_BATCHING_PARAM, hdev) ||
+               pending_find(MGMT_OP_SET_LE_BATCHING_ENABLE, hdev)) {
                BT_DBG("%s", hdev->name);
                err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_SET_LE_BATCHING_ENABLE,
                                MGMT_STATUS_BUSY);