diff options
author | John W. Linville <linville@tuxdriver.com> | 2012-06-13 15:12:07 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2012-06-13 15:12:07 -0400 |
commit | ec8eb9ae5819da011ac574aa290207a2a47cdbae (patch) | |
tree | ff7045c38e56624fd886837620a54daf54b6ba2a /include | |
parent | 9330969b8fd1304fdcb7c1825f1528eea38d321c (diff) | |
parent | 1d0c4da8f717937aeda47a72bc769d80f8776795 (diff) |
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
Diffstat (limited to 'include')
-rw-r--r-- | include/net/bluetooth/a2mp.h | 126 | ||||
-rw-r--r-- | include/net/bluetooth/bluetooth.h | 39 | ||||
-rw-r--r-- | include/net/bluetooth/hci.h | 99 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 29 | ||||
-rw-r--r-- | include/net/bluetooth/l2cap.h | 205 |
5 files changed, 286 insertions, 212 deletions
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h new file mode 100644 index 000000000000..6a76e0a0705e --- /dev/null +++ b/include/net/bluetooth/a2mp.h | |||
@@ -0,0 +1,126 @@ | |||
1 | /* | ||
2 | Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved. | ||
3 | Copyright (c) 2011,2012 Intel Corp. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License version 2 and | ||
7 | only version 2 as published by the Free Software Foundation. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #ifndef __A2MP_H | ||
16 | #define __A2MP_H | ||
17 | |||
18 | #include <net/bluetooth/l2cap.h> | ||
19 | |||
20 | #define A2MP_FEAT_EXT 0x8000 | ||
21 | |||
22 | struct amp_mgr { | ||
23 | struct l2cap_conn *l2cap_conn; | ||
24 | struct l2cap_chan *a2mp_chan; | ||
25 | struct kref kref; | ||
26 | __u8 ident; | ||
27 | __u8 handle; | ||
28 | unsigned long flags; | ||
29 | }; | ||
30 | |||
31 | struct a2mp_cmd { | ||
32 | __u8 code; | ||
33 | __u8 ident; | ||
34 | __le16 len; | ||
35 | __u8 data[0]; | ||
36 | } __packed; | ||
37 | |||
38 | /* A2MP command codes */ | ||
39 | #define A2MP_COMMAND_REJ 0x01 | ||
40 | struct a2mp_cmd_rej { | ||
41 | __le16 reason; | ||
42 | __u8 data[0]; | ||
43 | } __packed; | ||
44 | |||
45 | #define A2MP_DISCOVER_REQ 0x02 | ||
46 | struct a2mp_discov_req { | ||
47 | __le16 mtu; | ||
48 | __le16 ext_feat; | ||
49 | } __packed; | ||
50 | |||
51 | struct a2mp_cl { | ||
52 | __u8 id; | ||
53 | __u8 type; | ||
54 | __u8 status; | ||
55 | } __packed; | ||
56 | |||
57 | #define A2MP_DISCOVER_RSP 0x03 | ||
58 | struct a2mp_discov_rsp { | ||
59 | __le16 mtu; | ||
60 | __le16 ext_feat; | ||
61 | struct a2mp_cl cl[0]; | ||
62 | } __packed; | ||
63 | |||
64 | #define A2MP_CHANGE_NOTIFY 0x04 | ||
65 | #define A2MP_CHANGE_RSP 0x05 | ||
66 | |||
67 | #define A2MP_GETINFO_REQ 0x06 | ||
68 | struct a2mp_info_req { | ||
69 | __u8 id; | ||
70 | } __packed; | ||
71 | |||
72 | #define A2MP_GETINFO_RSP 0x07 | ||
73 | struct a2mp_info_rsp { | ||
74 | __u8 id; | ||
75 | __u8 status; | ||
76 | __le32 total_bw; | ||
77 | __le32 max_bw; | ||
78 | __le32 min_latency; | ||
79 | __le16 pal_cap; | ||
80 | __le16 assoc_size; | ||
81 | } __packed; | ||
82 | |||
83 | #define A2MP_GETAMPASSOC_REQ 0x08 | ||
84 | struct a2mp_amp_assoc_req { | ||
85 | __u8 id; | ||
86 | } __packed; | ||
87 | |||
88 | #define A2MP_GETAMPASSOC_RSP 0x09 | ||
89 | struct a2mp_amp_assoc_rsp { | ||
90 | __u8 id; | ||
91 | __u8 status; | ||
92 | __u8 amp_assoc[0]; | ||
93 | } __packed; | ||
94 | |||
95 | #define A2MP_CREATEPHYSLINK_REQ 0x0A | ||
96 | #define A2MP_DISCONNPHYSLINK_REQ 0x0C | ||
97 | struct a2mp_physlink_req { | ||
98 | __u8 local_id; | ||
99 | __u8 remote_id; | ||
100 | __u8 amp_assoc[0]; | ||
101 | } __packed; | ||
102 | |||
103 | #define A2MP_CREATEPHYSLINK_RSP 0x0B | ||
104 | #define A2MP_DISCONNPHYSLINK_RSP 0x0D | ||
105 | struct a2mp_physlink_rsp { | ||
106 | __u8 local_id; | ||
107 | __u8 remote_id; | ||
108 | __u8 status; | ||
109 | } __packed; | ||
110 | |||
111 | /* A2MP response status */ | ||
112 | #define A2MP_STATUS_SUCCESS 0x00 | ||
113 | #define A2MP_STATUS_INVALID_CTRL_ID 0x01 | ||
114 | #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02 | ||
115 | #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02 | ||
116 | #define A2MP_STATUS_COLLISION_OCCURED 0x03 | ||
117 | #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04 | ||
118 | #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05 | ||
119 | #define A2MP_STATUS_SECURITY_VIOLATION 0x06 | ||
120 | |||
121 | void amp_mgr_get(struct amp_mgr *mgr); | ||
122 | int amp_mgr_put(struct amp_mgr *mgr); | ||
123 | struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | ||
124 | struct sk_buff *skb); | ||
125 | |||
126 | #endif /* __A2MP_H */ | ||
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 961669b648fd..565d4bee1e49 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
4 | 4 | ||
@@ -12,22 +12,19 @@ | |||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | 19 | ||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
22 | SOFTWARE IS DISCLAIMED. | 22 | SOFTWARE IS DISCLAIMED. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __BLUETOOTH_H | 25 | #ifndef __BLUETOOTH_H |
26 | #define __BLUETOOTH_H | 26 | #define __BLUETOOTH_H |
27 | 27 | ||
28 | #include <asm/types.h> | ||
29 | #include <asm/byteorder.h> | ||
30 | #include <linux/list.h> | ||
31 | #include <linux/poll.h> | 28 | #include <linux/poll.h> |
32 | #include <net/sock.h> | 29 | #include <net/sock.h> |
33 | 30 | ||
@@ -168,8 +165,8 @@ typedef struct { | |||
168 | #define BDADDR_LE_PUBLIC 0x01 | 165 | #define BDADDR_LE_PUBLIC 0x01 |
169 | #define BDADDR_LE_RANDOM 0x02 | 166 | #define BDADDR_LE_RANDOM 0x02 |
170 | 167 | ||
171 | #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) | 168 | #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} }) |
172 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) | 169 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) |
173 | 170 | ||
174 | /* Copy, swap, convert BD Address */ | 171 | /* Copy, swap, convert BD Address */ |
175 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) | 172 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) |
@@ -215,7 +212,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
215 | struct msghdr *msg, size_t len, int flags); | 212 | struct msghdr *msg, size_t len, int flags); |
216 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | 213 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, |
217 | struct msghdr *msg, size_t len, int flags); | 214 | struct msghdr *msg, size_t len, int flags); |
218 | uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); | 215 | uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait); |
219 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); | 216 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); |
220 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); | 217 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); |
221 | 218 | ||
@@ -225,12 +222,12 @@ struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); | |||
225 | 222 | ||
226 | /* Skb helpers */ | 223 | /* Skb helpers */ |
227 | struct l2cap_ctrl { | 224 | struct l2cap_ctrl { |
228 | unsigned int sframe : 1, | 225 | unsigned int sframe:1, |
229 | poll : 1, | 226 | poll:1, |
230 | final : 1, | 227 | final:1, |
231 | fcs : 1, | 228 | fcs:1, |
232 | sar : 2, | 229 | sar:2, |
233 | super : 2; | 230 | super:2; |
234 | __u16 reqseq; | 231 | __u16 reqseq; |
235 | __u16 txseq; | 232 | __u16 txseq; |
236 | __u8 retries; | 233 | __u8 retries; |
@@ -249,7 +246,8 @@ static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) | |||
249 | { | 246 | { |
250 | struct sk_buff *skb; | 247 | struct sk_buff *skb; |
251 | 248 | ||
252 | if ((skb = alloc_skb(len + BT_SKB_RESERVE, how))) { | 249 | skb = alloc_skb(len + BT_SKB_RESERVE, how); |
250 | if (skb) { | ||
253 | skb_reserve(skb, BT_SKB_RESERVE); | 251 | skb_reserve(skb, BT_SKB_RESERVE); |
254 | bt_cb(skb)->incoming = 0; | 252 | bt_cb(skb)->incoming = 0; |
255 | } | 253 | } |
@@ -261,7 +259,8 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, | |||
261 | { | 259 | { |
262 | struct sk_buff *skb; | 260 | struct sk_buff *skb; |
263 | 261 | ||
264 | if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) { | 262 | skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err); |
263 | if (skb) { | ||
265 | skb_reserve(skb, BT_SKB_RESERVE); | 264 | skb_reserve(skb, BT_SKB_RESERVE); |
266 | bt_cb(skb)->incoming = 0; | 265 | bt_cb(skb)->incoming = 0; |
267 | } | 266 | } |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 66a7b579e31c..3f5d682e866f 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -30,6 +30,9 @@ | |||
30 | #define HCI_MAX_EVENT_SIZE 260 | 30 | #define HCI_MAX_EVENT_SIZE 260 |
31 | #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) | 31 | #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) |
32 | 32 | ||
33 | #define HCI_LINK_KEY_SIZE 16 | ||
34 | #define HCI_AMP_LINK_KEY_SIZE (2 * HCI_LINK_KEY_SIZE) | ||
35 | |||
33 | /* HCI dev events */ | 36 | /* HCI dev events */ |
34 | #define HCI_DEV_REG 1 | 37 | #define HCI_DEV_REG 1 |
35 | #define HCI_DEV_UNREG 2 | 38 | #define HCI_DEV_UNREG 2 |
@@ -56,9 +59,12 @@ | |||
56 | #define HCI_BREDR 0x00 | 59 | #define HCI_BREDR 0x00 |
57 | #define HCI_AMP 0x01 | 60 | #define HCI_AMP 0x01 |
58 | 61 | ||
62 | /* First BR/EDR Controller shall have ID = 0 */ | ||
63 | #define HCI_BREDR_ID 0 | ||
64 | |||
59 | /* HCI device quirks */ | 65 | /* HCI device quirks */ |
60 | enum { | 66 | enum { |
61 | HCI_QUIRK_NO_RESET, | 67 | HCI_QUIRK_RESET_ON_CLOSE, |
62 | HCI_QUIRK_RAW_DEVICE, | 68 | HCI_QUIRK_RAW_DEVICE, |
63 | HCI_QUIRK_FIXUP_BUFFER_SIZE | 69 | HCI_QUIRK_FIXUP_BUFFER_SIZE |
64 | }; | 70 | }; |
@@ -133,10 +139,8 @@ enum { | |||
133 | #define HCIINQUIRY _IOR('H', 240, int) | 139 | #define HCIINQUIRY _IOR('H', 240, int) |
134 | 140 | ||
135 | /* HCI timeouts */ | 141 | /* HCI timeouts */ |
136 | #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ | ||
137 | #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ | 142 | #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ |
138 | #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ | 143 | #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ |
139 | #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ | ||
140 | #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ | 144 | #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ |
141 | #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ | 145 | #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ |
142 | #define HCI_ACL_TX_TIMEOUT (45000) /* 45 seconds */ | 146 | #define HCI_ACL_TX_TIMEOUT (45000) /* 45 seconds */ |
@@ -371,7 +375,7 @@ struct hci_cp_reject_conn_req { | |||
371 | #define HCI_OP_LINK_KEY_REPLY 0x040b | 375 | #define HCI_OP_LINK_KEY_REPLY 0x040b |
372 | struct hci_cp_link_key_reply { | 376 | struct hci_cp_link_key_reply { |
373 | bdaddr_t bdaddr; | 377 | bdaddr_t bdaddr; |
374 | __u8 link_key[16]; | 378 | __u8 link_key[HCI_LINK_KEY_SIZE]; |
375 | } __packed; | 379 | } __packed; |
376 | 380 | ||
377 | #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c | 381 | #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c |
@@ -523,6 +527,28 @@ struct hci_cp_io_capability_neg_reply { | |||
523 | __u8 reason; | 527 | __u8 reason; |
524 | } __packed; | 528 | } __packed; |
525 | 529 | ||
530 | #define HCI_OP_CREATE_PHY_LINK 0x0435 | ||
531 | struct hci_cp_create_phy_link { | ||
532 | __u8 phy_handle; | ||
533 | __u8 key_len; | ||
534 | __u8 key_type; | ||
535 | __u8 key[HCI_AMP_LINK_KEY_SIZE]; | ||
536 | } __packed; | ||
537 | |||
538 | #define HCI_OP_ACCEPT_PHY_LINK 0x0436 | ||
539 | struct hci_cp_accept_phy_link { | ||
540 | __u8 phy_handle; | ||
541 | __u8 key_len; | ||
542 | __u8 key_type; | ||
543 | __u8 key[HCI_AMP_LINK_KEY_SIZE]; | ||
544 | } __packed; | ||
545 | |||
546 | #define HCI_OP_DISCONN_PHY_LINK 0x0437 | ||
547 | struct hci_cp_disconn_phy_link { | ||
548 | __u8 phy_handle; | ||
549 | __u8 reason; | ||
550 | } __packed; | ||
551 | |||
526 | #define HCI_OP_SNIFF_MODE 0x0803 | 552 | #define HCI_OP_SNIFF_MODE 0x0803 |
527 | struct hci_cp_sniff_mode { | 553 | struct hci_cp_sniff_mode { |
528 | __le16 handle; | 554 | __le16 handle; |
@@ -818,6 +844,31 @@ struct hci_rp_read_local_amp_info { | |||
818 | __le32 be_flush_to; | 844 | __le32 be_flush_to; |
819 | } __packed; | 845 | } __packed; |
820 | 846 | ||
847 | #define HCI_OP_READ_LOCAL_AMP_ASSOC 0x140a | ||
848 | struct hci_cp_read_local_amp_assoc { | ||
849 | __u8 phy_handle; | ||
850 | __le16 len_so_far; | ||
851 | __le16 max_len; | ||
852 | } __packed; | ||
853 | struct hci_rp_read_local_amp_assoc { | ||
854 | __u8 status; | ||
855 | __u8 phy_handle; | ||
856 | __le16 rem_len; | ||
857 | __u8 frag[0]; | ||
858 | } __packed; | ||
859 | |||
860 | #define HCI_OP_WRITE_REMOTE_AMP_ASSOC 0x140b | ||
861 | struct hci_cp_write_remote_amp_assoc { | ||
862 | __u8 phy_handle; | ||
863 | __le16 len_so_far; | ||
864 | __le16 rem_len; | ||
865 | __u8 frag[0]; | ||
866 | } __packed; | ||
867 | struct hci_rp_write_remote_amp_assoc { | ||
868 | __u8 status; | ||
869 | __u8 phy_handle; | ||
870 | } __packed; | ||
871 | |||
821 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 | 872 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 |
822 | struct hci_cp_le_set_event_mask { | 873 | struct hci_cp_le_set_event_mask { |
823 | __u8 mask[8]; | 874 | __u8 mask[8]; |
@@ -1048,7 +1099,7 @@ struct hci_ev_link_key_req { | |||
1048 | #define HCI_EV_LINK_KEY_NOTIFY 0x18 | 1099 | #define HCI_EV_LINK_KEY_NOTIFY 0x18 |
1049 | struct hci_ev_link_key_notify { | 1100 | struct hci_ev_link_key_notify { |
1050 | bdaddr_t bdaddr; | 1101 | bdaddr_t bdaddr; |
1051 | __u8 link_key[16]; | 1102 | __u8 link_key[HCI_LINK_KEY_SIZE]; |
1052 | __u8 key_type; | 1103 | __u8 key_type; |
1053 | } __packed; | 1104 | } __packed; |
1054 | 1105 | ||
@@ -1190,6 +1241,39 @@ struct hci_ev_le_meta { | |||
1190 | __u8 subevent; | 1241 | __u8 subevent; |
1191 | } __packed; | 1242 | } __packed; |
1192 | 1243 | ||
1244 | #define HCI_EV_PHY_LINK_COMPLETE 0x40 | ||
1245 | struct hci_ev_phy_link_complete { | ||
1246 | __u8 status; | ||
1247 | __u8 phy_handle; | ||
1248 | } __packed; | ||
1249 | |||
1250 | #define HCI_EV_CHANNEL_SELECTED 0x41 | ||
1251 | struct hci_ev_channel_selected { | ||
1252 | __u8 phy_handle; | ||
1253 | } __packed; | ||
1254 | |||
1255 | #define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42 | ||
1256 | struct hci_ev_disconn_phy_link_complete { | ||
1257 | __u8 status; | ||
1258 | __u8 phy_handle; | ||
1259 | __u8 reason; | ||
1260 | } __packed; | ||
1261 | |||
1262 | #define HCI_EV_LOGICAL_LINK_COMPLETE 0x45 | ||
1263 | struct hci_ev_logical_link_complete { | ||
1264 | __u8 status; | ||
1265 | __le16 handle; | ||
1266 | __u8 phy_handle; | ||
1267 | __u8 flow_spec_id; | ||
1268 | } __packed; | ||
1269 | |||
1270 | #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46 | ||
1271 | struct hci_ev_disconn_logical_link_complete { | ||
1272 | __u8 status; | ||
1273 | __le16 handle; | ||
1274 | __u8 reason; | ||
1275 | } __packed; | ||
1276 | |||
1193 | #define HCI_EV_NUM_COMP_BLOCKS 0x48 | 1277 | #define HCI_EV_NUM_COMP_BLOCKS 0x48 |
1194 | struct hci_comp_blocks_info { | 1278 | struct hci_comp_blocks_info { |
1195 | __le16 handle; | 1279 | __le16 handle; |
@@ -1290,7 +1374,6 @@ struct hci_sco_hdr { | |||
1290 | __u8 dlen; | 1374 | __u8 dlen; |
1291 | } __packed; | 1375 | } __packed; |
1292 | 1376 | ||
1293 | #include <linux/skbuff.h> | ||
1294 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) | 1377 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) |
1295 | { | 1378 | { |
1296 | return (struct hci_event_hdr *) skb->data; | 1379 | return (struct hci_event_hdr *) skb->data; |
@@ -1307,12 +1390,12 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) | |||
1307 | } | 1390 | } |
1308 | 1391 | ||
1309 | /* Command opcode pack/unpack */ | 1392 | /* Command opcode pack/unpack */ |
1310 | #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) | 1393 | #define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10))) |
1311 | #define hci_opcode_ogf(op) (op >> 10) | 1394 | #define hci_opcode_ogf(op) (op >> 10) |
1312 | #define hci_opcode_ocf(op) (op & 0x03ff) | 1395 | #define hci_opcode_ocf(op) (op & 0x03ff) |
1313 | 1396 | ||
1314 | /* ACL handle and flags pack/unpack */ | 1397 | /* ACL handle and flags pack/unpack */ |
1315 | #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) | 1398 | #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12))) |
1316 | #define hci_handle(h) (h & 0x0fff) | 1399 | #define hci_handle(h) (h & 0x0fff) |
1317 | #define hci_flags(h) (h >> 12) | 1400 | #define hci_flags(h) (h >> 12) |
1318 | 1401 | ||
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 9fc7728f94e4..20fd57367ddc 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -25,7 +25,6 @@ | |||
25 | #ifndef __HCI_CORE_H | 25 | #ifndef __HCI_CORE_H |
26 | #define __HCI_CORE_H | 26 | #define __HCI_CORE_H |
27 | 27 | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <net/bluetooth/hci.h> | 28 | #include <net/bluetooth/hci.h> |
30 | 29 | ||
31 | /* HCI priority */ | 30 | /* HCI priority */ |
@@ -65,7 +64,7 @@ struct discovery_state { | |||
65 | DISCOVERY_RESOLVING, | 64 | DISCOVERY_RESOLVING, |
66 | DISCOVERY_STOPPING, | 65 | DISCOVERY_STOPPING, |
67 | } state; | 66 | } state; |
68 | struct list_head all; /* All devices found during inquiry */ | 67 | struct list_head all; /* All devices found during inquiry */ |
69 | struct list_head unknown; /* Name state not known */ | 68 | struct list_head unknown; /* Name state not known */ |
70 | struct list_head resolve; /* Name needs to be resolved */ | 69 | struct list_head resolve; /* Name needs to be resolved */ |
71 | __u32 timestamp; | 70 | __u32 timestamp; |
@@ -105,7 +104,7 @@ struct link_key { | |||
105 | struct list_head list; | 104 | struct list_head list; |
106 | bdaddr_t bdaddr; | 105 | bdaddr_t bdaddr; |
107 | u8 type; | 106 | u8 type; |
108 | u8 val[16]; | 107 | u8 val[HCI_LINK_KEY_SIZE]; |
109 | u8 pin_len; | 108 | u8 pin_len; |
110 | }; | 109 | }; |
111 | 110 | ||
@@ -333,6 +332,7 @@ struct hci_conn { | |||
333 | void *l2cap_data; | 332 | void *l2cap_data; |
334 | void *sco_data; | 333 | void *sco_data; |
335 | void *smp_conn; | 334 | void *smp_conn; |
335 | struct amp_mgr *amp_mgr; | ||
336 | 336 | ||
337 | struct hci_conn *link; | 337 | struct hci_conn *link; |
338 | 338 | ||
@@ -360,7 +360,8 @@ extern int l2cap_connect_cfm(struct hci_conn *hcon, u8 status); | |||
360 | extern int l2cap_disconn_ind(struct hci_conn *hcon); | 360 | extern int l2cap_disconn_ind(struct hci_conn *hcon); |
361 | extern int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); | 361 | extern int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); |
362 | extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); | 362 | extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); |
363 | extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags); | 363 | extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, |
364 | u16 flags); | ||
364 | 365 | ||
365 | extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | 366 | extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); |
366 | extern int sco_connect_cfm(struct hci_conn *hcon, __u8 status); | 367 | extern int sco_connect_cfm(struct hci_conn *hcon, __u8 status); |
@@ -429,8 +430,8 @@ enum { | |||
429 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) | 430 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) |
430 | { | 431 | { |
431 | struct hci_dev *hdev = conn->hdev; | 432 | struct hci_dev *hdev = conn->hdev; |
432 | return (test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && | 433 | return test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && |
433 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags)); | 434 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); |
434 | } | 435 | } |
435 | 436 | ||
436 | static inline void hci_conn_hash_init(struct hci_dev *hdev) | 437 | static inline void hci_conn_hash_init(struct hci_dev *hdev) |
@@ -640,6 +641,19 @@ static inline void hci_set_drvdata(struct hci_dev *hdev, void *data) | |||
640 | dev_set_drvdata(&hdev->dev, data); | 641 | dev_set_drvdata(&hdev->dev, data); |
641 | } | 642 | } |
642 | 643 | ||
644 | /* hci_dev_list shall be locked */ | ||
645 | static inline uint8_t __hci_num_ctrl(void) | ||
646 | { | ||
647 | uint8_t count = 0; | ||
648 | struct list_head *p; | ||
649 | |||
650 | list_for_each(p, &hci_dev_list) { | ||
651 | count++; | ||
652 | } | ||
653 | |||
654 | return count; | ||
655 | } | ||
656 | |||
643 | struct hci_dev *hci_dev_get(int index); | 657 | struct hci_dev *hci_dev_get(int index); |
644 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); | 658 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); |
645 | 659 | ||
@@ -661,7 +675,8 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); | |||
661 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); | 675 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); |
662 | int hci_inquiry(void __user *arg); | 676 | int hci_inquiry(void __user *arg); |
663 | 677 | ||
664 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); | 678 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, |
679 | bdaddr_t *bdaddr); | ||
665 | int hci_blacklist_clear(struct hci_dev *hdev); | 680 | int hci_blacklist_clear(struct hci_dev *hdev); |
666 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 681 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); |
667 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 682 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); |
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 1c7d1cd5e679..d80e3f0691b4 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -40,11 +40,11 @@ | |||
40 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ | 40 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ |
41 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ | 41 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
42 | #define L2CAP_DEFAULT_ACK_TO 200 | 42 | #define L2CAP_DEFAULT_ACK_TO 200 |
43 | #define L2CAP_LE_DEFAULT_MTU 23 | ||
44 | #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF | 43 | #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF |
45 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF | 44 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF |
46 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF | 45 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF |
47 | #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */ | 46 | #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */ |
47 | #define L2CAP_LE_MIN_MTU 23 | ||
48 | 48 | ||
49 | #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) | 49 | #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) |
50 | #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) | 50 | #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) |
@@ -52,6 +52,8 @@ | |||
52 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) | 52 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) |
53 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) | 53 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) |
54 | 54 | ||
55 | #define L2CAP_A2MP_DEFAULT_MTU 670 | ||
56 | |||
55 | /* L2CAP socket address */ | 57 | /* L2CAP socket address */ |
56 | struct sockaddr_l2 { | 58 | struct sockaddr_l2 { |
57 | sa_family_t l2_family; | 59 | sa_family_t l2_family; |
@@ -229,9 +231,14 @@ struct l2cap_conn_rsp { | |||
229 | __le16 status; | 231 | __le16 status; |
230 | } __packed; | 232 | } __packed; |
231 | 233 | ||
234 | /* protocol/service multiplexer (PSM) */ | ||
235 | #define L2CAP_PSM_SDP 0x0001 | ||
236 | #define L2CAP_PSM_RFCOMM 0x0003 | ||
237 | |||
232 | /* channel indentifier */ | 238 | /* channel indentifier */ |
233 | #define L2CAP_CID_SIGNALING 0x0001 | 239 | #define L2CAP_CID_SIGNALING 0x0001 |
234 | #define L2CAP_CID_CONN_LESS 0x0002 | 240 | #define L2CAP_CID_CONN_LESS 0x0002 |
241 | #define L2CAP_CID_A2MP 0x0003 | ||
235 | #define L2CAP_CID_LE_DATA 0x0004 | 242 | #define L2CAP_CID_LE_DATA 0x0004 |
236 | #define L2CAP_CID_LE_SIGNALING 0x0005 | 243 | #define L2CAP_CID_LE_SIGNALING 0x0005 |
237 | #define L2CAP_CID_SMP 0x0006 | 244 | #define L2CAP_CID_SMP 0x0006 |
@@ -271,6 +278,9 @@ struct l2cap_conf_rsp { | |||
271 | #define L2CAP_CONF_PENDING 0x0004 | 278 | #define L2CAP_CONF_PENDING 0x0004 |
272 | #define L2CAP_CONF_EFS_REJECT 0x0005 | 279 | #define L2CAP_CONF_EFS_REJECT 0x0005 |
273 | 280 | ||
281 | /* configuration req/rsp continuation flag */ | ||
282 | #define L2CAP_CONF_FLAG_CONTINUATION 0x0001 | ||
283 | |||
274 | struct l2cap_conf_opt { | 284 | struct l2cap_conf_opt { |
275 | __u8 type; | 285 | __u8 type; |
276 | __u8 len; | 286 | __u8 len; |
@@ -419,11 +429,6 @@ struct l2cap_seq_list { | |||
419 | #define L2CAP_SEQ_LIST_CLEAR 0xFFFF | 429 | #define L2CAP_SEQ_LIST_CLEAR 0xFFFF |
420 | #define L2CAP_SEQ_LIST_TAIL 0x8000 | 430 | #define L2CAP_SEQ_LIST_TAIL 0x8000 |
421 | 431 | ||
422 | struct srej_list { | ||
423 | __u16 tx_seq; | ||
424 | struct list_head list; | ||
425 | }; | ||
426 | |||
427 | struct l2cap_chan { | 432 | struct l2cap_chan { |
428 | struct sock *sk; | 433 | struct sock *sk; |
429 | 434 | ||
@@ -475,14 +480,12 @@ struct l2cap_chan { | |||
475 | __u16 expected_ack_seq; | 480 | __u16 expected_ack_seq; |
476 | __u16 expected_tx_seq; | 481 | __u16 expected_tx_seq; |
477 | __u16 buffer_seq; | 482 | __u16 buffer_seq; |
478 | __u16 buffer_seq_srej; | ||
479 | __u16 srej_save_reqseq; | 483 | __u16 srej_save_reqseq; |
480 | __u16 last_acked_seq; | 484 | __u16 last_acked_seq; |
481 | __u16 frames_sent; | 485 | __u16 frames_sent; |
482 | __u16 unacked_frames; | 486 | __u16 unacked_frames; |
483 | __u8 retry_count; | 487 | __u8 retry_count; |
484 | __u16 srej_queue_next; | 488 | __u16 srej_queue_next; |
485 | __u8 num_acked; | ||
486 | __u16 sdu_len; | 489 | __u16 sdu_len; |
487 | struct sk_buff *sdu; | 490 | struct sk_buff *sdu; |
488 | struct sk_buff *sdu_last_frag; | 491 | struct sk_buff *sdu_last_frag; |
@@ -515,7 +518,6 @@ struct l2cap_chan { | |||
515 | struct sk_buff_head srej_q; | 518 | struct sk_buff_head srej_q; |
516 | struct l2cap_seq_list srej_list; | 519 | struct l2cap_seq_list srej_list; |
517 | struct l2cap_seq_list retrans_list; | 520 | struct l2cap_seq_list retrans_list; |
518 | struct list_head srej_l; | ||
519 | 521 | ||
520 | struct list_head list; | 522 | struct list_head list; |
521 | struct list_head global_l; | 523 | struct list_head global_l; |
@@ -528,10 +530,14 @@ struct l2cap_chan { | |||
528 | struct l2cap_ops { | 530 | struct l2cap_ops { |
529 | char *name; | 531 | char *name; |
530 | 532 | ||
531 | struct l2cap_chan *(*new_connection) (void *data); | 533 | struct l2cap_chan *(*new_connection) (struct l2cap_chan *chan); |
532 | int (*recv) (void *data, struct sk_buff *skb); | 534 | int (*recv) (struct l2cap_chan * chan, |
533 | void (*close) (void *data); | 535 | struct sk_buff *skb); |
534 | void (*state_change) (void *data, int state); | 536 | void (*teardown) (struct l2cap_chan *chan, int err); |
537 | void (*close) (struct l2cap_chan *chan); | ||
538 | void (*state_change) (struct l2cap_chan *chan, | ||
539 | int state); | ||
540 | void (*ready) (struct l2cap_chan *chan); | ||
535 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, | 541 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, |
536 | unsigned long len, int nb); | 542 | unsigned long len, int nb); |
537 | }; | 543 | }; |
@@ -575,6 +581,7 @@ struct l2cap_conn { | |||
575 | #define L2CAP_CHAN_RAW 1 | 581 | #define L2CAP_CHAN_RAW 1 |
576 | #define L2CAP_CHAN_CONN_LESS 2 | 582 | #define L2CAP_CHAN_CONN_LESS 2 |
577 | #define L2CAP_CHAN_CONN_ORIENTED 3 | 583 | #define L2CAP_CHAN_CONN_ORIENTED 3 |
584 | #define L2CAP_CHAN_CONN_FIX_A2MP 4 | ||
578 | 585 | ||
579 | /* ----- L2CAP socket info ----- */ | 586 | /* ----- L2CAP socket info ----- */ |
580 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 587 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) |
@@ -597,6 +604,7 @@ enum { | |||
597 | CONF_EWS_RECV, | 604 | CONF_EWS_RECV, |
598 | CONF_LOC_CONF_PEND, | 605 | CONF_LOC_CONF_PEND, |
599 | CONF_REM_CONF_PEND, | 606 | CONF_REM_CONF_PEND, |
607 | CONF_NOT_COMPLETE, | ||
600 | }; | 608 | }; |
601 | 609 | ||
602 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 610 | #define L2CAP_CONF_MAX_CONF_REQ 2 |
@@ -713,11 +721,7 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan, | |||
713 | 721 | ||
714 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) | 722 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) |
715 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) | 723 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) |
716 | #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ | ||
717 | msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); | ||
718 | #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) | 724 | #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) |
719 | #define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ | ||
720 | msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); | ||
721 | #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) | 725 | #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) |
722 | #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ | 726 | #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ |
723 | msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | 727 | msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); |
@@ -736,173 +740,17 @@ static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) | |||
736 | return (seq + 1) % (chan->tx_win_max + 1); | 740 | return (seq + 1) % (chan->tx_win_max + 1); |
737 | } | 741 | } |
738 | 742 | ||
739 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) | 743 | static inline struct l2cap_chan *l2cap_chan_no_new_connection(struct l2cap_chan *chan) |
740 | { | ||
741 | int sub; | ||
742 | |||
743 | sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; | ||
744 | |||
745 | if (sub < 0) | ||
746 | sub += 64; | ||
747 | |||
748 | return sub == ch->remote_tx_win; | ||
749 | } | ||
750 | |||
751 | static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) | ||
752 | { | ||
753 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
754 | return (ctrl & L2CAP_EXT_CTRL_REQSEQ) >> | ||
755 | L2CAP_EXT_CTRL_REQSEQ_SHIFT; | ||
756 | else | ||
757 | return (ctrl & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT; | ||
758 | } | ||
759 | |||
760 | static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) | ||
761 | { | 744 | { |
762 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | 745 | return NULL; |
763 | return (reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT) & | ||
764 | L2CAP_EXT_CTRL_REQSEQ; | ||
765 | else | ||
766 | return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; | ||
767 | } | 746 | } |
768 | 747 | ||
769 | static inline __u16 __get_txseq(struct l2cap_chan *chan, __u32 ctrl) | 748 | static inline void l2cap_chan_no_teardown(struct l2cap_chan *chan, int err) |
770 | { | 749 | { |
771 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
772 | return (ctrl & L2CAP_EXT_CTRL_TXSEQ) >> | ||
773 | L2CAP_EXT_CTRL_TXSEQ_SHIFT; | ||
774 | else | ||
775 | return (ctrl & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT; | ||
776 | } | 750 | } |
777 | 751 | ||
778 | static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) | 752 | static inline void l2cap_chan_no_ready(struct l2cap_chan *chan) |
779 | { | 753 | { |
780 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
781 | return (txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT) & | ||
782 | L2CAP_EXT_CTRL_TXSEQ; | ||
783 | else | ||
784 | return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; | ||
785 | } | ||
786 | |||
787 | static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) | ||
788 | { | ||
789 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
790 | return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; | ||
791 | else | ||
792 | return ctrl & L2CAP_CTRL_FRAME_TYPE; | ||
793 | } | ||
794 | |||
795 | static inline __u32 __set_sframe(struct l2cap_chan *chan) | ||
796 | { | ||
797 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
798 | return L2CAP_EXT_CTRL_FRAME_TYPE; | ||
799 | else | ||
800 | return L2CAP_CTRL_FRAME_TYPE; | ||
801 | } | ||
802 | |||
803 | static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) | ||
804 | { | ||
805 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
806 | return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT; | ||
807 | else | ||
808 | return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT; | ||
809 | } | ||
810 | |||
811 | static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar) | ||
812 | { | ||
813 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
814 | return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR; | ||
815 | else | ||
816 | return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR; | ||
817 | } | ||
818 | |||
819 | static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl) | ||
820 | { | ||
821 | return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START; | ||
822 | } | ||
823 | |||
824 | static inline __u32 __get_sar_mask(struct l2cap_chan *chan) | ||
825 | { | ||
826 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
827 | return L2CAP_EXT_CTRL_SAR; | ||
828 | else | ||
829 | return L2CAP_CTRL_SAR; | ||
830 | } | ||
831 | |||
832 | static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) | ||
833 | { | ||
834 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
835 | return (ctrl & L2CAP_EXT_CTRL_SUPERVISE) >> | ||
836 | L2CAP_EXT_CTRL_SUPER_SHIFT; | ||
837 | else | ||
838 | return (ctrl & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT; | ||
839 | } | ||
840 | |||
841 | static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) | ||
842 | { | ||
843 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
844 | return (super << L2CAP_EXT_CTRL_SUPER_SHIFT) & | ||
845 | L2CAP_EXT_CTRL_SUPERVISE; | ||
846 | else | ||
847 | return (super << L2CAP_CTRL_SUPER_SHIFT) & | ||
848 | L2CAP_CTRL_SUPERVISE; | ||
849 | } | ||
850 | |||
851 | static inline __u32 __set_ctrl_final(struct l2cap_chan *chan) | ||
852 | { | ||
853 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
854 | return L2CAP_EXT_CTRL_FINAL; | ||
855 | else | ||
856 | return L2CAP_CTRL_FINAL; | ||
857 | } | ||
858 | |||
859 | static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) | ||
860 | { | ||
861 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
862 | return ctrl & L2CAP_EXT_CTRL_FINAL; | ||
863 | else | ||
864 | return ctrl & L2CAP_CTRL_FINAL; | ||
865 | } | ||
866 | |||
867 | static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan) | ||
868 | { | ||
869 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
870 | return L2CAP_EXT_CTRL_POLL; | ||
871 | else | ||
872 | return L2CAP_CTRL_POLL; | ||
873 | } | ||
874 | |||
875 | static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) | ||
876 | { | ||
877 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
878 | return ctrl & L2CAP_EXT_CTRL_POLL; | ||
879 | else | ||
880 | return ctrl & L2CAP_CTRL_POLL; | ||
881 | } | ||
882 | |||
883 | static inline __u32 __get_control(struct l2cap_chan *chan, void *p) | ||
884 | { | ||
885 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
886 | return get_unaligned_le32(p); | ||
887 | else | ||
888 | return get_unaligned_le16(p); | ||
889 | } | ||
890 | |||
891 | static inline void __put_control(struct l2cap_chan *chan, __u32 control, | ||
892 | void *p) | ||
893 | { | ||
894 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
895 | return put_unaligned_le32(control, p); | ||
896 | else | ||
897 | return put_unaligned_le16(control, p); | ||
898 | } | ||
899 | |||
900 | static inline __u8 __ctrl_size(struct l2cap_chan *chan) | ||
901 | { | ||
902 | if (test_bit(FLAG_EXT_CTRL, &chan->flags)) | ||
903 | return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE; | ||
904 | else | ||
905 | return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; | ||
906 | } | 754 | } |
907 | 755 | ||
908 | extern bool disable_ertm; | 756 | extern bool disable_ertm; |
@@ -926,5 +774,8 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, | |||
926 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); | 774 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
927 | int l2cap_chan_check_security(struct l2cap_chan *chan); | 775 | int l2cap_chan_check_security(struct l2cap_chan *chan); |
928 | void l2cap_chan_set_defaults(struct l2cap_chan *chan); | 776 | void l2cap_chan_set_defaults(struct l2cap_chan *chan); |
777 | int l2cap_ertm_init(struct l2cap_chan *chan); | ||
778 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); | ||
779 | void l2cap_chan_del(struct l2cap_chan *chan, int err); | ||
929 | 780 | ||
930 | #endif /* __L2CAP_H */ | 781 | #endif /* __L2CAP_H */ |