Bluetooth: Add support for extended index management events
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 15 Mar 2015 02:27:56 +0000 (19:27 -0700)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 15 Mar 2015 07:53:08 +0000 (09:53 +0200)
This introduces support for using Extended Index Added and Extended
Index Removed events. These events contain the controller type and
also the hardware bus information from the driver.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci.h
include/net/bluetooth/mgmt.h
net/bluetooth/mgmt.c

index 0995ec755959205999a2334a2555e54779114817..b8318711135adee2119a1957cf19529f894f8043 100644 (file)
@@ -183,6 +183,7 @@ enum {
 enum {
        HCI_MGMT_INDEX_EVENTS,
        HCI_MGMT_UNCONF_INDEX_EVENTS,
+       HCI_MGMT_EXT_INDEX_EVENTS,
 };
 
 /*
index 5bf6af9cee783a28bfce50a305c7fe3d321d33db..8562f9ecf230c6b3287faa8bbdb9f9e662a9290a 100644 (file)
@@ -692,3 +692,12 @@ struct mgmt_ev_new_conn_param {
 #define MGMT_EV_UNCONF_INDEX_REMOVED   0x001e
 
 #define MGMT_EV_NEW_CONFIG_OPTIONS     0x001f
+
+struct mgmt_ev_ext_index {
+       __u8 type;
+       __u8 bus;
+} __packed;
+
+#define MGMT_EV_EXT_INDEX_ADDED                0x0020
+
+#define MGMT_EV_EXT_INDEX_REMOVED      0x0021
index 6b58c13b2b51ce2db392363ddd7cb3ddb4913b30..56f49e9c4189d01836d4d157bffba8da4517a5d6 100644 (file)
@@ -128,6 +128,8 @@ static const u16 mgmt_events[] = {
        MGMT_EV_UNCONF_INDEX_ADDED,
        MGMT_EV_UNCONF_INDEX_REMOVED,
        MGMT_EV_NEW_CONFIG_OPTIONS,
+       MGMT_EV_EXT_INDEX_ADDED,
+       MGMT_EV_EXT_INDEX_REMOVED,
 };
 
 #define CACHE_TIMEOUT  msecs_to_jiffies(2 * 1000)
@@ -6370,6 +6372,7 @@ done:
 
 void mgmt_index_added(struct hci_dev *hdev)
 {
+       struct mgmt_ev_ext_index ev;
 
        if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
                return;
@@ -6379,16 +6382,29 @@ void mgmt_index_added(struct hci_dev *hdev)
                if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {
                        mgmt_index_event(MGMT_EV_UNCONF_INDEX_ADDED, hdev,
                                         NULL, 0, HCI_MGMT_UNCONF_INDEX_EVENTS);
+                       ev.type = 0x01;
                } else {
                        mgmt_index_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0,
                                         HCI_MGMT_INDEX_EVENTS);
+                       ev.type = 0x00;
                }
                break;
+       case HCI_AMP:
+               ev.type = 0x02;
+               break;
+       default:
+               return;
        }
+
+       ev.bus = hdev->bus;
+
+       mgmt_index_event(MGMT_EV_EXT_INDEX_ADDED, hdev, &ev, sizeof(ev),
+                        HCI_MGMT_EXT_INDEX_EVENTS);
 }
 
 void mgmt_index_removed(struct hci_dev *hdev)
 {
+       struct mgmt_ev_ext_index ev;
        u8 status = MGMT_STATUS_INVALID_INDEX;
 
        if (test_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks))
@@ -6401,12 +6417,24 @@ void mgmt_index_removed(struct hci_dev *hdev)
                if (hci_dev_test_flag(hdev, HCI_UNCONFIGURED)) {
                        mgmt_index_event(MGMT_EV_UNCONF_INDEX_REMOVED, hdev,
                                         NULL, 0, HCI_MGMT_UNCONF_INDEX_EVENTS);
+                       ev.type = 0x01;
                } else {
                        mgmt_index_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0,
                                         HCI_MGMT_INDEX_EVENTS);
+                       ev.type = 0x00;
                }
                break;
+       case HCI_AMP:
+               ev.type = 0x02;
+               break;
+       default:
+               return;
        }
+
+       ev.bus = hdev->bus;
+
+       mgmt_index_event(MGMT_EV_EXT_INDEX_REMOVED, hdev, &ev, sizeof(ev),
+                        HCI_MGMT_EXT_INDEX_EVENTS);
 }
 
 /* This function requires the caller holds hdev->lock */