xref: /openbmc/linux/include/net/bluetooth/l2cap.h (revision f19425641cb2572a33cb074d5e30283720bd4d22)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds    BlueZ - Bluetooth protocol stack for Linux
31da177e4SLinus Torvalds    Copyright (C) 2000-2001 Qualcomm Incorporated
4ce5706bdSGustavo F. Padovan    Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org>
55d8868ffSGustavo F. Padovan    Copyright (C) 2010 Google Inc.
61da177e4SLinus Torvalds 
71da177e4SLinus Torvalds    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds    This program is free software; you can redistribute it and/or modify
101da177e4SLinus Torvalds    it under the terms of the GNU General Public License version 2 as
111da177e4SLinus Torvalds    published by the Free Software Foundation;
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
141da177e4SLinus Torvalds    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
151da177e4SLinus Torvalds    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
161da177e4SLinus Torvalds    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
171da177e4SLinus Torvalds    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
181da177e4SLinus Torvalds    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
191da177e4SLinus Torvalds    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
201da177e4SLinus Torvalds    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
231da177e4SLinus Torvalds    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
241da177e4SLinus Torvalds    SOFTWARE IS DISCLAIMED.
251da177e4SLinus Torvalds */
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds #ifndef __L2CAP_H
281da177e4SLinus Torvalds #define __L2CAP_H
291da177e4SLinus Torvalds 
3088843ab0SAndrei Emeltchenko #include <asm/unaligned.h>
31abe84903SJohan Hedberg #include <linux/atomic.h>
3288843ab0SAndrei Emeltchenko 
331da177e4SLinus Torvalds /* L2CAP defaults */
341da177e4SLinus Torvalds #define L2CAP_DEFAULT_MTU		672
35f2fcfcd6SGustavo F. Padovan #define L2CAP_DEFAULT_MIN_MTU		48
368936fa6dSAndrei Emeltchenko #define L2CAP_DEFAULT_FLUSH_TO		0xFFFF
378936fa6dSAndrei Emeltchenko #define L2CAP_EFS_DEFAULT_FLUSH_TO	0xFFFFFFFF
381c2acffbSGustavo F. Padovan #define L2CAP_DEFAULT_TX_WINDOW		63
396327eb98SAndrei Emeltchenko #define L2CAP_DEFAULT_EXT_WINDOW	0x3FFF
40e90bac06SGustavo F. Padovan #define L2CAP_DEFAULT_MAX_TX		3
41fa235562SMat Martineau #define L2CAP_DEFAULT_RETRANS_TO	2000    /* 2 seconds */
42e90bac06SGustavo F. Padovan #define L2CAP_DEFAULT_MONITOR_TO	12000   /* 12 seconds */
430b4558e3SAndrei Emeltchenko #define L2CAP_DEFAULT_MAX_PDU_SIZE	1492    /* Sized for AMP packet */
44c1b4f43bSGustavo F. Padovan #define L2CAP_DEFAULT_ACK_TO		200
458f7975b1SAndrei Emeltchenko #define L2CAP_DEFAULT_MAX_SDU_SIZE	0xFFFF
468f7975b1SAndrei Emeltchenko #define L2CAP_DEFAULT_SDU_ITIME		0xFFFFFFFF
478f7975b1SAndrei Emeltchenko #define L2CAP_DEFAULT_ACC_LAT		0xFFFFFFFF
4894122bbeSMat Martineau #define L2CAP_BREDR_MAX_PAYLOAD		1019    /* 3-DH5 packet */
498c3a4f00SAndre Guedes #define L2CAP_LE_MIN_MTU		23
50da49b602SLuiz Augusto von Dentz #define L2CAP_ECRED_CONN_SCID_MAX	5
511da177e4SLinus Torvalds 
52ba13ccd9SMarcel Holtmann #define L2CAP_DISC_TIMEOUT		msecs_to_jiffies(100)
53ba13ccd9SMarcel Holtmann #define L2CAP_DISC_REJ_TIMEOUT		msecs_to_jiffies(5000)
54ba13ccd9SMarcel Holtmann #define L2CAP_ENC_TIMEOUT		msecs_to_jiffies(5000)
55ba13ccd9SMarcel Holtmann #define L2CAP_CONN_TIMEOUT		msecs_to_jiffies(40000)
56ba13ccd9SMarcel Holtmann #define L2CAP_INFO_TIMEOUT		msecs_to_jiffies(4000)
575b155ef9SMat Martineau #define L2CAP_MOVE_TIMEOUT		msecs_to_jiffies(4000)
585b155ef9SMat Martineau #define L2CAP_MOVE_ERTX_TIMEOUT		msecs_to_jiffies(60000)
59cb02a255SDean Jenkins #define L2CAP_WAIT_ACK_POLL_PERIOD	msecs_to_jiffies(200)
60e432c72cSDean Jenkins #define L2CAP_WAIT_ACK_TIMEOUT		msecs_to_jiffies(10000)
611da177e4SLinus Torvalds 
62466f8004SAndrei Emeltchenko #define L2CAP_A2MP_DEFAULT_MTU		670
63466f8004SAndrei Emeltchenko 
641da177e4SLinus Torvalds /* L2CAP socket address */
651da177e4SLinus Torvalds struct sockaddr_l2 {
661da177e4SLinus Torvalds 	sa_family_t	l2_family;
678e036fc3SAl Viro 	__le16		l2_psm;
681da177e4SLinus Torvalds 	bdaddr_t	l2_bdaddr;
69f29972deSMarcel Holtmann 	__le16		l2_cid;
7043ef0b8bSAndre Guedes 	__u8		l2_bdaddr_type;
711da177e4SLinus Torvalds };
721da177e4SLinus Torvalds 
731da177e4SLinus Torvalds /* L2CAP socket options */
741da177e4SLinus Torvalds #define L2CAP_OPTIONS	0x01
751da177e4SLinus Torvalds struct l2cap_options {
761da177e4SLinus Torvalds 	__u16 omtu;
771da177e4SLinus Torvalds 	__u16 imtu;
781da177e4SLinus Torvalds 	__u16 flush_to;
791da177e4SLinus Torvalds 	__u8  mode;
80fcc203c3SGustavo F. Padovan 	__u8  fcs;
8168d7f0ceSGustavo F. Padovan 	__u8  max_tx;
8214b5aa71SGustavo F. Padovan 	__u16 txwin_size;
831da177e4SLinus Torvalds };
841da177e4SLinus Torvalds 
851da177e4SLinus Torvalds #define L2CAP_CONNINFO	0x02
861da177e4SLinus Torvalds struct l2cap_conninfo {
871da177e4SLinus Torvalds 	__u16 hci_handle;
881da177e4SLinus Torvalds 	__u8  dev_class[3];
891da177e4SLinus Torvalds };
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds #define L2CAP_LM	0x03
921da177e4SLinus Torvalds #define L2CAP_LM_MASTER		0x0001
931da177e4SLinus Torvalds #define L2CAP_LM_AUTH		0x0002
941da177e4SLinus Torvalds #define L2CAP_LM_ENCRYPT	0x0004
951da177e4SLinus Torvalds #define L2CAP_LM_TRUSTED	0x0008
961da177e4SLinus Torvalds #define L2CAP_LM_RELIABLE	0x0010
971da177e4SLinus Torvalds #define L2CAP_LM_SECURE		0x0020
987d513e92SMarcel Holtmann #define L2CAP_LM_FIPS		0x0040
991da177e4SLinus Torvalds 
1001da177e4SLinus Torvalds /* L2CAP command codes */
1011da177e4SLinus Torvalds #define L2CAP_COMMAND_REJ	0x01
1021da177e4SLinus Torvalds #define L2CAP_CONN_REQ		0x02
1031da177e4SLinus Torvalds #define L2CAP_CONN_RSP		0x03
1041da177e4SLinus Torvalds #define L2CAP_CONF_REQ		0x04
1051da177e4SLinus Torvalds #define L2CAP_CONF_RSP		0x05
1061da177e4SLinus Torvalds #define L2CAP_DISCONN_REQ	0x06
1071da177e4SLinus Torvalds #define L2CAP_DISCONN_RSP	0x07
1081da177e4SLinus Torvalds #define L2CAP_ECHO_REQ		0x08
1091da177e4SLinus Torvalds #define L2CAP_ECHO_RSP		0x09
1101da177e4SLinus Torvalds #define L2CAP_INFO_REQ		0x0a
1111da177e4SLinus Torvalds #define L2CAP_INFO_RSP		0x0b
11238094c75SMat Martineau #define L2CAP_CREATE_CHAN_REQ	0x0c
11338094c75SMat Martineau #define L2CAP_CREATE_CHAN_RSP	0x0d
11438094c75SMat Martineau #define L2CAP_MOVE_CHAN_REQ	0x0e
11538094c75SMat Martineau #define L2CAP_MOVE_CHAN_RSP	0x0f
11638094c75SMat Martineau #define L2CAP_MOVE_CHAN_CFM	0x10
11738094c75SMat Martineau #define L2CAP_MOVE_CHAN_CFM_RSP	0x11
1183300d9a9SClaudio Takahasi #define L2CAP_CONN_PARAM_UPDATE_REQ	0x12
1193300d9a9SClaudio Takahasi #define L2CAP_CONN_PARAM_UPDATE_RSP	0x13
120ee5ec5cfSJohan Hedberg #define L2CAP_LE_CONN_REQ	0x14
121ee5ec5cfSJohan Hedberg #define L2CAP_LE_CONN_RSP	0x15
122ee5ec5cfSJohan Hedberg #define L2CAP_LE_CREDITS	0x16
12314572096SLuiz Augusto von Dentz #define L2CAP_ECRED_CONN_REQ	0x17
12414572096SLuiz Augusto von Dentz #define L2CAP_ECRED_CONN_RSP	0x18
12514572096SLuiz Augusto von Dentz #define L2CAP_ECRED_RECONF_REQ	0x19
12614572096SLuiz Augusto von Dentz #define L2CAP_ECRED_RECONF_RSP	0x1a
1271da177e4SLinus Torvalds 
128a858393bSAndrei Emeltchenko /* L2CAP extended feature mask */
12947ec1dcdSMarcel Holtmann #define L2CAP_FEAT_FLOWCTL	0x00000001
13047ec1dcdSMarcel Holtmann #define L2CAP_FEAT_RETRANS	0x00000002
131a858393bSAndrei Emeltchenko #define L2CAP_FEAT_BIDIR_QOS	0x00000004
13247ec1dcdSMarcel Holtmann #define L2CAP_FEAT_ERTM		0x00000008
13347ec1dcdSMarcel Holtmann #define L2CAP_FEAT_STREAMING	0x00000010
13447ec1dcdSMarcel Holtmann #define L2CAP_FEAT_FCS		0x00000020
135a858393bSAndrei Emeltchenko #define L2CAP_FEAT_EXT_FLOW	0x00000040
13647ec1dcdSMarcel Holtmann #define L2CAP_FEAT_FIXED_CHAN	0x00000080
137a858393bSAndrei Emeltchenko #define L2CAP_FEAT_EXT_WINDOW	0x00000100
138a858393bSAndrei Emeltchenko #define L2CAP_FEAT_UCD		0x00000200
13947ec1dcdSMarcel Holtmann 
14047ec1dcdSMarcel Holtmann /* L2CAP checksum option */
14147ec1dcdSMarcel Holtmann #define L2CAP_FCS_NONE		0x00
14247ec1dcdSMarcel Holtmann #define L2CAP_FCS_CRC16		0x01
14347ec1dcdSMarcel Holtmann 
144d835ac0fSMat Martineau /* L2CAP fixed channels */
145a6801ca9SMarcel Holtmann #define L2CAP_FC_SIG_BREDR	0x02
146d40bffbcSMarcel Holtmann #define L2CAP_FC_CONNLESS	0x04
147d835ac0fSMat Martineau #define L2CAP_FC_A2MP		0x08
148a6801ca9SMarcel Holtmann #define L2CAP_FC_ATT		0x10
149a6801ca9SMarcel Holtmann #define L2CAP_FC_SIG_LE		0x20
150a6801ca9SMarcel Holtmann #define L2CAP_FC_SMP_LE		0x40
151ef8efe4bSJohan Hedberg #define L2CAP_FC_SMP_BREDR	0x80
152d835ac0fSMat Martineau 
1531c2acffbSGustavo F. Padovan /* L2CAP Control Field bit masks */
1541c2acffbSGustavo F. Padovan #define L2CAP_CTRL_SAR			0xC000
1551c2acffbSGustavo F. Padovan #define L2CAP_CTRL_REQSEQ		0x3F00
1561c2acffbSGustavo F. Padovan #define L2CAP_CTRL_TXSEQ		0x007E
15757253fd8SAndrei Emeltchenko #define L2CAP_CTRL_SUPERVISE		0x000C
15857253fd8SAndrei Emeltchenko 
1591c2acffbSGustavo F. Padovan #define L2CAP_CTRL_RETRANS		0x0080
1601c2acffbSGustavo F. Padovan #define L2CAP_CTRL_FINAL		0x0080
1611c2acffbSGustavo F. Padovan #define L2CAP_CTRL_POLL			0x0010
1621c2acffbSGustavo F. Padovan #define L2CAP_CTRL_FRAME_TYPE		0x0001 /* I- or S-Frame */
1631c2acffbSGustavo F. Padovan 
1641c2acffbSGustavo F. Padovan #define L2CAP_CTRL_TXSEQ_SHIFT		1
16557253fd8SAndrei Emeltchenko #define L2CAP_CTRL_SUPER_SHIFT		2
166d5f7ac38SMat Martineau #define L2CAP_CTRL_POLL_SHIFT		4
167d5f7ac38SMat Martineau #define L2CAP_CTRL_FINAL_SHIFT		7
1681c2acffbSGustavo F. Padovan #define L2CAP_CTRL_REQSEQ_SHIFT		8
1698f17154fSGustavo F. Padovan #define L2CAP_CTRL_SAR_SHIFT		14
1701c2acffbSGustavo F. Padovan 
17157253fd8SAndrei Emeltchenko /* L2CAP Extended Control Field bit mask */
17257253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_TXSEQ		0xFFFC0000
17357253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_SAR		0x00030000
17457253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_SUPERVISE	0x00030000
17557253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_REQSEQ		0x0000FFFC
17657253fd8SAndrei Emeltchenko 
17757253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_POLL		0x00040000
17857253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_FINAL		0x00000002
17957253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_FRAME_TYPE	0x00000001 /* I- or S-Frame */
18057253fd8SAndrei Emeltchenko 
181d5f7ac38SMat Martineau #define L2CAP_EXT_CTRL_FINAL_SHIFT	1
18257253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_REQSEQ_SHIFT	2
18357253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_SAR_SHIFT	16
18457253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_SUPER_SHIFT	16
185d5f7ac38SMat Martineau #define L2CAP_EXT_CTRL_POLL_SHIFT	18
18657253fd8SAndrei Emeltchenko #define L2CAP_EXT_CTRL_TXSEQ_SHIFT	18
18757253fd8SAndrei Emeltchenko 
1881c2acffbSGustavo F. Padovan /* L2CAP Supervisory Function */
189ab784b73SAndrei Emeltchenko #define L2CAP_SUPER_RR		0x00
190ab784b73SAndrei Emeltchenko #define L2CAP_SUPER_REJ		0x01
191ab784b73SAndrei Emeltchenko #define L2CAP_SUPER_RNR		0x02
192ab784b73SAndrei Emeltchenko #define L2CAP_SUPER_SREJ	0x03
1931c2acffbSGustavo F. Padovan 
1941c2acffbSGustavo F. Padovan /* L2CAP Segmentation and Reassembly */
1957e0ef6eeSAndrei Emeltchenko #define L2CAP_SAR_UNSEGMENTED	0x00
1967e0ef6eeSAndrei Emeltchenko #define L2CAP_SAR_START		0x01
1977e0ef6eeSAndrei Emeltchenko #define L2CAP_SAR_END		0x02
1987e0ef6eeSAndrei Emeltchenko #define L2CAP_SAR_CONTINUE	0x03
1991c2acffbSGustavo F. Padovan 
200e2fd318eSIlia Kolomisnky /* L2CAP Command rej. reasons */
201e2fd318eSIlia Kolomisnky #define L2CAP_REJ_NOT_UNDERSTOOD	0x0000
202e2fd318eSIlia Kolomisnky #define L2CAP_REJ_MTU_EXCEEDED		0x0001
203e2fd318eSIlia Kolomisnky #define L2CAP_REJ_INVALID_CID		0x0002
204e2fd318eSIlia Kolomisnky 
2051da177e4SLinus Torvalds /* L2CAP structures */
2061da177e4SLinus Torvalds struct l2cap_hdr {
2078e036fc3SAl Viro 	__le16     len;
2088e036fc3SAl Viro 	__le16     cid;
20966c853ccSGustavo F. Padovan } __packed;
2101da177e4SLinus Torvalds #define L2CAP_HDR_SIZE		4
211d43cb289SAndrei Emeltchenko #define L2CAP_ENH_HDR_SIZE	6
212d43cb289SAndrei Emeltchenko #define L2CAP_EXT_HDR_SIZE	8
213d43cb289SAndrei Emeltchenko 
214d43cb289SAndrei Emeltchenko #define L2CAP_FCS_SIZE		2
215d43cb289SAndrei Emeltchenko #define L2CAP_SDULEN_SIZE	2
216d43cb289SAndrei Emeltchenko #define L2CAP_PSMLEN_SIZE	2
217d5f7ac38SMat Martineau #define L2CAP_ENH_CTRL_SIZE	2
218d5f7ac38SMat Martineau #define L2CAP_EXT_CTRL_SIZE	4
2191da177e4SLinus Torvalds 
2201da177e4SLinus Torvalds struct l2cap_cmd_hdr {
2211da177e4SLinus Torvalds 	__u8       code;
2221da177e4SLinus Torvalds 	__u8       ident;
2238e036fc3SAl Viro 	__le16     len;
22466c853ccSGustavo F. Padovan } __packed;
2251da177e4SLinus Torvalds #define L2CAP_CMD_HDR_SIZE	4
2261da177e4SLinus Torvalds 
227e2fd318eSIlia Kolomisnky struct l2cap_cmd_rej_unk {
2288e036fc3SAl Viro 	__le16     reason;
22966c853ccSGustavo F. Padovan } __packed;
2301da177e4SLinus Torvalds 
231e2fd318eSIlia Kolomisnky struct l2cap_cmd_rej_mtu {
232e2fd318eSIlia Kolomisnky 	__le16     reason;
233e2fd318eSIlia Kolomisnky 	__le16     max_mtu;
234e2fd318eSIlia Kolomisnky } __packed;
235e2fd318eSIlia Kolomisnky 
236e2fd318eSIlia Kolomisnky struct l2cap_cmd_rej_cid {
237e2fd318eSIlia Kolomisnky 	__le16     reason;
238e2fd318eSIlia Kolomisnky 	__le16     scid;
239e2fd318eSIlia Kolomisnky 	__le16     dcid;
240e2fd318eSIlia Kolomisnky } __packed;
241e2fd318eSIlia Kolomisnky 
2421da177e4SLinus Torvalds struct l2cap_conn_req {
2438e036fc3SAl Viro 	__le16     psm;
2448e036fc3SAl Viro 	__le16     scid;
24566c853ccSGustavo F. Padovan } __packed;
2461da177e4SLinus Torvalds 
2471da177e4SLinus Torvalds struct l2cap_conn_rsp {
2488e036fc3SAl Viro 	__le16     dcid;
2498e036fc3SAl Viro 	__le16     scid;
2508e036fc3SAl Viro 	__le16     result;
2518e036fc3SAl Viro 	__le16     status;
25266c853ccSGustavo F. Padovan } __packed;
2531da177e4SLinus Torvalds 
2542983fd68SAndrei Emeltchenko /* protocol/service multiplexer (PSM) */
2552983fd68SAndrei Emeltchenko #define L2CAP_PSM_SDP		0x0001
2562983fd68SAndrei Emeltchenko #define L2CAP_PSM_RFCOMM	0x0003
2573124b843SMarcel Holtmann #define L2CAP_PSM_3DSP		0x0021
258cab9e3a0SJukka Rissanen #define L2CAP_PSM_IPSP		0x0023 /* 6LoWPAN */
2592983fd68SAndrei Emeltchenko 
260114f9f1eSJohan Hedberg #define L2CAP_PSM_DYN_START	0x1001
261114f9f1eSJohan Hedberg #define L2CAP_PSM_DYN_END	0xffff
262114f9f1eSJohan Hedberg #define L2CAP_PSM_AUTO_END	0x10ff
263114f9f1eSJohan Hedberg #define L2CAP_PSM_LE_DYN_START  0x0080
264114f9f1eSJohan Hedberg #define L2CAP_PSM_LE_DYN_END	0x00ff
265114f9f1eSJohan Hedberg 
2663f79410cSMaxime Jayat /* channel identifier */
2678db4dc46SGustavo F. Padovan #define L2CAP_CID_SIGNALING	0x0001
2688db4dc46SGustavo F. Padovan #define L2CAP_CID_CONN_LESS	0x0002
269466f8004SAndrei Emeltchenko #define L2CAP_CID_A2MP		0x0003
270073d1cf3SJohan Hedberg #define L2CAP_CID_ATT		0x0004
271acd7d370SVille Tervo #define L2CAP_CID_LE_SIGNALING	0x0005
272acd7d370SVille Tervo #define L2CAP_CID_SMP		0x0006
273ef8efe4bSJohan Hedberg #define L2CAP_CID_SMP_BREDR	0x0007
2748db4dc46SGustavo F. Padovan #define L2CAP_CID_DYN_START	0x0040
2758db4dc46SGustavo F. Padovan #define L2CAP_CID_DYN_END	0xffff
276e77af755SJohan Hedberg #define L2CAP_CID_LE_DYN_END	0x007f
2778db4dc46SGustavo F. Padovan 
27838094c75SMat Martineau /* connect/create channel results */
2791da177e4SLinus Torvalds #define L2CAP_CR_SUCCESS	0x0000
2801da177e4SLinus Torvalds #define L2CAP_CR_PEND		0x0001
2811da177e4SLinus Torvalds #define L2CAP_CR_BAD_PSM	0x0002
2821da177e4SLinus Torvalds #define L2CAP_CR_SEC_BLOCK	0x0003
2831da177e4SLinus Torvalds #define L2CAP_CR_NO_MEM		0x0004
28438094c75SMat Martineau #define L2CAP_CR_BAD_AMP	0x0005
285dd1a8f8aSMallikarjun Phulari #define L2CAP_CR_INVALID_SCID	0x0006
286dd1a8f8aSMallikarjun Phulari #define L2CAP_CR_SCID_IN_USE	0x0007
287571f7390SMallikarjun Phulari 
288571f7390SMallikarjun Phulari /* credit based connect results */
289571f7390SMallikarjun Phulari #define L2CAP_CR_LE_SUCCESS		0x0000
290571f7390SMallikarjun Phulari #define L2CAP_CR_LE_BAD_PSM		0x0002
291571f7390SMallikarjun Phulari #define L2CAP_CR_LE_NO_MEM		0x0004
292571f7390SMallikarjun Phulari #define L2CAP_CR_LE_AUTHENTICATION	0x0005
293571f7390SMallikarjun Phulari #define L2CAP_CR_LE_AUTHORIZATION	0x0006
294571f7390SMallikarjun Phulari #define L2CAP_CR_LE_BAD_KEY_SIZE	0x0007
295571f7390SMallikarjun Phulari #define L2CAP_CR_LE_ENCRYPTION		0x0008
296571f7390SMallikarjun Phulari #define L2CAP_CR_LE_INVALID_SCID	0x0009
297571f7390SMallikarjun Phulari #define L2CAP_CR_LE_SCID_IN_USE		0X000A
29815f02b91SLuiz Augusto von Dentz #define L2CAP_CR_LE_UNACCEPT_PARAMS	0X000B
29915f02b91SLuiz Augusto von Dentz #define L2CAP_CR_LE_INVALID_PARAMS	0X000C
3001da177e4SLinus Torvalds 
30138094c75SMat Martineau /* connect/create channel status */
3021da177e4SLinus Torvalds #define L2CAP_CS_NO_INFO	0x0000
3031da177e4SLinus Torvalds #define L2CAP_CS_AUTHEN_PEND	0x0001
3041da177e4SLinus Torvalds #define L2CAP_CS_AUTHOR_PEND	0x0002
3051da177e4SLinus Torvalds 
3061da177e4SLinus Torvalds struct l2cap_conf_req {
3078e036fc3SAl Viro 	__le16     dcid;
3088e036fc3SAl Viro 	__le16     flags;
309a7e45454SGustavo A. R. Silva 	__u8       data[];
31066c853ccSGustavo F. Padovan } __packed;
3111da177e4SLinus Torvalds 
3121da177e4SLinus Torvalds struct l2cap_conf_rsp {
3138e036fc3SAl Viro 	__le16     scid;
3148e036fc3SAl Viro 	__le16     flags;
3158e036fc3SAl Viro 	__le16     result;
316a7e45454SGustavo A. R. Silva 	__u8       data[];
31766c853ccSGustavo F. Padovan } __packed;
3181da177e4SLinus Torvalds 
3195dee9e7cSMarcel Holtmann #define L2CAP_CONF_SUCCESS	0x0000
3205dee9e7cSMarcel Holtmann #define L2CAP_CONF_UNACCEPT	0x0001
3215dee9e7cSMarcel Holtmann #define L2CAP_CONF_REJECT	0x0002
3225dee9e7cSMarcel Holtmann #define L2CAP_CONF_UNKNOWN	0x0003
3230e8b207eSAndrei Emeltchenko #define L2CAP_CONF_PENDING	0x0004
3245a9e7057SAndrei Emeltchenko #define L2CAP_CONF_EFS_REJECT	0x0005
3251da177e4SLinus Torvalds 
32659e54bd1SAndrei Emeltchenko /* configuration req/rsp continuation flag */
32759e54bd1SAndrei Emeltchenko #define L2CAP_CONF_FLAG_CONTINUATION	0x0001
32859e54bd1SAndrei Emeltchenko 
3291da177e4SLinus Torvalds struct l2cap_conf_opt {
3301da177e4SLinus Torvalds 	__u8       type;
3311da177e4SLinus Torvalds 	__u8       len;
332a7e45454SGustavo A. R. Silva 	__u8       val[];
33366c853ccSGustavo F. Padovan } __packed;
3341da177e4SLinus Torvalds #define L2CAP_CONF_OPT_SIZE	2
3351da177e4SLinus Torvalds 
336589d2746SGustavo F. Padovan #define L2CAP_CONF_HINT		0x80
33747ec1dcdSMarcel Holtmann #define L2CAP_CONF_MASK		0x7f
338589d2746SGustavo F. Padovan 
3391da177e4SLinus Torvalds #define L2CAP_CONF_MTU		0x01
3401da177e4SLinus Torvalds #define L2CAP_CONF_FLUSH_TO	0x02
3411da177e4SLinus Torvalds #define L2CAP_CONF_QOS		0x03
3421da177e4SLinus Torvalds #define L2CAP_CONF_RFC		0x04
34347ec1dcdSMarcel Holtmann #define L2CAP_CONF_FCS		0x05
3445a9e7057SAndrei Emeltchenko #define L2CAP_CONF_EFS		0x06
3456327eb98SAndrei Emeltchenko #define L2CAP_CONF_EWS		0x07
3461da177e4SLinus Torvalds 
3471da177e4SLinus Torvalds #define L2CAP_CONF_MAX_SIZE	22
3481da177e4SLinus Torvalds 
3496464f35fSMarcel Holtmann struct l2cap_conf_rfc {
3506464f35fSMarcel Holtmann 	__u8       mode;
3516464f35fSMarcel Holtmann 	__u8       txwin_size;
3526464f35fSMarcel Holtmann 	__u8       max_transmit;
3536464f35fSMarcel Holtmann 	__le16     retrans_timeout;
3546464f35fSMarcel Holtmann 	__le16     monitor_timeout;
3556464f35fSMarcel Holtmann 	__le16     max_pdu_size;
35666c853ccSGustavo F. Padovan } __packed;
3576464f35fSMarcel Holtmann 
3586464f35fSMarcel Holtmann #define L2CAP_MODE_BASIC	0x00
3596464f35fSMarcel Holtmann #define L2CAP_MODE_RETRANS	0x01
3606464f35fSMarcel Holtmann #define L2CAP_MODE_FLOWCTL	0x02
36147ec1dcdSMarcel Holtmann #define L2CAP_MODE_ERTM		0x03
362c6b03cf9SMarcel Holtmann #define L2CAP_MODE_STREAMING	0x04
3636464f35fSMarcel Holtmann 
36438319713SJohan Hedberg /* Unlike the above this one doesn't actually map to anything that would
36538319713SJohan Hedberg  * ever be sent over the air. Therefore, use a value that's unlikely to
36638319713SJohan Hedberg  * ever be used in the BR/EDR configuration phase.
36738319713SJohan Hedberg  */
36838319713SJohan Hedberg #define L2CAP_MODE_LE_FLOWCTL	0x80
36914572096SLuiz Augusto von Dentz #define L2CAP_MODE_EXT_FLOWCTL	0x81
37038319713SJohan Hedberg 
3715a9e7057SAndrei Emeltchenko struct l2cap_conf_efs {
3725a9e7057SAndrei Emeltchenko 	__u8	id;
3735a9e7057SAndrei Emeltchenko 	__u8	stype;
3745a9e7057SAndrei Emeltchenko 	__le16	msdu;
3755a9e7057SAndrei Emeltchenko 	__le32	sdu_itime;
3765a9e7057SAndrei Emeltchenko 	__le32	acc_lat;
3775a9e7057SAndrei Emeltchenko 	__le32	flush_to;
3785a9e7057SAndrei Emeltchenko } __packed;
3795a9e7057SAndrei Emeltchenko 
3808f7975b1SAndrei Emeltchenko #define L2CAP_SERV_NOTRAFIC	0x00
3818f7975b1SAndrei Emeltchenko #define L2CAP_SERV_BESTEFFORT	0x01
3828f7975b1SAndrei Emeltchenko #define L2CAP_SERV_GUARANTEED	0x02
3838f7975b1SAndrei Emeltchenko 
3848f7975b1SAndrei Emeltchenko #define L2CAP_BESTEFFORT_ID	0x01
3858f7975b1SAndrei Emeltchenko 
3861da177e4SLinus Torvalds struct l2cap_disconn_req {
3878e036fc3SAl Viro 	__le16     dcid;
3888e036fc3SAl Viro 	__le16     scid;
38966c853ccSGustavo F. Padovan } __packed;
3901da177e4SLinus Torvalds 
3911da177e4SLinus Torvalds struct l2cap_disconn_rsp {
3928e036fc3SAl Viro 	__le16     dcid;
3938e036fc3SAl Viro 	__le16     scid;
39466c853ccSGustavo F. Padovan } __packed;
3951da177e4SLinus Torvalds 
3961da177e4SLinus Torvalds struct l2cap_info_req {
3978e036fc3SAl Viro 	__le16      type;
39866c853ccSGustavo F. Padovan } __packed;
3991da177e4SLinus Torvalds 
4001da177e4SLinus Torvalds struct l2cap_info_rsp {
4018e036fc3SAl Viro 	__le16      type;
4028e036fc3SAl Viro 	__le16      result;
403a7e45454SGustavo A. R. Silva 	__u8        data[];
40466c853ccSGustavo F. Padovan } __packed;
4051da177e4SLinus Torvalds 
40638094c75SMat Martineau struct l2cap_create_chan_req {
40738094c75SMat Martineau 	__le16      psm;
40838094c75SMat Martineau 	__le16      scid;
40938094c75SMat Martineau 	__u8        amp_id;
41038094c75SMat Martineau } __packed;
41138094c75SMat Martineau 
41238094c75SMat Martineau struct l2cap_create_chan_rsp {
41338094c75SMat Martineau 	__le16      dcid;
41438094c75SMat Martineau 	__le16      scid;
41538094c75SMat Martineau 	__le16      result;
41638094c75SMat Martineau 	__le16      status;
41738094c75SMat Martineau } __packed;
41838094c75SMat Martineau 
41938094c75SMat Martineau struct l2cap_move_chan_req {
42038094c75SMat Martineau 	__le16      icid;
42138094c75SMat Martineau 	__u8        dest_amp_id;
42238094c75SMat Martineau } __packed;
42338094c75SMat Martineau 
42438094c75SMat Martineau struct l2cap_move_chan_rsp {
42538094c75SMat Martineau 	__le16      icid;
42638094c75SMat Martineau 	__le16      result;
42738094c75SMat Martineau } __packed;
42838094c75SMat Martineau 
42938094c75SMat Martineau #define L2CAP_MR_SUCCESS	0x0000
43038094c75SMat Martineau #define L2CAP_MR_PEND		0x0001
43138094c75SMat Martineau #define L2CAP_MR_BAD_ID		0x0002
43238094c75SMat Martineau #define L2CAP_MR_SAME_ID	0x0003
43338094c75SMat Martineau #define L2CAP_MR_NOT_SUPP	0x0004
43438094c75SMat Martineau #define L2CAP_MR_COLLISION	0x0005
43538094c75SMat Martineau #define L2CAP_MR_NOT_ALLOWED	0x0006
43638094c75SMat Martineau 
43738094c75SMat Martineau struct l2cap_move_chan_cfm {
43838094c75SMat Martineau 	__le16      icid;
43938094c75SMat Martineau 	__le16      result;
44038094c75SMat Martineau } __packed;
44138094c75SMat Martineau 
44238094c75SMat Martineau #define L2CAP_MC_CONFIRMED	0x0000
44338094c75SMat Martineau #define L2CAP_MC_UNCONFIRMED	0x0001
44438094c75SMat Martineau 
44538094c75SMat Martineau struct l2cap_move_chan_cfm_rsp {
44638094c75SMat Martineau 	__le16      icid;
44738094c75SMat Martineau } __packed;
44838094c75SMat Martineau 
4491da177e4SLinus Torvalds /* info type */
4501da177e4SLinus Torvalds #define L2CAP_IT_CL_MTU		0x0001
4511da177e4SLinus Torvalds #define L2CAP_IT_FEAT_MASK	0x0002
452e1027a7cSMarcel Holtmann #define L2CAP_IT_FIXED_CHAN	0x0003
4531da177e4SLinus Torvalds 
4541da177e4SLinus Torvalds /* info result */
4551da177e4SLinus Torvalds #define L2CAP_IR_SUCCESS	0x0000
4561da177e4SLinus Torvalds #define L2CAP_IR_NOTSUPP	0x0001
4571da177e4SLinus Torvalds 
458de73115aSClaudio Takahasi struct l2cap_conn_param_update_req {
459de73115aSClaudio Takahasi 	__le16      min;
460de73115aSClaudio Takahasi 	__le16      max;
461de73115aSClaudio Takahasi 	__le16      latency;
462de73115aSClaudio Takahasi 	__le16      to_multiplier;
463de73115aSClaudio Takahasi } __packed;
464de73115aSClaudio Takahasi 
465de73115aSClaudio Takahasi struct l2cap_conn_param_update_rsp {
466de73115aSClaudio Takahasi 	__le16      result;
467de73115aSClaudio Takahasi } __packed;
468de73115aSClaudio Takahasi 
469de73115aSClaudio Takahasi /* Connection Parameters result */
470de73115aSClaudio Takahasi #define L2CAP_CONN_PARAM_ACCEPTED	0x0000
471de73115aSClaudio Takahasi #define L2CAP_CONN_PARAM_REJECTED	0x0001
472de73115aSClaudio Takahasi 
473ee5ec5cfSJohan Hedberg struct l2cap_le_conn_req {
474ee5ec5cfSJohan Hedberg 	__le16     psm;
475ee5ec5cfSJohan Hedberg 	__le16     scid;
476ee5ec5cfSJohan Hedberg 	__le16     mtu;
477ee5ec5cfSJohan Hedberg 	__le16     mps;
478ee5ec5cfSJohan Hedberg 	__le16     credits;
479ee5ec5cfSJohan Hedberg } __packed;
480ee5ec5cfSJohan Hedberg 
481ee5ec5cfSJohan Hedberg struct l2cap_le_conn_rsp {
482ee5ec5cfSJohan Hedberg 	__le16     dcid;
483ee5ec5cfSJohan Hedberg 	__le16     mtu;
484ee5ec5cfSJohan Hedberg 	__le16     mps;
485ee5ec5cfSJohan Hedberg 	__le16     credits;
486ee5ec5cfSJohan Hedberg 	__le16     result;
487ee5ec5cfSJohan Hedberg } __packed;
488ee5ec5cfSJohan Hedberg 
489ee5ec5cfSJohan Hedberg struct l2cap_le_credits {
490ee5ec5cfSJohan Hedberg 	__le16     cid;
491ee5ec5cfSJohan Hedberg 	__le16     credits;
492ee5ec5cfSJohan Hedberg } __packed;
493ee5ec5cfSJohan Hedberg 
49414572096SLuiz Augusto von Dentz #define L2CAP_ECRED_MIN_MTU		64
49514572096SLuiz Augusto von Dentz #define L2CAP_ECRED_MIN_MPS		64
49614572096SLuiz Augusto von Dentz 
49714572096SLuiz Augusto von Dentz struct l2cap_ecred_conn_req {
49814572096SLuiz Augusto von Dentz 	__le16 psm;
49914572096SLuiz Augusto von Dentz 	__le16 mtu;
50014572096SLuiz Augusto von Dentz 	__le16 mps;
50114572096SLuiz Augusto von Dentz 	__le16 credits;
502631512f8SGustavo A. R. Silva 	__le16 scid[];
50314572096SLuiz Augusto von Dentz } __packed;
50414572096SLuiz Augusto von Dentz 
50514572096SLuiz Augusto von Dentz struct l2cap_ecred_conn_rsp {
50614572096SLuiz Augusto von Dentz 	__le16 mtu;
50714572096SLuiz Augusto von Dentz 	__le16 mps;
50814572096SLuiz Augusto von Dentz 	__le16 credits;
50914572096SLuiz Augusto von Dentz 	__le16 result;
510631512f8SGustavo A. R. Silva 	__le16 dcid[];
51114572096SLuiz Augusto von Dentz };
51214572096SLuiz Augusto von Dentz 
51314572096SLuiz Augusto von Dentz struct l2cap_ecred_reconf_req {
51414572096SLuiz Augusto von Dentz 	__le16 mtu;
51514572096SLuiz Augusto von Dentz 	__le16 mps;
516631512f8SGustavo A. R. Silva 	__le16 scid[];
51714572096SLuiz Augusto von Dentz } __packed;
51814572096SLuiz Augusto von Dentz 
51914572096SLuiz Augusto von Dentz #define L2CAP_RECONF_SUCCESS		0x0000
52014572096SLuiz Augusto von Dentz #define L2CAP_RECONF_INVALID_MTU	0x0001
52114572096SLuiz Augusto von Dentz #define L2CAP_RECONF_INVALID_MPS	0x0002
52214572096SLuiz Augusto von Dentz 
52314572096SLuiz Augusto von Dentz struct l2cap_ecred_reconf_rsp {
52414572096SLuiz Augusto von Dentz 	__le16 result;
52514572096SLuiz Augusto von Dentz } __packed;
52614572096SLuiz Augusto von Dentz 
52748454079SGustavo F. Padovan /* ----- L2CAP channels and connections ----- */
5283c588192SMat Martineau struct l2cap_seq_list {
5293c588192SMat Martineau 	__u16	head;
5303c588192SMat Martineau 	__u16	tail;
5313c588192SMat Martineau 	__u16	mask;
5323c588192SMat Martineau 	__u16	*list;
5333c588192SMat Martineau };
5343c588192SMat Martineau 
5353c588192SMat Martineau #define L2CAP_SEQ_LIST_CLEAR	0xFFFF
5363c588192SMat Martineau #define L2CAP_SEQ_LIST_TAIL	0x8000
5373c588192SMat Martineau 
53848454079SGustavo F. Padovan struct l2cap_chan {
5398c1d787bSGustavo F. Padovan 	struct l2cap_conn	*conn;
54008333283SMat Martineau 	struct hci_conn		*hs_hcon;
54108333283SMat Martineau 	struct hci_chan		*hs_hchan;
542144ad330SSyam Sidhardhan 	struct kref	kref;
543abe84903SJohan Hedberg 	atomic_t	nesting;
5448c1d787bSGustavo F. Padovan 
54589bc500eSGustavo F. Padovan 	__u8		state;
54689bc500eSGustavo F. Padovan 
5477eafc59eSMarcel Holtmann 	bdaddr_t	dst;
5484f1654e0SMarcel Holtmann 	__u8		dst_type;
5497eafc59eSMarcel Holtmann 	bdaddr_t	src;
5504f1654e0SMarcel Holtmann 	__u8		src_type;
551fe4128e0SGustavo F. Padovan 	__le16		psm;
5524f1654e0SMarcel Holtmann 	__le16		sport;
553fe4128e0SGustavo F. Padovan 	__u16		dcid;
554fe4128e0SGustavo F. Padovan 	__u16		scid;
5554343478fSGustavo F. Padovan 
5560c1bc5c6SGustavo F. Padovan 	__u16		imtu;
5570c1bc5c6SGustavo F. Padovan 	__u16		omtu;
5580c1bc5c6SGustavo F. Padovan 	__u16		flush_to;
5590c1bc5c6SGustavo F. Padovan 	__u8		mode;
560715ec005SGustavo F. Padovan 	__u8		chan_type;
5612ea66482SMat Martineau 	__u8		chan_policy;
5620c1bc5c6SGustavo F. Padovan 
5634343478fSGustavo F. Padovan 	__u8		sec_level;
5644343478fSGustavo F. Padovan 
565fc7f8a7eSGustavo F. Padovan 	__u8		ident;
566fc7f8a7eSGustavo F. Padovan 
56773ffa904SGustavo F. Padovan 	__u8		conf_req[64];
56873ffa904SGustavo F. Padovan 	__u8		conf_len;
56973ffa904SGustavo F. Padovan 	__u8		num_conf_req;
57073ffa904SGustavo F. Padovan 	__u8		num_conf_rsp;
57173ffa904SGustavo F. Padovan 
57247d1ec61SGustavo F. Padovan 	__u8		fcs;
57347d1ec61SGustavo F. Padovan 
5746327eb98SAndrei Emeltchenko 	__u16		tx_win;
575836be934SAndrei Emeltchenko 	__u16		tx_win_max;
576c20f8e35SMat Martineau 	__u16		ack_win;
57747d1ec61SGustavo F. Padovan 	__u8		max_tx;
57847d1ec61SGustavo F. Padovan 	__u16		retrans_timeout;
57947d1ec61SGustavo F. Padovan 	__u16		monitor_timeout;
58047d1ec61SGustavo F. Padovan 	__u16		mps;
58147d1ec61SGustavo F. Padovan 
5820cd75f7eSJohan Hedberg 	__u16		tx_credits;
5830cd75f7eSJohan Hedberg 	__u16		rx_credits;
5840cd75f7eSJohan Hedberg 
585d5f7ac38SMat Martineau 	__u8		tx_state;
586d5f7ac38SMat Martineau 	__u8		rx_state;
587d5f7ac38SMat Martineau 
588c1360a1cSGustavo F. Padovan 	unsigned long	conf_state;
589e2ab4353SGustavo F. Padovan 	unsigned long	conn_state;
590d57b0e8bSAndrei Emeltchenko 	unsigned long	flags;
591525cd185SGustavo F. Padovan 
592fffadc08SAndrei Emeltchenko 	__u8		remote_amp_id;
59308333283SMat Martineau 	__u8		local_amp_id;
59408333283SMat Martineau 	__u8		move_id;
59508333283SMat Martineau 	__u8		move_state;
59608333283SMat Martineau 	__u8		move_role;
59708333283SMat Martineau 
598fb45de7dSAndrei Emeltchenko 	__u16		next_tx_seq;
599fb45de7dSAndrei Emeltchenko 	__u16		expected_ack_seq;
600fb45de7dSAndrei Emeltchenko 	__u16		expected_tx_seq;
6010b209faeSAndrei Emeltchenko 	__u16		buffer_seq;
602fb45de7dSAndrei Emeltchenko 	__u16		srej_save_reqseq;
603d5f7ac38SMat Martineau 	__u16		last_acked_seq;
604fb45de7dSAndrei Emeltchenko 	__u16		frames_sent;
605fb45de7dSAndrei Emeltchenko 	__u16		unacked_frames;
6066a026610SGustavo F. Padovan 	__u8		retry_count;
6076f61fd47SGustavo F. Padovan 	__u16		sdu_len;
6086f61fd47SGustavo F. Padovan 	struct sk_buff	*sdu;
60984084a31SMat Martineau 	struct sk_buff	*sdu_last_frag;
6106f61fd47SGustavo F. Padovan 
6116327eb98SAndrei Emeltchenko 	__u16		remote_tx_win;
6122c03a7a4SGustavo F. Padovan 	__u8		remote_max_tx;
6132c03a7a4SGustavo F. Padovan 	__u16		remote_mps;
61442e5c802SGustavo F. Padovan 
6155a9e7057SAndrei Emeltchenko 	__u8		local_id;
6165a9e7057SAndrei Emeltchenko 	__u8		local_stype;
6175a9e7057SAndrei Emeltchenko 	__u16		local_msdu;
6185a9e7057SAndrei Emeltchenko 	__u32		local_sdu_itime;
6195a9e7057SAndrei Emeltchenko 	__u32		local_acc_lat;
6205a9e7057SAndrei Emeltchenko 	__u32		local_flush_to;
6215a9e7057SAndrei Emeltchenko 
6225a9e7057SAndrei Emeltchenko 	__u8		remote_id;
6235a9e7057SAndrei Emeltchenko 	__u8		remote_stype;
6245a9e7057SAndrei Emeltchenko 	__u16		remote_msdu;
6255a9e7057SAndrei Emeltchenko 	__u32		remote_sdu_itime;
6265a9e7057SAndrei Emeltchenko 	__u32		remote_acc_lat;
6275a9e7057SAndrei Emeltchenko 	__u32		remote_flush_to;
6285a9e7057SAndrei Emeltchenko 
629721c4181SGustavo F. Padovan 	struct delayed_work	chan_timer;
630721c4181SGustavo F. Padovan 	struct delayed_work	retrans_timer;
631721c4181SGustavo F. Padovan 	struct delayed_work	monitor_timer;
632721c4181SGustavo F. Padovan 	struct delayed_work	ack_timer;
633721c4181SGustavo F. Padovan 
63458d35f87SGustavo F. Padovan 	struct sk_buff		*tx_send_head;
63558d35f87SGustavo F. Padovan 	struct sk_buff_head	tx_q;
636f1c6775bSGustavo F. Padovan 	struct sk_buff_head	srej_q;
6373c588192SMat Martineau 	struct l2cap_seq_list	srej_list;
6383c588192SMat Martineau 	struct l2cap_seq_list	retrans_list;
639e92c8e70SGustavo F. Padovan 
640baa7e1faSGustavo F. Padovan 	struct list_head	list;
64123691d75SGustavo F. Padovan 	struct list_head	global_l;
64280808e43SGustavo F. Padovan 
64380808e43SGustavo F. Padovan 	void			*data;
64467f86a45SMarcel Holtmann 	const struct l2cap_ops	*ops;
645c03b355eSAndrei Emeltchenko 	struct mutex		lock;
64680808e43SGustavo F. Padovan };
64780808e43SGustavo F. Padovan 
64880808e43SGustavo F. Padovan struct l2cap_ops {
64980808e43SGustavo F. Padovan 	char			*name;
65080808e43SGustavo F. Padovan 
65180b98027SGustavo Padovan 	struct l2cap_chan	*(*new_connection) (struct l2cap_chan *chan);
65280b98027SGustavo Padovan 	int			(*recv) (struct l2cap_chan * chan,
65380b98027SGustavo Padovan 					 struct sk_buff *skb);
654c0df7f6eSAndrei Emeltchenko 	void			(*teardown) (struct l2cap_chan *chan, int err);
65580b98027SGustavo Padovan 	void			(*close) (struct l2cap_chan *chan);
65680b98027SGustavo Padovan 	void			(*state_change) (struct l2cap_chan *chan,
65753f52121SGustavo Padovan 						 int state, int err);
65854a59aa2SAndrei Emeltchenko 	void			(*ready) (struct l2cap_chan *chan);
6592dc4e510SGustavo Padovan 	void			(*defer) (struct l2cap_chan *chan);
660d97c899bSMarcel Holtmann 	void			(*resume) (struct l2cap_chan *chan);
661837776f7SJohan Hedberg 	void			(*suspend) (struct l2cap_chan *chan);
6625ec1bbe5SGustavo Padovan 	void			(*set_shutdown) (struct l2cap_chan *chan);
6638d836d71SGustavo Padovan 	long			(*get_sndtimeo) (struct l2cap_chan *chan);
664b48596d1SLuiz Augusto von Dentz 	struct pid		*(*get_peer_pid) (struct l2cap_chan *chan);
6652f7719ceSAndrei Emeltchenko 	struct sk_buff		*(*alloc_skb) (struct l2cap_chan *chan,
666d9fbd02bSMarcel Holtmann 					       unsigned long hdr_len,
66790338947SGustavo Padovan 					       unsigned long len, int nb);
668*f1942564SLuiz Augusto von Dentz 	int			(*filter) (struct l2cap_chan * chan,
669*f1942564SLuiz Augusto von Dentz 					   struct sk_buff *skb);
6701da177e4SLinus Torvalds };
6711da177e4SLinus Torvalds 
6721da177e4SLinus Torvalds struct l2cap_conn {
6731da177e4SLinus Torvalds 	struct hci_conn		*hcon;
67473d80debSLuiz Augusto von Dentz 	struct hci_chan		*hchan;
6751da177e4SLinus Torvalds 
6761da177e4SLinus Torvalds 	unsigned int		mtu;
6771da177e4SLinus Torvalds 
6784e8402a3SMarcel Holtmann 	__u32			feat_mask;
6790bd49fc7SJohan Hedberg 	__u8			remote_fixed_chan;
6800bd49fc7SJohan Hedberg 	__u8			local_fixed_chan;
6814e8402a3SMarcel Holtmann 
6824e8402a3SMarcel Holtmann 	__u8			info_state;
6834e8402a3SMarcel Holtmann 	__u8			info_ident;
6844e8402a3SMarcel Holtmann 
685030013d8SGustavo F. Padovan 	struct delayed_work	info_timer;
6864e8402a3SMarcel Holtmann 
6871da177e4SLinus Torvalds 	struct sk_buff		*rx_skb;
6881da177e4SLinus Torvalds 	__u32			rx_len;
6891da177e4SLinus Torvalds 	__u8			tx_ident;
6905a54e7c8SMarcel Holtmann 	struct mutex		ident_lock;
6911da177e4SLinus Torvalds 
69261a939c6SJohan Hedberg 	struct sk_buff_head	pending_rx;
69361a939c6SJohan Hedberg 	struct work_struct	pending_rx_work;
69461a939c6SJohan Hedberg 
695f3d82d0cSJohan Hedberg 	struct work_struct	id_addr_update_work;
696f3d82d0cSJohan Hedberg 
6972950f21aSMarcel Holtmann 	__u8			disc_reason;
6982950f21aSMarcel Holtmann 
69970db83c4SJohan Hedberg 	struct l2cap_chan	*smp;
7005d3de7dfSVinicius Costa Gomes 
701baa7e1faSGustavo F. Padovan 	struct list_head	chan_l;
702d01b2ff4SGustavo F. Padovan 	struct mutex		chan_lock;
7039c903e37SDavid Herrmann 	struct kref		ref;
7042c8e1411SDavid Herrmann 	struct list_head	users;
7052c8e1411SDavid Herrmann };
7062c8e1411SDavid Herrmann 
7072c8e1411SDavid Herrmann struct l2cap_user {
7082c8e1411SDavid Herrmann 	struct list_head list;
7092c8e1411SDavid Herrmann 	int (*probe) (struct l2cap_conn *conn, struct l2cap_user *user);
7102c8e1411SDavid Herrmann 	void (*remove) (struct l2cap_conn *conn, struct l2cap_user *user);
7111da177e4SLinus Torvalds };
7121da177e4SLinus Torvalds 
7134e8402a3SMarcel Holtmann #define L2CAP_INFO_CL_MTU_REQ_SENT	0x01
714984947dcSMarcel Holtmann #define L2CAP_INFO_FEAT_MASK_REQ_SENT	0x04
715984947dcSMarcel Holtmann #define L2CAP_INFO_FEAT_MASK_REQ_DONE	0x08
7164e8402a3SMarcel Holtmann 
717715ec005SGustavo F. Padovan #define L2CAP_CHAN_RAW			1
718715ec005SGustavo F. Padovan #define L2CAP_CHAN_CONN_LESS		2
719715ec005SGustavo F. Padovan #define L2CAP_CHAN_CONN_ORIENTED	3
7202338a7e0SJohan Hedberg #define L2CAP_CHAN_FIXED		4
721715ec005SGustavo F. Padovan 
72248454079SGustavo F. Padovan /* ----- L2CAP socket info ----- */
7231da177e4SLinus Torvalds #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
7241da177e4SLinus Torvalds 
7251da177e4SLinus Torvalds struct l2cap_pinfo {
7261da177e4SLinus Torvalds 	struct bt_sock		bt;
72748454079SGustavo F. Padovan 	struct l2cap_chan	*chan;
728e328140fSMat Martineau 	struct sk_buff		*rx_busy_skb;
7291da177e4SLinus Torvalds };
7301da177e4SLinus Torvalds 
731c1360a1cSGustavo F. Padovan enum {
732c1360a1cSGustavo F. Padovan 	CONF_REQ_SENT,
733c1360a1cSGustavo F. Padovan 	CONF_INPUT_DONE,
734c1360a1cSGustavo F. Padovan 	CONF_OUTPUT_DONE,
735c1360a1cSGustavo F. Padovan 	CONF_MTU_DONE,
736c1360a1cSGustavo F. Padovan 	CONF_MODE_DONE,
737c1360a1cSGustavo F. Padovan 	CONF_CONNECT_PEND,
738f2592d3eSAndrei Emeltchenko 	CONF_RECV_NO_FCS,
739c1360a1cSGustavo F. Padovan 	CONF_STATE2_DEVICE,
7406327eb98SAndrei Emeltchenko 	CONF_EWS_RECV,
7410e8b207eSAndrei Emeltchenko 	CONF_LOC_CONF_PEND,
7420e8b207eSAndrei Emeltchenko 	CONF_REM_CONF_PEND,
7432827011fSMat Martineau 	CONF_NOT_COMPLETE,
744c1360a1cSGustavo F. Padovan };
745861d6882SMarcel Holtmann 
746f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_MAX_CONF_REQ 2
747f2fcfcd6SGustavo F. Padovan #define L2CAP_CONF_MAX_CONF_RSP 2
748f2fcfcd6SGustavo F. Padovan 
749e2ab4353SGustavo F. Padovan enum {
750e2ab4353SGustavo F. Padovan 	CONN_SREJ_SENT,
751e2ab4353SGustavo F. Padovan 	CONN_WAIT_F,
752e2ab4353SGustavo F. Padovan 	CONN_SREJ_ACT,
753e2ab4353SGustavo F. Padovan 	CONN_SEND_PBIT,
754e2ab4353SGustavo F. Padovan 	CONN_REMOTE_BUSY,
755e2ab4353SGustavo F. Padovan 	CONN_LOCAL_BUSY,
756e2ab4353SGustavo F. Padovan 	CONN_REJ_ACT,
757e2ab4353SGustavo F. Padovan 	CONN_SEND_FBIT,
758e2ab4353SGustavo F. Padovan 	CONN_RNR_SENT,
759e2ab4353SGustavo F. Padovan };
760e90bac06SGustavo F. Padovan 
761d57b0e8bSAndrei Emeltchenko /* Definitions for flags in l2cap_chan */
762d57b0e8bSAndrei Emeltchenko enum {
76343bd0f32SAndrei Emeltchenko 	FLAG_ROLE_SWITCH,
76415770b1aSAndrei Emeltchenko 	FLAG_FORCE_ACTIVE,
765ecf61bdbSAndrei Emeltchenko 	FLAG_FORCE_RELIABLE,
766d57b0e8bSAndrei Emeltchenko 	FLAG_FLUSHABLE,
7676327eb98SAndrei Emeltchenko 	FLAG_EXT_CTRL,
7685a9e7057SAndrei Emeltchenko 	FLAG_EFS_ENABLE,
769bdc25783SMarcel Holtmann 	FLAG_DEFER_SETUP,
770595177f3SJohan Hedberg 	FLAG_LE_CONN_REQ_SENT,
77114572096SLuiz Augusto von Dentz 	FLAG_ECRED_CONN_REQ_SENT,
772d52deb17SJohan Hedberg 	FLAG_PENDING_SECURITY,
773c16900cfSJohan Hedberg 	FLAG_HOLD_HCI_CONN,
774d57b0e8bSAndrei Emeltchenko };
775d57b0e8bSAndrei Emeltchenko 
776abe84903SJohan Hedberg /* Lock nesting levels for L2CAP channels. We need these because lockdep
777abe84903SJohan Hedberg  * otherwise considers all channels equal and will e.g. complain about a
778abe84903SJohan Hedberg  * connection oriented channel triggering SMP procedures or a listening
779abe84903SJohan Hedberg  * channel creating and locking a child channel.
780abe84903SJohan Hedberg  */
781abe84903SJohan Hedberg enum {
782abe84903SJohan Hedberg 	L2CAP_NESTING_SMP,
783abe84903SJohan Hedberg 	L2CAP_NESTING_NORMAL,
784abe84903SJohan Hedberg 	L2CAP_NESTING_PARENT,
785abe84903SJohan Hedberg };
786abe84903SJohan Hedberg 
787d5f7ac38SMat Martineau enum {
788d5f7ac38SMat Martineau 	L2CAP_TX_STATE_XMIT,
789d5f7ac38SMat Martineau 	L2CAP_TX_STATE_WAIT_F,
790d5f7ac38SMat Martineau };
791d5f7ac38SMat Martineau 
792d5f7ac38SMat Martineau enum {
793d5f7ac38SMat Martineau 	L2CAP_RX_STATE_RECV,
794d5f7ac38SMat Martineau 	L2CAP_RX_STATE_SREJ_SENT,
79508333283SMat Martineau 	L2CAP_RX_STATE_MOVE,
79608333283SMat Martineau 	L2CAP_RX_STATE_WAIT_P,
79708333283SMat Martineau 	L2CAP_RX_STATE_WAIT_F,
798d5f7ac38SMat Martineau };
799d5f7ac38SMat Martineau 
800d5f7ac38SMat Martineau enum {
801d5f7ac38SMat Martineau 	L2CAP_TXSEQ_EXPECTED,
802d5f7ac38SMat Martineau 	L2CAP_TXSEQ_EXPECTED_SREJ,
803d5f7ac38SMat Martineau 	L2CAP_TXSEQ_UNEXPECTED,
804d5f7ac38SMat Martineau 	L2CAP_TXSEQ_UNEXPECTED_SREJ,
805d5f7ac38SMat Martineau 	L2CAP_TXSEQ_DUPLICATE,
806d5f7ac38SMat Martineau 	L2CAP_TXSEQ_DUPLICATE_SREJ,
807d5f7ac38SMat Martineau 	L2CAP_TXSEQ_INVALID,
808d5f7ac38SMat Martineau 	L2CAP_TXSEQ_INVALID_IGNORE,
809d5f7ac38SMat Martineau };
810d5f7ac38SMat Martineau 
811d5f7ac38SMat Martineau enum {
812d5f7ac38SMat Martineau 	L2CAP_EV_DATA_REQUEST,
813d5f7ac38SMat Martineau 	L2CAP_EV_LOCAL_BUSY_DETECTED,
814d5f7ac38SMat Martineau 	L2CAP_EV_LOCAL_BUSY_CLEAR,
815d5f7ac38SMat Martineau 	L2CAP_EV_RECV_REQSEQ_AND_FBIT,
816d5f7ac38SMat Martineau 	L2CAP_EV_RECV_FBIT,
817d5f7ac38SMat Martineau 	L2CAP_EV_RETRANS_TO,
818d5f7ac38SMat Martineau 	L2CAP_EV_MONITOR_TO,
819d5f7ac38SMat Martineau 	L2CAP_EV_EXPLICIT_POLL,
820d5f7ac38SMat Martineau 	L2CAP_EV_RECV_IFRAME,
821d5f7ac38SMat Martineau 	L2CAP_EV_RECV_RR,
822d5f7ac38SMat Martineau 	L2CAP_EV_RECV_REJ,
823d5f7ac38SMat Martineau 	L2CAP_EV_RECV_RNR,
824d5f7ac38SMat Martineau 	L2CAP_EV_RECV_SREJ,
825d5f7ac38SMat Martineau 	L2CAP_EV_RECV_FRAME,
826d5f7ac38SMat Martineau };
827d5f7ac38SMat Martineau 
82808333283SMat Martineau enum {
82908333283SMat Martineau 	L2CAP_MOVE_ROLE_NONE,
83008333283SMat Martineau 	L2CAP_MOVE_ROLE_INITIATOR,
83108333283SMat Martineau 	L2CAP_MOVE_ROLE_RESPONDER,
83208333283SMat Martineau };
83308333283SMat Martineau 
83408333283SMat Martineau enum {
83508333283SMat Martineau 	L2CAP_MOVE_STABLE,
83608333283SMat Martineau 	L2CAP_MOVE_WAIT_REQ,
83708333283SMat Martineau 	L2CAP_MOVE_WAIT_RSP,
83808333283SMat Martineau 	L2CAP_MOVE_WAIT_RSP_SUCCESS,
83908333283SMat Martineau 	L2CAP_MOVE_WAIT_CONFIRM,
84008333283SMat Martineau 	L2CAP_MOVE_WAIT_CONFIRM_RSP,
84108333283SMat Martineau 	L2CAP_MOVE_WAIT_LOGICAL_COMP,
84208333283SMat Martineau 	L2CAP_MOVE_WAIT_LOGICAL_CFM,
84308333283SMat Martineau 	L2CAP_MOVE_WAIT_LOCAL_BUSY,
84408333283SMat Martineau 	L2CAP_MOVE_WAIT_PREPARE,
84508333283SMat Martineau };
84608333283SMat Martineau 
84730648372SJaganath Kanakkassery void l2cap_chan_hold(struct l2cap_chan *c);
84830648372SJaganath Kanakkassery void l2cap_chan_put(struct l2cap_chan *c);
849371fd835SUlisses Furquim 
850c03b355eSAndrei Emeltchenko static inline void l2cap_chan_lock(struct l2cap_chan *chan)
851c03b355eSAndrei Emeltchenko {
852abe84903SJohan Hedberg 	mutex_lock_nested(&chan->lock, atomic_read(&chan->nesting));
853c03b355eSAndrei Emeltchenko }
854c03b355eSAndrei Emeltchenko 
855c03b355eSAndrei Emeltchenko static inline void l2cap_chan_unlock(struct l2cap_chan *chan)
856c03b355eSAndrei Emeltchenko {
857c03b355eSAndrei Emeltchenko 	mutex_unlock(&chan->lock);
858c03b355eSAndrei Emeltchenko }
859c03b355eSAndrei Emeltchenko 
860c2ec9c1bSGustavo F. Padovan static inline void l2cap_set_timer(struct l2cap_chan *chan,
861c2ec9c1bSGustavo F. Padovan 				   struct delayed_work *work, long timeout)
862c2ec9c1bSGustavo F. Padovan {
863e05dcc32SAndrei Emeltchenko 	BT_DBG("chan %p state %s timeout %ld", chan,
864e05dcc32SAndrei Emeltchenko 	       state_to_string(chan->state), timeout);
865c2ec9c1bSGustavo F. Padovan 
8666f74b6f3SAndrei Emeltchenko 	/* If delayed work cancelled do not hold(chan)
8676f74b6f3SAndrei Emeltchenko 	   since it is already done with previous set_timer */
86817cd3f37SUlisses Furquim 	if (!cancel_delayed_work(work))
869371fd835SUlisses Furquim 		l2cap_chan_hold(chan);
8706f74b6f3SAndrei Emeltchenko 
871c2ec9c1bSGustavo F. Padovan 	schedule_delayed_work(work, timeout);
872c2ec9c1bSGustavo F. Padovan }
873c2ec9c1bSGustavo F. Padovan 
87475b93b59SSzymon Janc static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
875371fd835SUlisses Furquim 				     struct delayed_work *work)
876c2ec9c1bSGustavo F. Padovan {
87775b93b59SSzymon Janc 	bool ret;
87875b93b59SSzymon Janc 
8796f74b6f3SAndrei Emeltchenko 	/* put(chan) if delayed work cancelled otherwise it
8806f74b6f3SAndrei Emeltchenko 	   is done in delayed work function */
88117cd3f37SUlisses Furquim 	ret = cancel_delayed_work(work);
88275b93b59SSzymon Janc 	if (ret)
883371fd835SUlisses Furquim 		l2cap_chan_put(chan);
88475b93b59SSzymon Janc 
88575b93b59SSzymon Janc 	return ret;
886c2ec9c1bSGustavo F. Padovan }
887c2ec9c1bSGustavo F. Padovan 
888c9b66675SGustavo F. Padovan #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
889c9b66675SGustavo F. Padovan #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
8901a09bcb9SGustavo F. Padovan #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
8911a09bcb9SGustavo F. Padovan #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
8921a09bcb9SGustavo F. Padovan #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
893b83ddfe2SAndrzej Kaczmarek 		msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
8941a09bcb9SGustavo F. Padovan #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
895c74e560cSGustavo F. Padovan 
896836be934SAndrei Emeltchenko static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
897836be934SAndrei Emeltchenko {
8985a364bd3SMat Martineau 	if (seq1 >= seq2)
8995a364bd3SMat Martineau 		return seq1 - seq2;
9005a364bd3SMat Martineau 	else
9015a364bd3SMat Martineau 		return chan->tx_win_max + 1 - seq2 + seq1;
902836be934SAndrei Emeltchenko }
903836be934SAndrei Emeltchenko 
904836be934SAndrei Emeltchenko static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq)
905836be934SAndrei Emeltchenko {
906836be934SAndrei Emeltchenko 	return (seq + 1) % (chan->tx_win_max + 1);
907836be934SAndrei Emeltchenko }
908836be934SAndrei Emeltchenko 
9097e1af8a3SGustavo Padovan static inline struct l2cap_chan *l2cap_chan_no_new_connection(struct l2cap_chan *chan)
9107e1af8a3SGustavo Padovan {
9117e1af8a3SGustavo Padovan 	return NULL;
9127e1af8a3SGustavo Padovan }
9137e1af8a3SGustavo Padovan 
914f193844cSJohan Hedberg static inline int l2cap_chan_no_recv(struct l2cap_chan *chan, struct sk_buff *skb)
915f193844cSJohan Hedberg {
916f193844cSJohan Hedberg 	return -ENOSYS;
917f193844cSJohan Hedberg }
918f193844cSJohan Hedberg 
919f193844cSJohan Hedberg static inline struct sk_buff *l2cap_chan_no_alloc_skb(struct l2cap_chan *chan,
920f193844cSJohan Hedberg 						      unsigned long hdr_len,
921f193844cSJohan Hedberg 						      unsigned long len, int nb)
922f193844cSJohan Hedberg {
923f193844cSJohan Hedberg 	return ERR_PTR(-ENOSYS);
924f193844cSJohan Hedberg }
925f193844cSJohan Hedberg 
9267e1af8a3SGustavo Padovan static inline void l2cap_chan_no_teardown(struct l2cap_chan *chan, int err)
9277e1af8a3SGustavo Padovan {
9287e1af8a3SGustavo Padovan }
9297e1af8a3SGustavo Padovan 
930f193844cSJohan Hedberg static inline void l2cap_chan_no_close(struct l2cap_chan *chan)
931f193844cSJohan Hedberg {
932f193844cSJohan Hedberg }
933f193844cSJohan Hedberg 
9347e1af8a3SGustavo Padovan static inline void l2cap_chan_no_ready(struct l2cap_chan *chan)
9357e1af8a3SGustavo Padovan {
9367e1af8a3SGustavo Padovan }
9371da177e4SLinus Torvalds 
938f193844cSJohan Hedberg static inline void l2cap_chan_no_state_change(struct l2cap_chan *chan,
939f193844cSJohan Hedberg 					      int state, int err)
940f193844cSJohan Hedberg {
941f193844cSJohan Hedberg }
942f193844cSJohan Hedberg 
9432dc4e510SGustavo Padovan static inline void l2cap_chan_no_defer(struct l2cap_chan *chan)
9442dc4e510SGustavo Padovan {
9452dc4e510SGustavo Padovan }
9462dc4e510SGustavo Padovan 
947f193844cSJohan Hedberg static inline void l2cap_chan_no_suspend(struct l2cap_chan *chan)
948f193844cSJohan Hedberg {
949f193844cSJohan Hedberg }
950f193844cSJohan Hedberg 
9512ce5fb51SMarcel Holtmann static inline void l2cap_chan_no_resume(struct l2cap_chan *chan)
9522ce5fb51SMarcel Holtmann {
9532ce5fb51SMarcel Holtmann }
9542ce5fb51SMarcel Holtmann 
9555ec1bbe5SGustavo Padovan static inline void l2cap_chan_no_set_shutdown(struct l2cap_chan *chan)
9565ec1bbe5SGustavo Padovan {
9575ec1bbe5SGustavo Padovan }
9585ec1bbe5SGustavo Padovan 
9598d836d71SGustavo Padovan static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
9608d836d71SGustavo Padovan {
9618d836d71SGustavo Padovan 	return 0;
9628d836d71SGustavo Padovan }
9638d836d71SGustavo Padovan 
964eb939922SRusty Russell extern bool disable_ertm;
9654be5ca67SLuiz Augusto von Dentz extern bool enable_ecred;
966bb58f747SGustavo F. Padovan 
967bb58f747SGustavo F. Padovan int l2cap_init_sockets(void);
968bb58f747SGustavo F. Padovan void l2cap_cleanup_sockets(void);
969b3916db3SDavid Herrmann bool l2cap_is_socket(struct socket *sock);
970bb58f747SGustavo F. Padovan 
97127e2d4c8SJohan Hedberg void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan);
97215f02b91SLuiz Augusto von Dentz void __l2cap_ecred_conn_rsp_defer(struct l2cap_chan *chan);
9738c1d787bSGustavo F. Padovan void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
97468983259SGustavo F. Padovan 
9759e4425ffSGustavo F. Padovan int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
9769e4425ffSGustavo F. Padovan int l2cap_add_scid(struct l2cap_chan *chan,  __u16 scid);
9779e4425ffSGustavo F. Padovan 
978eef1d9b6SGustavo Padovan struct l2cap_chan *l2cap_chan_create(void);
9790f852724SGustavo F. Padovan void l2cap_chan_close(struct l2cap_chan *chan, int reason);
980cbe8fed4SJohan Hedberg int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
9818e9f9892SAndre Guedes 		       bdaddr_t *dst, u8 dst_type);
98215f02b91SLuiz Augusto von Dentz int l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu);
9838d46321cSMarcel Holtmann int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
984e328140fSMat Martineau void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
985e7cafc45SJohan Hedberg int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);
986bd4b1653SAndrei Emeltchenko void l2cap_chan_set_defaults(struct l2cap_chan *chan);
987466f8004SAndrei Emeltchenko int l2cap_ertm_init(struct l2cap_chan *chan);
988466f8004SAndrei Emeltchenko void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
98993c3e8f5SAndrei Emeltchenko void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
990da49b602SLuiz Augusto von Dentz typedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data);
991da49b602SLuiz Augusto von Dentz void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func,
992da49b602SLuiz Augusto von Dentz 		     void *data);
993466f8004SAndrei Emeltchenko void l2cap_chan_del(struct l2cap_chan *chan, int err);
9942766be48SAndrei Emeltchenko void l2cap_send_conn_req(struct l2cap_chan *chan);
9953f7a56c4SMat Martineau void l2cap_move_start(struct l2cap_chan *chan);
99627695fb4SAndrei Emeltchenko void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
99727695fb4SAndrei Emeltchenko 		       u8 status);
998a514b17fSAndrei Emeltchenko void __l2cap_physical_cfm(struct l2cap_chan *chan, int result);
999bb58f747SGustavo F. Padovan 
100051bb8457SJohan Hedberg struct l2cap_conn *l2cap_conn_get(struct l2cap_conn *conn);
10019c903e37SDavid Herrmann void l2cap_conn_put(struct l2cap_conn *conn);
10029c903e37SDavid Herrmann 
10032c8e1411SDavid Herrmann int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
10042c8e1411SDavid Herrmann void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user);
10052c8e1411SDavid Herrmann 
10061da177e4SLinus Torvalds #endif /* __L2CAP_H */
1007