History

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next

Johan Hedberg says: ==================== pull request: bluetooth-next 2020-07-31 Here's the main bluetooth-next pull request for 5.9: - Fix firmware filenames for Marvell chipsets - Several suspend-related fixes - Addedd mgmt commands for runtime configuration - Multiple fixes for Qualcomm-based controllers - Add new monitoring feature for mgmt - Fix handling of legacy cipher (E4) together with security level 4 - Add support for Realtek 8822CE controller - Fix issues with Chinese controllers using fake VID/PID values - Multiple other smaller fixes & improvements ====================

David S. Miller committed 6 years ago

Commit 4bb540d2 parents bd69058 075f77344 files · +2149 −324Browse files

Showing the changes to include (6 of 44 files). Show all

Unified · Split

6 files
  1. include/net/bluetooth/bluetooth.h +12 −0
  2. include/net/bluetooth/hci.h +26 −2
  3. include/net/bluetooth/hci_core.h +96 −11
  4. include/net/bluetooth/hci_sock.h +2 −2
  5. include/net/bluetooth/mgmt.h +95 −0
  6. include/net/bluetooth/sco.h +2 −0
include/net/bluetooth/bluetooth.h+12−0
@@ -41,6 +41,8 @@ · 40 unmodified lines
4141 #define BLUETOOTH_VER_1_1 1
4242 #define BLUETOOTH_VER_1_2 2
4343 #define BLUETOOTH_VER_2_0 3
44+#define BLUETOOTH_VER_2_1 4
45+#define BLUETOOTH_VER_4_0 6
4446
4547 /* Reserv for core and drivers use */
4648 #define BT_SKB_RESERVE 8
@@ -147,6 +149,10 @@ struct bt_voice { · 100 unmodified lines
147149 #define BT_MODE_LE_FLOWCTL 0x03
148150 #define BT_MODE_EXT_FLOWCTL 0x04
149151
152+#define BT_PKT_STATUS 16
153+
154+#define BT_SCM_PKT_STATUS 0x03
155+
150156 __printf(1, 2)
151157 void bt_info(const char *fmt, ...);
152158 __printf(1, 2)
@@ -286,6 +292,7 @@ struct bt_sock { · 133 unmodified lines
286292 struct sock *parent;
287293 unsigned long flags;
288294 void (*skb_msg_name)(struct sk_buff *, void *, int *);
295+ void (*skb_put_cmsg)(struct sk_buff *, struct msghdr *, struct sock *);
289296 };
290297
291298 enum {
@@ -335,6 +342,10 @@ struct l2cap_ctrl { · 43 unmodified lines
335342 struct l2cap_chan *chan;
336343 };
337344
345+struct sco_ctrl {
346+ u8 pkt_status;
347+};
348+
338349 struct hci_dev;
339350
340351 typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode);
@@ -361,6 +372,7 @@ struct bt_skb_cb { · 20 unmodified lines
361372 u8 incoming:1;
362373 union {
363374 struct l2cap_ctrl l2cap;
375+ struct sco_ctrl sco;
364376 struct hci_ctrl hci;
365377 };
366378 };
include/net/bluetooth/hci.h+26−2
@@ -227,6 +227,17 @@ enum { · 226 unmodified lines
227227 * supported.
228228 */
229229 HCI_QUIRK_VALID_LE_STATES,
230+
231+ /* When this quirk is set, then erroneous data reporting
232+ * is ignored. This is mainly due to the fact that the HCI
233+ * Read Default Erroneous Data Reporting command is advertised,
234+ * but not supported; these controllers often reply with unknown
235+ * command and tend to lock up randomly. Needing a hard reset.
236+ *
237+ * This quirk can be set before hci_register_dev is called or
238+ * during the hdev->setup vendor callback.
239+ */
240+ HCI_QUIRK_BROKEN_ERR_DATA_REPORTING,
230241 };
231242
232243 /* HCI device flags */
@@ -307,6 +318,7 @@ enum { · 74 unmodified lines
307318 HCI_FORCE_BREDR_SMP,
308319 HCI_FORCE_STATIC_ADDR,
309320 HCI_LL_RPA_RESOLUTION,
321+ HCI_ENABLE_LL_PRIVACY,
310322 HCI_CMD_PENDING,
311323 HCI_FORCE_NO_MITM,
312324
@@ -1637,6 +1649,8 @@ struct hci_rp_le_read_resolv_list_size { · 1324 unmodified lines
16371649
16381650 #define HCI_OP_LE_SET_ADDR_RESOLV_ENABLE 0x202d
16391651
1652+#define HCI_OP_LE_SET_RPA_TIMEOUT 0x202e
1653+
16401654 #define HCI_OP_LE_READ_MAX_DATA_LEN 0x202f
16411655 struct hci_rp_le_read_max_data_len {
16421656 __u8 status;
@@ -2268,8 +2282,10 @@ struct hci_ev_le_conn_complete { · 625 unmodified lines
22682282 #define LE_EXT_ADV_SCAN_RSP 0x0008
22692283 #define LE_EXT_ADV_LEGACY_PDU 0x0010
22702284
2271−#define ADDR_LE_DEV_PUBLIC 0x00
2272−#define ADDR_LE_DEV_RANDOM 0x01
2285+#define ADDR_LE_DEV_PUBLIC 0x00
2286+#define ADDR_LE_DEV_RANDOM 0x01
2287+#define ADDR_LE_DEV_PUBLIC_RESOLVED 0x02
2288+#define ADDR_LE_DEV_RANDOM_RESOLVED 0x03
22732289
22742290 #define HCI_EV_LE_ADVERTISING_REPORT 0x02
22752291 struct hci_ev_le_advertising_info {
@@ -2516,4 +2532,12 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) · 240 unmodified lines
25162532 #define hci_iso_data_len(h) ((h) & 0x3fff)
25172533 #define hci_iso_data_flags(h) ((h) >> 14)
25182534
2535+/* le24 support */
2536+static inline void hci_cpu_to_le24(__u32 val, __u8 dst[3])
2537+{
2538+ dst[0] = val & 0xff;
2539+ dst[1] = (val & 0xff00) >> 8;
2540+ dst[2] = (val & 0xff0000) >> 16;
2541+}
2542+
25192543 #endif /* __HCI_H */
include/net/bluetooth/hci_core.h+96−11
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #ifndef __HCI_CORE_H
2626 #define __HCI_CORE_H
2727
28+#include <linux/idr.h>
2829 #include <linux/leds.h>
2930 #include <linux/rculist.h>
3031
@@ -136,6 +137,23 @@ struct bdaddr_list_with_irk { · 105 unmodified lines
136137 u8 local_irk[16];
137138 };
138139
140+struct bdaddr_list_with_flags {
141+ struct list_head list;
142+ bdaddr_t bdaddr;
143+ u8 bdaddr_type;
144+ u32 current_flags;
145+};
146+
147+enum hci_conn_flags {
148+ HCI_CONN_FLAG_REMOTE_WAKEUP,
149+ HCI_CONN_FLAG_MAX
150+};
151+
152+#define hci_conn_test_flag(nr, flags) ((flags) & (1U << nr))
153+
154+/* Make sure number of flags doesn't exceed sizeof(current_flags) */
155+static_assert(HCI_CONN_FLAG_MAX < 32);
156+
139157 struct bt_uuid {
140158 struct list_head list;
141159 u8 uuid[16];
@@ -220,6 +238,24 @@ struct adv_info { · 78 unmodified lines
220238 #define HCI_MAX_ADV_INSTANCES 5
221239 #define HCI_DEFAULT_ADV_DURATION 2
222240
241+struct adv_pattern {
242+ struct list_head list;
243+ __u8 ad_type;
244+ __u8 offset;
245+ __u8 length;
246+ __u8 value[HCI_MAX_AD_LENGTH];
247+};
248+
249+struct adv_monitor {
250+ struct list_head patterns;
251+ bool active;
252+ __u16 handle;
253+};
254+
255+#define HCI_MIN_ADV_MONITOR_HANDLE 1
256+#define HCI_MAX_ADV_MONITOR_NUM_HANDLES 32
257+#define HCI_MAX_ADV_MONITOR_NUM_PATTERNS 16
258+
223259 #define HCI_MAX_SHORT_NAME_LENGTH 10
224260
225261 /* Min encryption key size to match with SMP */
@@ -295,6 +331,14 @@ struct hci_dev { · 69 unmodified lines
295331 __u8 le_scan_type;
296332 __u16 le_scan_interval;
297333 __u16 le_scan_window;
334+ __u16 le_scan_int_suspend;
335+ __u16 le_scan_window_suspend;
336+ __u16 le_scan_int_discovery;
337+ __u16 le_scan_window_discovery;
338+ __u16 le_scan_int_adv_monitor;
339+ __u16 le_scan_window_adv_monitor;
340+ __u16 le_scan_int_connect;
341+ __u16 le_scan_window_connect;
298342 __u16 le_conn_min_interval;
299343 __u16 le_conn_max_interval;
300344 __u16 le_conn_latency;
@@ -323,6 +367,17 @@ struct hci_dev { · 22 unmodified lines
323367 __u16 devid_product;
324368 __u16 devid_version;
325369
370+ __u8 def_page_scan_type;
371+ __u16 def_page_scan_int;
372+ __u16 def_page_scan_window;
373+ __u8 def_inq_scan_type;
374+ __u16 def_inq_scan_int;
375+ __u16 def_inq_scan_window;
376+ __u16 def_br_lsto;
377+ __u16 def_page_timeout;
378+ __u16 def_multi_adv_rotation_duration;
379+ __u16 def_le_autoconnect_timeout;
380+
326381 __u16 pkt_type;
327382 __u16 esco_type;
328383 __u16 link_policy;
@@ -438,7 +493,6 @@ struct hci_dev { · 109 unmodified lines
438493 struct list_head mgmt_pending;
439494 struct list_head blacklist;
440495 struct list_head whitelist;
441− struct list_head wakeable;
442496 struct list_head uuids;
443497 struct list_head link_keys;
444498 struct list_head long_term_keys;
@@ -477,6 +531,9 @@ struct hci_dev { · 32 unmodified lines
477531 __u16 adv_instance_timeout;
478532 struct delayed_work adv_instance_expire;
479533
534+ struct idr adv_monitors_idr;
535+ unsigned int adv_monitors_cnt;
536+
480537 __u8 irk[16];
481538 __u32 rpa_timeout;
482539 struct delayed_work rpa_expired;
@@ -508,6 +565,12 @@ struct hci_dev { · 25 unmodified lines
508565
509566 #define HCI_PHY_HANDLE(handle) (handle & 0xff)
510567
568+enum conn_reasons {
569+ CONN_REASON_PAIR_DEVICE,
570+ CONN_REASON_L2CAP_CHAN,
571+ CONN_REASON_SCO_CONNECT,
572+};
573+
511574 struct hci_conn {
512575 struct list_head list;
513576
@@ -559,6 +622,8 @@ struct hci_conn { · 45 unmodified lines
559622 __s8 max_tx_power;
560623 unsigned long flags;
561624
625+ enum conn_reasons conn_reason;
626+
562627 __u32 clock;
563628 __u16 clock_accuracy;
564629
@@ -626,7 +691,7 @@ struct hci_conn_params { · 61 unmodified lines
626691
627692 struct hci_conn *conn;
628693 bool explicit_connect;
629− bool wakeable;
694+ u32 current_flags;
630695 };
631696
632697 extern struct list_head hci_dev_list;
@@ -984,12 +1049,14 @@ struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); · 351 unmodified lines
9841049
9851050 struct hci_conn *hci_connect_le_scan(struct hci_dev *hdev, bdaddr_t *dst,
9861051 u8 dst_type, u8 sec_level,
987− u16 conn_timeout);
1052+ u16 conn_timeout,
1053+ enum conn_reasons conn_reason);
9881054 struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
9891055 u8 dst_type, u8 sec_level, u16 conn_timeout,
9901056 u8 role, bdaddr_t *direct_rpa);
9911057 struct hci_conn *hci_connect_acl(struct hci_dev *hdev, bdaddr_t *dst,
992− u8 sec_level, u8 auth_type);
1058+ u8 sec_level, u8 auth_type,
1059+ enum conn_reasons conn_reason);
9931060 struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, bdaddr_t *dst,
9941061 __u16 setting);
9951062 int hci_conn_check_link_mode(struct hci_conn *conn);
@@ -1151,12 +1218,19 @@ struct bdaddr_list *hci_bdaddr_list_lookup(struct list_head *list, · 155 unmodified lines
11511218 struct bdaddr_list_with_irk *hci_bdaddr_list_lookup_with_irk(
11521219 struct list_head *list, bdaddr_t *bdaddr,
11531220 u8 type);
1221+struct bdaddr_list_with_flags *
1222+hci_bdaddr_list_lookup_with_flags(struct list_head *list, bdaddr_t *bdaddr,
1223+ u8 type);
11541224 int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type);
11551225 int hci_bdaddr_list_add_with_irk(struct list_head *list, bdaddr_t *bdaddr,
1156− u8 type, u8 *peer_irk, u8 *local_irk);
1226+ u8 type, u8 *peer_irk, u8 *local_irk);
1227+int hci_bdaddr_list_add_with_flags(struct list_head *list, bdaddr_t *bdaddr,
1228+ u8 type, u32 flags);
11571229 int hci_bdaddr_list_del(struct list_head *list, bdaddr_t *bdaddr, u8 type);
11581230 int hci_bdaddr_list_del_with_irk(struct list_head *list, bdaddr_t *bdaddr,
1159− u8 type);
1231+ u8 type);
1232+int hci_bdaddr_list_del_with_flags(struct list_head *list, bdaddr_t *bdaddr,
1233+ u8 type);
11601234 void hci_bdaddr_list_clear(struct list_head *list);
11611235
11621236 struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev,
@@ -1217,6 +1291,12 @@ int hci_add_adv_instance(struct hci_dev *hdev, u8 instance, u32 flags, · 54 unmodified lines
12171291 int hci_remove_adv_instance(struct hci_dev *hdev, u8 instance);
12181292 void hci_adv_instances_set_rpa_expired(struct hci_dev *hdev, bool rpa_expired);
12191293
1294+void hci_adv_monitors_clear(struct hci_dev *hdev);
1295+void hci_free_adv_monitor(struct adv_monitor *monitor);
1296+int hci_add_adv_monitor(struct hci_dev *hdev, struct adv_monitor *monitor);
1297+int hci_remove_adv_monitor(struct hci_dev *hdev, u16 handle);
1298+bool hci_is_adv_monitoring(struct hci_dev *hdev);
1299+
12201300 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
12211301
12221302 void hci_init_sysfs(struct hci_dev *hdev);
@@ -1279,6 +1359,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn); · 56 unmodified lines
12791359 #define scan_coded(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_CODED) || \
12801360 ((dev)->le_rx_def_phys & HCI_LE_SET_PHY_CODED))
12811361
1362+/* Use LL Privacy based address resolution if supported */
1363+#define use_ll_privacy(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY)
1364+
12821365 /* Use ext scanning if set ext scan param and ext scan enable is supported */
12831366 #define use_ext_scan(dev) (((dev)->commands[37] & 0x20) && \
12841367 ((dev)->commands[37] & 0x40))
@@ -1387,7 +1470,7 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) · 102 unmodified lines
13871470 __u8 encrypt;
13881471
13891472 if (conn->state == BT_CONFIG) {
1390− if (status)
1473+ if (!status)
13911474 conn->state = BT_CONNECTED;
13921475
13931476 hci_connect_cfm(conn, status);
@@ -1402,11 +1485,13 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status) · 8 unmodified lines
14021485 else
14031486 encrypt = 0x01;
14041487
1405− if (conn->sec_level == BT_SECURITY_SDP)
1406− conn->sec_level = BT_SECURITY_LOW;
1488+ if (!status) {
1489+ if (conn->sec_level == BT_SECURITY_SDP)
1490+ conn->sec_level = BT_SECURITY_LOW;
14071491
1408− if (conn->pending_sec_level > conn->sec_level)
1409− conn->sec_level = conn->pending_sec_level;
1492+ if (conn->pending_sec_level > conn->sec_level)
1493+ conn->sec_level = conn->pending_sec_level;
1494+ }
14101495
14111496 mutex_lock(&hci_cb_list_lock);
14121497 list_for_each_entry(cb, &hci_cb_list, list) {
include/net/bluetooth/hci_sock.h+2−2
@@ -31,8 +31,8 @@ · 30 unmodified lines
3131 #define HCI_TIME_STAMP 3
3232
3333 /* CMSG flags */
34−#define HCI_CMSG_DIR 0x0001
35−#define HCI_CMSG_TSTAMP 0x0002
34+#define HCI_CMSG_DIR 0x01
35+#define HCI_CMSG_TSTAMP 0x02
3636
3737 struct sockaddr_hci {
3838 sa_family_t hci_family;
include/net/bluetooth/mgmt.h+95−0
@@ -52,6 +52,12 @@ struct mgmt_hdr { · 51 unmodified lines
5252 __le16 len;
5353 } __packed;
5454
55+struct mgmt_tlv {
56+ __le16 type;
57+ __u8 length;
58+ __u8 value[];
59+} __packed;
60+
5561 struct mgmt_addr_info {
5662 bdaddr_t bdaddr;
5763 __u8 type;
@@ -702,6 +708,78 @@ struct mgmt_rp_set_exp_feature { · 644 unmodified lines
702708 __le32 flags;
703709 } __packed;
704710
711+#define MGMT_OP_READ_DEF_SYSTEM_CONFIG 0x004b
712+#define MGMT_READ_DEF_SYSTEM_CONFIG_SIZE 0
713+
714+#define MGMT_OP_SET_DEF_SYSTEM_CONFIG 0x004c
715+#define MGMT_SET_DEF_SYSTEM_CONFIG_SIZE 0
716+
717+#define MGMT_OP_READ_DEF_RUNTIME_CONFIG 0x004d
718+#define MGMT_READ_DEF_RUNTIME_CONFIG_SIZE 0
719+
720+#define MGMT_OP_SET_DEF_RUNTIME_CONFIG 0x004e
721+#define MGMT_SET_DEF_RUNTIME_CONFIG_SIZE 0
722+
723+#define MGMT_OP_GET_DEVICE_FLAGS 0x004F
724+#define MGMT_GET_DEVICE_FLAGS_SIZE 7
725+struct mgmt_cp_get_device_flags {
726+ struct mgmt_addr_info addr;
727+} __packed;
728+struct mgmt_rp_get_device_flags {
729+ struct mgmt_addr_info addr;
730+ __le32 supported_flags;
731+ __le32 current_flags;
732+} __packed;
733+
734+#define MGMT_OP_SET_DEVICE_FLAGS 0x0050
735+#define MGMT_SET_DEVICE_FLAGS_SIZE 11
736+struct mgmt_cp_set_device_flags {
737+ struct mgmt_addr_info addr;
738+ __le32 current_flags;
739+} __packed;
740+struct mgmt_rp_set_device_flags {
741+ struct mgmt_addr_info addr;
742+} __packed;
743+
744+#define MGMT_ADV_MONITOR_FEATURE_MASK_OR_PATTERNS BIT(0)
745+
746+#define MGMT_OP_READ_ADV_MONITOR_FEATURES 0x0051
747+#define MGMT_READ_ADV_MONITOR_FEATURES_SIZE 0
748+struct mgmt_rp_read_adv_monitor_features {
749+ __le32 supported_features;
750+ __le32 enabled_features;
751+ __le16 max_num_handles;
752+ __u8 max_num_patterns;
753+ __le16 num_handles;
754+ __le16 handles[];
755+} __packed;
756+
757+struct mgmt_adv_pattern {
758+ __u8 ad_type;
759+ __u8 offset;
760+ __u8 length;
761+ __u8 value[31];
762+} __packed;
763+
764+#define MGMT_OP_ADD_ADV_PATTERNS_MONITOR 0x0052
765+struct mgmt_cp_add_adv_patterns_monitor {
766+ __u8 pattern_count;
767+ struct mgmt_adv_pattern patterns[];
768+} __packed;
769+#define MGMT_ADD_ADV_PATTERNS_MONITOR_SIZE 1
770+struct mgmt_rp_add_adv_patterns_monitor {
771+ __le16 monitor_handle;
772+} __packed;
773+
774+#define MGMT_OP_REMOVE_ADV_MONITOR 0x0053
775+struct mgmt_cp_remove_adv_monitor {
776+ __le16 monitor_handle;
777+} __packed;
778+#define MGMT_REMOVE_ADV_MONITOR_SIZE 2
779+struct mgmt_rp_remove_adv_monitor {
780+ __le16 monitor_handle;
781+} __packed;
782+
705783 #define MGMT_EV_CMD_COMPLETE 0x0001
706784 struct mgmt_ev_cmd_complete {
707785 __le16 opcode;
@@ -933,3 +1011,20 @@ struct mgmt_ev_exp_feature_changed { · 225 unmodified lines
9331011 __u8 uuid[16];
9341012 __le32 flags;
9351013 } __packed;
1014+
1015+#define MGMT_EV_DEVICE_FLAGS_CHANGED 0x002a
1016+struct mgmt_ev_device_flags_changed {
1017+ struct mgmt_addr_info addr;
1018+ __le32 supported_flags;
1019+ __le32 current_flags;
1020+} __packed;
1021+
1022+#define MGMT_EV_ADV_MONITOR_ADDED 0x002b
1023+struct mgmt_ev_adv_monitor_added {
1024+ __le16 monitor_handle;
1025+} __packed;
1026+
1027+#define MGMT_EV_ADV_MONITOR_REMOVED 0x002c
1028+struct mgmt_ev_adv_monitor_removed {
1029+ __le16 monitor_handle;
1030+} __packed;
include/net/bluetooth/sco.h+2−0
@@ -46,4 +46,6 @@ struct sco_conninfo { · 45 unmodified lines
4646 __u8 dev_class[3];
4747 };
4848
49+#define SCO_CMSG_PKT_STATUS 0x01
50+
4951 #endif /* __SCO_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t