diff options
author | John W. Linville <linville@tuxdriver.com> | 2013-04-22 14:56:41 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-04-22 14:56:41 -0400 |
commit | e563589f7187699b0217854467d857f53b29cc50 (patch) | |
tree | c6ff538f85ba5496da39b9d1789db761f58e803a /include/net | |
parent | 197bbf0aedfb81ab70247264883c81e7f7d503ba (diff) | |
parent | 76a388beaf92cc75b829d4a0b7d69afaaeaa4b0a (diff) |
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/bluetooth/bluetooth.h | 5 | ||||
-rw-r--r-- | include/net/bluetooth/hci.h | 9 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 98 | ||||
-rw-r--r-- | include/net/bluetooth/l2cap.h | 15 |
4 files changed, 91 insertions, 36 deletions
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index ed6e9552252e..6912ef9a1881 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
@@ -193,11 +193,11 @@ static inline bool bdaddr_type_is_le(__u8 type) | |||
193 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) | 193 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) |
194 | 194 | ||
195 | /* Copy, swap, convert BD Address */ | 195 | /* Copy, swap, convert BD Address */ |
196 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) | 196 | static inline int bacmp(const bdaddr_t *ba1, const bdaddr_t *ba2) |
197 | { | 197 | { |
198 | return memcmp(ba1, ba2, sizeof(bdaddr_t)); | 198 | return memcmp(ba1, ba2, sizeof(bdaddr_t)); |
199 | } | 199 | } |
200 | static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) | 200 | static inline void bacpy(bdaddr_t *dst, const bdaddr_t *src) |
201 | { | 201 | { |
202 | memcpy(dst, src, sizeof(bdaddr_t)); | 202 | memcpy(dst, src, sizeof(bdaddr_t)); |
203 | } | 203 | } |
@@ -266,6 +266,7 @@ typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status); | |||
266 | 266 | ||
267 | struct hci_req_ctrl { | 267 | struct hci_req_ctrl { |
268 | bool start; | 268 | bool start; |
269 | u8 event; | ||
269 | hci_req_complete_t complete; | 270 | hci_req_complete_t complete; |
270 | }; | 271 | }; |
271 | 272 | ||
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index b3308927a0a1..e0512aaef4b8 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -984,6 +984,9 @@ struct hci_cp_le_set_adv_data { | |||
984 | 984 | ||
985 | #define HCI_OP_LE_SET_ADV_ENABLE 0x200a | 985 | #define HCI_OP_LE_SET_ADV_ENABLE 0x200a |
986 | 986 | ||
987 | #define LE_SCAN_PASSIVE 0x00 | ||
988 | #define LE_SCAN_ACTIVE 0x01 | ||
989 | |||
987 | #define HCI_OP_LE_SET_SCAN_PARAM 0x200b | 990 | #define HCI_OP_LE_SET_SCAN_PARAM 0x200b |
988 | struct hci_cp_le_set_scan_param { | 991 | struct hci_cp_le_set_scan_param { |
989 | __u8 type; | 992 | __u8 type; |
@@ -993,8 +996,10 @@ struct hci_cp_le_set_scan_param { | |||
993 | __u8 filter_policy; | 996 | __u8 filter_policy; |
994 | } __packed; | 997 | } __packed; |
995 | 998 | ||
996 | #define LE_SCANNING_DISABLED 0x00 | 999 | #define LE_SCAN_DISABLE 0x00 |
997 | #define LE_SCANNING_ENABLED 0x01 | 1000 | #define LE_SCAN_ENABLE 0x01 |
1001 | #define LE_SCAN_FILTER_DUP_DISABLE 0x00 | ||
1002 | #define LE_SCAN_FILTER_DUP_ENABLE 0x01 | ||
998 | 1003 | ||
999 | #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c | 1004 | #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c |
1000 | struct hci_cp_le_set_scan_enable { | 1005 | struct hci_cp_le_set_scan_enable { |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 358a6983d3bb..80d718a9b31f 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -134,6 +134,8 @@ struct amp_assoc { | |||
134 | __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; | 134 | __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; |
135 | }; | 135 | }; |
136 | 136 | ||
137 | #define HCI_MAX_PAGES 3 | ||
138 | |||
137 | #define NUM_REASSEMBLY 4 | 139 | #define NUM_REASSEMBLY 4 |
138 | struct hci_dev { | 140 | struct hci_dev { |
139 | struct list_head list; | 141 | struct list_head list; |
@@ -151,8 +153,8 @@ struct hci_dev { | |||
151 | __u8 dev_class[3]; | 153 | __u8 dev_class[3]; |
152 | __u8 major_class; | 154 | __u8 major_class; |
153 | __u8 minor_class; | 155 | __u8 minor_class; |
154 | __u8 features[8]; | 156 | __u8 max_page; |
155 | __u8 host_features[8]; | 157 | __u8 features[HCI_MAX_PAGES][8]; |
156 | __u8 le_features[8]; | 158 | __u8 le_features[8]; |
157 | __u8 le_white_list_size; | 159 | __u8 le_white_list_size; |
158 | __u8 le_states[8]; | 160 | __u8 le_states[8]; |
@@ -244,6 +246,7 @@ struct hci_dev { | |||
244 | struct sk_buff_head raw_q; | 246 | struct sk_buff_head raw_q; |
245 | struct sk_buff_head cmd_q; | 247 | struct sk_buff_head cmd_q; |
246 | 248 | ||
249 | struct sk_buff *recv_evt; | ||
247 | struct sk_buff *sent_cmd; | 250 | struct sk_buff *sent_cmd; |
248 | struct sk_buff *reassembly[NUM_REASSEMBLY]; | 251 | struct sk_buff *reassembly[NUM_REASSEMBLY]; |
249 | 252 | ||
@@ -268,8 +271,6 @@ struct hci_dev { | |||
268 | 271 | ||
269 | struct hci_dev_stats stat; | 272 | struct hci_dev_stats stat; |
270 | 273 | ||
271 | struct sk_buff_head driver_init; | ||
272 | |||
273 | atomic_t promisc; | 274 | atomic_t promisc; |
274 | 275 | ||
275 | struct dentry *debugfs; | 276 | struct dentry *debugfs; |
@@ -292,6 +293,7 @@ struct hci_dev { | |||
292 | int (*open)(struct hci_dev *hdev); | 293 | int (*open)(struct hci_dev *hdev); |
293 | int (*close)(struct hci_dev *hdev); | 294 | int (*close)(struct hci_dev *hdev); |
294 | int (*flush)(struct hci_dev *hdev); | 295 | int (*flush)(struct hci_dev *hdev); |
296 | int (*setup)(struct hci_dev *hdev); | ||
295 | int (*send)(struct sk_buff *skb); | 297 | int (*send)(struct sk_buff *skb); |
296 | void (*notify)(struct hci_dev *hdev, unsigned int evt); | 298 | void (*notify)(struct hci_dev *hdev, unsigned int evt); |
297 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); | 299 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); |
@@ -313,7 +315,7 @@ struct hci_conn { | |||
313 | bool out; | 315 | bool out; |
314 | __u8 attempt; | 316 | __u8 attempt; |
315 | __u8 dev_class[3]; | 317 | __u8 dev_class[3]; |
316 | __u8 features[8]; | 318 | __u8 features[HCI_MAX_PAGES][8]; |
317 | __u16 interval; | 319 | __u16 interval; |
318 | __u16 pkt_type; | 320 | __u16 pkt_type; |
319 | __u16 link_policy; | 321 | __u16 link_policy; |
@@ -345,7 +347,6 @@ struct hci_conn { | |||
345 | struct timer_list auto_accept_timer; | 347 | struct timer_list auto_accept_timer; |
346 | 348 | ||
347 | struct device dev; | 349 | struct device dev; |
348 | atomic_t devref; | ||
349 | 350 | ||
350 | struct hci_dev *hdev; | 351 | struct hci_dev *hdev; |
351 | void *l2cap_data; | 352 | void *l2cap_data; |
@@ -584,7 +585,6 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); | |||
584 | int hci_conn_del(struct hci_conn *conn); | 585 | int hci_conn_del(struct hci_conn *conn); |
585 | void hci_conn_hash_flush(struct hci_dev *hdev); | 586 | void hci_conn_hash_flush(struct hci_dev *hdev); |
586 | void hci_conn_check_pending(struct hci_dev *hdev); | 587 | void hci_conn_check_pending(struct hci_dev *hdev); |
587 | void hci_conn_accept(struct hci_conn *conn, int mask); | ||
588 | 588 | ||
589 | struct hci_chan *hci_chan_create(struct hci_conn *conn); | 589 | struct hci_chan *hci_chan_create(struct hci_conn *conn); |
590 | void hci_chan_del(struct hci_chan *chan); | 590 | void hci_chan_del(struct hci_chan *chan); |
@@ -601,8 +601,36 @@ int hci_conn_switch_role(struct hci_conn *conn, __u8 role); | |||
601 | 601 | ||
602 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); | 602 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); |
603 | 603 | ||
604 | void hci_conn_hold_device(struct hci_conn *conn); | 604 | /* |
605 | void hci_conn_put_device(struct hci_conn *conn); | 605 | * hci_conn_get() and hci_conn_put() are used to control the life-time of an |
606 | * "hci_conn" object. They do not guarantee that the hci_conn object is running, | ||
607 | * working or anything else. They just guarantee that the object is available | ||
608 | * and can be dereferenced. So you can use its locks, local variables and any | ||
609 | * other constant data. | ||
610 | * Before accessing runtime data, you _must_ lock the object and then check that | ||
611 | * it is still running. As soon as you release the locks, the connection might | ||
612 | * get dropped, though. | ||
613 | * | ||
614 | * On the other hand, hci_conn_hold() and hci_conn_drop() are used to control | ||
615 | * how long the underlying connection is held. So every channel that runs on the | ||
616 | * hci_conn object calls this to prevent the connection from disappearing. As | ||
617 | * long as you hold a device, you must also guarantee that you have a valid | ||
618 | * reference to the device via hci_conn_get() (or the initial reference from | ||
619 | * hci_conn_add()). | ||
620 | * The hold()/drop() ref-count is known to drop below 0 sometimes, which doesn't | ||
621 | * break because nobody cares for that. But this means, we cannot use | ||
622 | * _get()/_drop() in it, but require the caller to have a valid ref (FIXME). | ||
623 | */ | ||
624 | |||
625 | static inline void hci_conn_get(struct hci_conn *conn) | ||
626 | { | ||
627 | get_device(&conn->dev); | ||
628 | } | ||
629 | |||
630 | static inline void hci_conn_put(struct hci_conn *conn) | ||
631 | { | ||
632 | put_device(&conn->dev); | ||
633 | } | ||
606 | 634 | ||
607 | static inline void hci_conn_hold(struct hci_conn *conn) | 635 | static inline void hci_conn_hold(struct hci_conn *conn) |
608 | { | 636 | { |
@@ -612,7 +640,7 @@ static inline void hci_conn_hold(struct hci_conn *conn) | |||
612 | cancel_delayed_work(&conn->disc_work); | 640 | cancel_delayed_work(&conn->disc_work); |
613 | } | 641 | } |
614 | 642 | ||
615 | static inline void hci_conn_put(struct hci_conn *conn) | 643 | static inline void hci_conn_drop(struct hci_conn *conn) |
616 | { | 644 | { |
617 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); | 645 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); |
618 | 646 | ||
@@ -760,29 +788,29 @@ void hci_conn_del_sysfs(struct hci_conn *conn); | |||
760 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) | 788 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) |
761 | 789 | ||
762 | /* ----- LMP capabilities ----- */ | 790 | /* ----- LMP capabilities ----- */ |
763 | #define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) | 791 | #define lmp_encrypt_capable(dev) ((dev)->features[0][0] & LMP_ENCRYPT) |
764 | #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) | 792 | #define lmp_rswitch_capable(dev) ((dev)->features[0][0] & LMP_RSWITCH) |
765 | #define lmp_hold_capable(dev) ((dev)->features[0] & LMP_HOLD) | 793 | #define lmp_hold_capable(dev) ((dev)->features[0][0] & LMP_HOLD) |
766 | #define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) | 794 | #define lmp_sniff_capable(dev) ((dev)->features[0][0] & LMP_SNIFF) |
767 | #define lmp_park_capable(dev) ((dev)->features[1] & LMP_PARK) | 795 | #define lmp_park_capable(dev) ((dev)->features[0][1] & LMP_PARK) |
768 | #define lmp_inq_rssi_capable(dev) ((dev)->features[3] & LMP_RSSI_INQ) | 796 | #define lmp_inq_rssi_capable(dev) ((dev)->features[0][3] & LMP_RSSI_INQ) |
769 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) | 797 | #define lmp_esco_capable(dev) ((dev)->features[0][3] & LMP_ESCO) |
770 | #define lmp_bredr_capable(dev) (!((dev)->features[4] & LMP_NO_BREDR)) | 798 | #define lmp_bredr_capable(dev) (!((dev)->features[0][4] & LMP_NO_BREDR)) |
771 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) | 799 | #define lmp_le_capable(dev) ((dev)->features[0][4] & LMP_LE) |
772 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) | 800 | #define lmp_sniffsubr_capable(dev) ((dev)->features[0][5] & LMP_SNIFF_SUBR) |
773 | #define lmp_pause_enc_capable(dev) ((dev)->features[5] & LMP_PAUSE_ENC) | 801 | #define lmp_pause_enc_capable(dev) ((dev)->features[0][5] & LMP_PAUSE_ENC) |
774 | #define lmp_ext_inq_capable(dev) ((dev)->features[6] & LMP_EXT_INQ) | 802 | #define lmp_ext_inq_capable(dev) ((dev)->features[0][6] & LMP_EXT_INQ) |
775 | #define lmp_le_br_capable(dev) !!((dev)->features[6] & LMP_SIMUL_LE_BR) | 803 | #define lmp_le_br_capable(dev) (!!((dev)->features[0][6] & LMP_SIMUL_LE_BR)) |
776 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) | 804 | #define lmp_ssp_capable(dev) ((dev)->features[0][6] & LMP_SIMPLE_PAIR) |
777 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) | 805 | #define lmp_no_flush_capable(dev) ((dev)->features[0][6] & LMP_NO_FLUSH) |
778 | #define lmp_lsto_capable(dev) ((dev)->features[7] & LMP_LSTO) | 806 | #define lmp_lsto_capable(dev) ((dev)->features[0][7] & LMP_LSTO) |
779 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[7] & LMP_INQ_TX_PWR) | 807 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[0][7] & LMP_INQ_TX_PWR) |
780 | #define lmp_ext_feat_capable(dev) ((dev)->features[7] & LMP_EXTFEATURES) | 808 | #define lmp_ext_feat_capable(dev) ((dev)->features[0][7] & LMP_EXTFEATURES) |
781 | 809 | ||
782 | /* ----- Extended LMP capabilities ----- */ | 810 | /* ----- Extended LMP capabilities ----- */ |
783 | #define lmp_host_ssp_capable(dev) ((dev)->host_features[0] & LMP_HOST_SSP) | 811 | #define lmp_host_ssp_capable(dev) ((dev)->features[1][0] & LMP_HOST_SSP) |
784 | #define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE) | 812 | #define lmp_host_le_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE)) |
785 | #define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR) | 813 | #define lmp_host_le_br_capable(dev) (!!((dev)->features[1][0] & LMP_HOST_LE_BREDR)) |
786 | 814 | ||
787 | /* returns true if at least one AMP active */ | 815 | /* returns true if at least one AMP active */ |
788 | static inline bool hci_amp_capable(void) | 816 | static inline bool hci_amp_capable(void) |
@@ -1054,8 +1082,14 @@ struct hci_request { | |||
1054 | void hci_req_init(struct hci_request *req, struct hci_dev *hdev); | 1082 | void hci_req_init(struct hci_request *req, struct hci_dev *hdev); |
1055 | int hci_req_run(struct hci_request *req, hci_req_complete_t complete); | 1083 | int hci_req_run(struct hci_request *req, hci_req_complete_t complete); |
1056 | void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void *param); | 1084 | void hci_req_add(struct hci_request *req, u16 opcode, u32 plen, void *param); |
1085 | void hci_req_add_ev(struct hci_request *req, u16 opcode, u32 plen, void *param, | ||
1086 | u8 event); | ||
1057 | void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); | 1087 | void hci_req_cmd_complete(struct hci_dev *hdev, u16 opcode, u8 status); |
1058 | void hci_req_cmd_status(struct hci_dev *hdev, u16 opcode, u8 status); | 1088 | |
1089 | struct sk_buff *__hci_cmd_sync(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
1090 | void *param, u32 timeout); | ||
1091 | struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen, | ||
1092 | void *param, u8 event, u32 timeout); | ||
1059 | 1093 | ||
1060 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); | 1094 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); |
1061 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); | 1095 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); |
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index cdd33021f831..fb94cf13c777 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -583,6 +583,14 @@ struct l2cap_conn { | |||
583 | 583 | ||
584 | struct list_head chan_l; | 584 | struct list_head chan_l; |
585 | struct mutex chan_lock; | 585 | struct mutex chan_lock; |
586 | struct kref ref; | ||
587 | struct list_head users; | ||
588 | }; | ||
589 | |||
590 | struct l2cap_user { | ||
591 | struct list_head list; | ||
592 | int (*probe) (struct l2cap_conn *conn, struct l2cap_user *user); | ||
593 | void (*remove) (struct l2cap_conn *conn, struct l2cap_user *user); | ||
586 | }; | 594 | }; |
587 | 595 | ||
588 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 596 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 |
@@ -786,6 +794,7 @@ extern bool disable_ertm; | |||
786 | 794 | ||
787 | int l2cap_init_sockets(void); | 795 | int l2cap_init_sockets(void); |
788 | void l2cap_cleanup_sockets(void); | 796 | void l2cap_cleanup_sockets(void); |
797 | bool l2cap_is_socket(struct socket *sock); | ||
789 | 798 | ||
790 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); | 799 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); |
791 | int __l2cap_wait_ack(struct sock *sk); | 800 | int __l2cap_wait_ack(struct sock *sk); |
@@ -812,4 +821,10 @@ void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan, | |||
812 | u8 status); | 821 | u8 status); |
813 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); | 822 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); |
814 | 823 | ||
824 | void l2cap_conn_get(struct l2cap_conn *conn); | ||
825 | void l2cap_conn_put(struct l2cap_conn *conn); | ||
826 | |||
827 | int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user); | ||
828 | void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user); | ||
829 | |||
815 | #endif /* __L2CAP_H */ | 830 | #endif /* __L2CAP_H */ |