18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci   BlueZ - Bluetooth protocol stack for Linux
38c2ecf20Sopenharmony_ci   Copyright (C) 2000-2001 Qualcomm Incorporated
48c2ecf20Sopenharmony_ci   Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org>
58c2ecf20Sopenharmony_ci   Copyright (C) 2010 Google Inc.
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci   Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci   This program is free software; you can redistribute it and/or modify
108c2ecf20Sopenharmony_ci   it under the terms of the GNU General Public License version 2 as
118c2ecf20Sopenharmony_ci   published by the Free Software Foundation;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
148c2ecf20Sopenharmony_ci   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
158c2ecf20Sopenharmony_ci   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
168c2ecf20Sopenharmony_ci   IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
178c2ecf20Sopenharmony_ci   CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
188c2ecf20Sopenharmony_ci   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
198c2ecf20Sopenharmony_ci   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
208c2ecf20Sopenharmony_ci   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci   ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
238c2ecf20Sopenharmony_ci   COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
248c2ecf20Sopenharmony_ci   SOFTWARE IS DISCLAIMED.
258c2ecf20Sopenharmony_ci*/
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#ifndef __L2CAP_H
288c2ecf20Sopenharmony_ci#define __L2CAP_H
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#include <asm/unaligned.h>
318c2ecf20Sopenharmony_ci#include <linux/atomic.h>
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* L2CAP defaults */
348c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_MTU		672
358c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_MIN_MTU		48
368c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_FLUSH_TO		0xFFFF
378c2ecf20Sopenharmony_ci#define L2CAP_EFS_DEFAULT_FLUSH_TO	0xFFFFFFFF
388c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_TX_WINDOW		63
398c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_EXT_WINDOW	0x3FFF
408c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_MAX_TX		3
418c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_RETRANS_TO	2000    /* 2 seconds */
428c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_MONITOR_TO	12000   /* 12 seconds */
438c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_MAX_PDU_SIZE	1492    /* Sized for AMP packet */
448c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_ACK_TO		200
458c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_MAX_SDU_SIZE	0xFFFF
468c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_SDU_ITIME		0xFFFFFFFF
478c2ecf20Sopenharmony_ci#define L2CAP_DEFAULT_ACC_LAT		0xFFFFFFFF
488c2ecf20Sopenharmony_ci#define L2CAP_BREDR_MAX_PAYLOAD		1019    /* 3-DH5 packet */
498c2ecf20Sopenharmony_ci#define L2CAP_LE_MIN_MTU		23
508c2ecf20Sopenharmony_ci#define L2CAP_ECRED_CONN_SCID_MAX	5
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define L2CAP_DISC_TIMEOUT		msecs_to_jiffies(100)
538c2ecf20Sopenharmony_ci#define L2CAP_DISC_REJ_TIMEOUT		msecs_to_jiffies(5000)
548c2ecf20Sopenharmony_ci#define L2CAP_ENC_TIMEOUT		msecs_to_jiffies(5000)
558c2ecf20Sopenharmony_ci#define L2CAP_CONN_TIMEOUT		msecs_to_jiffies(40000)
568c2ecf20Sopenharmony_ci#define L2CAP_INFO_TIMEOUT		msecs_to_jiffies(4000)
578c2ecf20Sopenharmony_ci#define L2CAP_MOVE_TIMEOUT		msecs_to_jiffies(4000)
588c2ecf20Sopenharmony_ci#define L2CAP_MOVE_ERTX_TIMEOUT		msecs_to_jiffies(60000)
598c2ecf20Sopenharmony_ci#define L2CAP_WAIT_ACK_POLL_PERIOD	msecs_to_jiffies(200)
608c2ecf20Sopenharmony_ci#define L2CAP_WAIT_ACK_TIMEOUT		msecs_to_jiffies(10000)
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define L2CAP_A2MP_DEFAULT_MTU		670
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci/* L2CAP socket address */
658c2ecf20Sopenharmony_cistruct sockaddr_l2 {
668c2ecf20Sopenharmony_ci	sa_family_t	l2_family;
678c2ecf20Sopenharmony_ci	__le16		l2_psm;
688c2ecf20Sopenharmony_ci	bdaddr_t	l2_bdaddr;
698c2ecf20Sopenharmony_ci	__le16		l2_cid;
708c2ecf20Sopenharmony_ci	__u8		l2_bdaddr_type;
718c2ecf20Sopenharmony_ci};
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci/* L2CAP socket options */
748c2ecf20Sopenharmony_ci#define L2CAP_OPTIONS	0x01
758c2ecf20Sopenharmony_cistruct l2cap_options {
768c2ecf20Sopenharmony_ci	__u16 omtu;
778c2ecf20Sopenharmony_ci	__u16 imtu;
788c2ecf20Sopenharmony_ci	__u16 flush_to;
798c2ecf20Sopenharmony_ci	__u8  mode;
808c2ecf20Sopenharmony_ci	__u8  fcs;
818c2ecf20Sopenharmony_ci	__u8  max_tx;
828c2ecf20Sopenharmony_ci	__u16 txwin_size;
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define L2CAP_CONNINFO	0x02
868c2ecf20Sopenharmony_cistruct l2cap_conninfo {
878c2ecf20Sopenharmony_ci	__u16 hci_handle;
888c2ecf20Sopenharmony_ci	__u8  dev_class[3];
898c2ecf20Sopenharmony_ci};
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define L2CAP_LM	0x03
928c2ecf20Sopenharmony_ci#define L2CAP_LM_MASTER		0x0001
938c2ecf20Sopenharmony_ci#define L2CAP_LM_AUTH		0x0002
948c2ecf20Sopenharmony_ci#define L2CAP_LM_ENCRYPT	0x0004
958c2ecf20Sopenharmony_ci#define L2CAP_LM_TRUSTED	0x0008
968c2ecf20Sopenharmony_ci#define L2CAP_LM_RELIABLE	0x0010
978c2ecf20Sopenharmony_ci#define L2CAP_LM_SECURE		0x0020
988c2ecf20Sopenharmony_ci#define L2CAP_LM_FIPS		0x0040
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/* L2CAP command codes */
1018c2ecf20Sopenharmony_ci#define L2CAP_COMMAND_REJ	0x01
1028c2ecf20Sopenharmony_ci#define L2CAP_CONN_REQ		0x02
1038c2ecf20Sopenharmony_ci#define L2CAP_CONN_RSP		0x03
1048c2ecf20Sopenharmony_ci#define L2CAP_CONF_REQ		0x04
1058c2ecf20Sopenharmony_ci#define L2CAP_CONF_RSP		0x05
1068c2ecf20Sopenharmony_ci#define L2CAP_DISCONN_REQ	0x06
1078c2ecf20Sopenharmony_ci#define L2CAP_DISCONN_RSP	0x07
1088c2ecf20Sopenharmony_ci#define L2CAP_ECHO_REQ		0x08
1098c2ecf20Sopenharmony_ci#define L2CAP_ECHO_RSP		0x09
1108c2ecf20Sopenharmony_ci#define L2CAP_INFO_REQ		0x0a
1118c2ecf20Sopenharmony_ci#define L2CAP_INFO_RSP		0x0b
1128c2ecf20Sopenharmony_ci#define L2CAP_CREATE_CHAN_REQ	0x0c
1138c2ecf20Sopenharmony_ci#define L2CAP_CREATE_CHAN_RSP	0x0d
1148c2ecf20Sopenharmony_ci#define L2CAP_MOVE_CHAN_REQ	0x0e
1158c2ecf20Sopenharmony_ci#define L2CAP_MOVE_CHAN_RSP	0x0f
1168c2ecf20Sopenharmony_ci#define L2CAP_MOVE_CHAN_CFM	0x10
1178c2ecf20Sopenharmony_ci#define L2CAP_MOVE_CHAN_CFM_RSP	0x11
1188c2ecf20Sopenharmony_ci#define L2CAP_CONN_PARAM_UPDATE_REQ	0x12
1198c2ecf20Sopenharmony_ci#define L2CAP_CONN_PARAM_UPDATE_RSP	0x13
1208c2ecf20Sopenharmony_ci#define L2CAP_LE_CONN_REQ	0x14
1218c2ecf20Sopenharmony_ci#define L2CAP_LE_CONN_RSP	0x15
1228c2ecf20Sopenharmony_ci#define L2CAP_LE_CREDITS	0x16
1238c2ecf20Sopenharmony_ci#define L2CAP_ECRED_CONN_REQ	0x17
1248c2ecf20Sopenharmony_ci#define L2CAP_ECRED_CONN_RSP	0x18
1258c2ecf20Sopenharmony_ci#define L2CAP_ECRED_RECONF_REQ	0x19
1268c2ecf20Sopenharmony_ci#define L2CAP_ECRED_RECONF_RSP	0x1a
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/* L2CAP extended feature mask */
1298c2ecf20Sopenharmony_ci#define L2CAP_FEAT_FLOWCTL	0x00000001
1308c2ecf20Sopenharmony_ci#define L2CAP_FEAT_RETRANS	0x00000002
1318c2ecf20Sopenharmony_ci#define L2CAP_FEAT_BIDIR_QOS	0x00000004
1328c2ecf20Sopenharmony_ci#define L2CAP_FEAT_ERTM		0x00000008
1338c2ecf20Sopenharmony_ci#define L2CAP_FEAT_STREAMING	0x00000010
1348c2ecf20Sopenharmony_ci#define L2CAP_FEAT_FCS		0x00000020
1358c2ecf20Sopenharmony_ci#define L2CAP_FEAT_EXT_FLOW	0x00000040
1368c2ecf20Sopenharmony_ci#define L2CAP_FEAT_FIXED_CHAN	0x00000080
1378c2ecf20Sopenharmony_ci#define L2CAP_FEAT_EXT_WINDOW	0x00000100
1388c2ecf20Sopenharmony_ci#define L2CAP_FEAT_UCD		0x00000200
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/* L2CAP checksum option */
1418c2ecf20Sopenharmony_ci#define L2CAP_FCS_NONE		0x00
1428c2ecf20Sopenharmony_ci#define L2CAP_FCS_CRC16		0x01
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/* L2CAP fixed channels */
1458c2ecf20Sopenharmony_ci#define L2CAP_FC_SIG_BREDR	0x02
1468c2ecf20Sopenharmony_ci#define L2CAP_FC_CONNLESS	0x04
1478c2ecf20Sopenharmony_ci#define L2CAP_FC_A2MP		0x08
1488c2ecf20Sopenharmony_ci#define L2CAP_FC_ATT		0x10
1498c2ecf20Sopenharmony_ci#define L2CAP_FC_SIG_LE		0x20
1508c2ecf20Sopenharmony_ci#define L2CAP_FC_SMP_LE		0x40
1518c2ecf20Sopenharmony_ci#define L2CAP_FC_SMP_BREDR	0x80
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/* L2CAP Control Field bit masks */
1548c2ecf20Sopenharmony_ci#define L2CAP_CTRL_SAR			0xC000
1558c2ecf20Sopenharmony_ci#define L2CAP_CTRL_REQSEQ		0x3F00
1568c2ecf20Sopenharmony_ci#define L2CAP_CTRL_TXSEQ		0x007E
1578c2ecf20Sopenharmony_ci#define L2CAP_CTRL_SUPERVISE		0x000C
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define L2CAP_CTRL_RETRANS		0x0080
1608c2ecf20Sopenharmony_ci#define L2CAP_CTRL_FINAL		0x0080
1618c2ecf20Sopenharmony_ci#define L2CAP_CTRL_POLL			0x0010
1628c2ecf20Sopenharmony_ci#define L2CAP_CTRL_FRAME_TYPE		0x0001 /* I- or S-Frame */
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define L2CAP_CTRL_TXSEQ_SHIFT		1
1658c2ecf20Sopenharmony_ci#define L2CAP_CTRL_SUPER_SHIFT		2
1668c2ecf20Sopenharmony_ci#define L2CAP_CTRL_POLL_SHIFT		4
1678c2ecf20Sopenharmony_ci#define L2CAP_CTRL_FINAL_SHIFT		7
1688c2ecf20Sopenharmony_ci#define L2CAP_CTRL_REQSEQ_SHIFT		8
1698c2ecf20Sopenharmony_ci#define L2CAP_CTRL_SAR_SHIFT		14
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/* L2CAP Extended Control Field bit mask */
1728c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_TXSEQ		0xFFFC0000
1738c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_SAR		0x00030000
1748c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_SUPERVISE	0x00030000
1758c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_REQSEQ		0x0000FFFC
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_POLL		0x00040000
1788c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_FINAL		0x00000002
1798c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_FRAME_TYPE	0x00000001 /* I- or S-Frame */
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_FINAL_SHIFT	1
1828c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_REQSEQ_SHIFT	2
1838c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_SAR_SHIFT	16
1848c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_SUPER_SHIFT	16
1858c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_POLL_SHIFT	18
1868c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_TXSEQ_SHIFT	18
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* L2CAP Supervisory Function */
1898c2ecf20Sopenharmony_ci#define L2CAP_SUPER_RR		0x00
1908c2ecf20Sopenharmony_ci#define L2CAP_SUPER_REJ		0x01
1918c2ecf20Sopenharmony_ci#define L2CAP_SUPER_RNR		0x02
1928c2ecf20Sopenharmony_ci#define L2CAP_SUPER_SREJ	0x03
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci/* L2CAP Segmentation and Reassembly */
1958c2ecf20Sopenharmony_ci#define L2CAP_SAR_UNSEGMENTED	0x00
1968c2ecf20Sopenharmony_ci#define L2CAP_SAR_START		0x01
1978c2ecf20Sopenharmony_ci#define L2CAP_SAR_END		0x02
1988c2ecf20Sopenharmony_ci#define L2CAP_SAR_CONTINUE	0x03
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* L2CAP Command rej. reasons */
2018c2ecf20Sopenharmony_ci#define L2CAP_REJ_NOT_UNDERSTOOD	0x0000
2028c2ecf20Sopenharmony_ci#define L2CAP_REJ_MTU_EXCEEDED		0x0001
2038c2ecf20Sopenharmony_ci#define L2CAP_REJ_INVALID_CID		0x0002
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci/* L2CAP structures */
2068c2ecf20Sopenharmony_cistruct l2cap_hdr {
2078c2ecf20Sopenharmony_ci	__le16     len;
2088c2ecf20Sopenharmony_ci	__le16     cid;
2098c2ecf20Sopenharmony_ci} __packed;
2108c2ecf20Sopenharmony_ci#define L2CAP_HDR_SIZE		4
2118c2ecf20Sopenharmony_ci#define L2CAP_ENH_HDR_SIZE	6
2128c2ecf20Sopenharmony_ci#define L2CAP_EXT_HDR_SIZE	8
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define L2CAP_FCS_SIZE		2
2158c2ecf20Sopenharmony_ci#define L2CAP_SDULEN_SIZE	2
2168c2ecf20Sopenharmony_ci#define L2CAP_PSMLEN_SIZE	2
2178c2ecf20Sopenharmony_ci#define L2CAP_ENH_CTRL_SIZE	2
2188c2ecf20Sopenharmony_ci#define L2CAP_EXT_CTRL_SIZE	4
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_cistruct l2cap_cmd_hdr {
2218c2ecf20Sopenharmony_ci	__u8       code;
2228c2ecf20Sopenharmony_ci	__u8       ident;
2238c2ecf20Sopenharmony_ci	__le16     len;
2248c2ecf20Sopenharmony_ci} __packed;
2258c2ecf20Sopenharmony_ci#define L2CAP_CMD_HDR_SIZE	4
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistruct l2cap_cmd_rej_unk {
2288c2ecf20Sopenharmony_ci	__le16     reason;
2298c2ecf20Sopenharmony_ci} __packed;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_cistruct l2cap_cmd_rej_mtu {
2328c2ecf20Sopenharmony_ci	__le16     reason;
2338c2ecf20Sopenharmony_ci	__le16     max_mtu;
2348c2ecf20Sopenharmony_ci} __packed;
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_cistruct l2cap_cmd_rej_cid {
2378c2ecf20Sopenharmony_ci	__le16     reason;
2388c2ecf20Sopenharmony_ci	__le16     scid;
2398c2ecf20Sopenharmony_ci	__le16     dcid;
2408c2ecf20Sopenharmony_ci} __packed;
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_cistruct l2cap_conn_req {
2438c2ecf20Sopenharmony_ci	__le16     psm;
2448c2ecf20Sopenharmony_ci	__le16     scid;
2458c2ecf20Sopenharmony_ci} __packed;
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_cistruct l2cap_conn_rsp {
2488c2ecf20Sopenharmony_ci	__le16     dcid;
2498c2ecf20Sopenharmony_ci	__le16     scid;
2508c2ecf20Sopenharmony_ci	__le16     result;
2518c2ecf20Sopenharmony_ci	__le16     status;
2528c2ecf20Sopenharmony_ci} __packed;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci/* protocol/service multiplexer (PSM) */
2558c2ecf20Sopenharmony_ci#define L2CAP_PSM_SDP		0x0001
2568c2ecf20Sopenharmony_ci#define L2CAP_PSM_RFCOMM	0x0003
2578c2ecf20Sopenharmony_ci#define L2CAP_PSM_3DSP		0x0021
2588c2ecf20Sopenharmony_ci#define L2CAP_PSM_IPSP		0x0023 /* 6LoWPAN */
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci#define L2CAP_PSM_DYN_START	0x1001
2618c2ecf20Sopenharmony_ci#define L2CAP_PSM_DYN_END	0xffff
2628c2ecf20Sopenharmony_ci#define L2CAP_PSM_AUTO_END	0x10ff
2638c2ecf20Sopenharmony_ci#define L2CAP_PSM_LE_DYN_START  0x0080
2648c2ecf20Sopenharmony_ci#define L2CAP_PSM_LE_DYN_END	0x00ff
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci/* channel identifier */
2678c2ecf20Sopenharmony_ci#define L2CAP_CID_SIGNALING	0x0001
2688c2ecf20Sopenharmony_ci#define L2CAP_CID_CONN_LESS	0x0002
2698c2ecf20Sopenharmony_ci#define L2CAP_CID_A2MP		0x0003
2708c2ecf20Sopenharmony_ci#define L2CAP_CID_ATT		0x0004
2718c2ecf20Sopenharmony_ci#define L2CAP_CID_LE_SIGNALING	0x0005
2728c2ecf20Sopenharmony_ci#define L2CAP_CID_SMP		0x0006
2738c2ecf20Sopenharmony_ci#define L2CAP_CID_SMP_BREDR	0x0007
2748c2ecf20Sopenharmony_ci#define L2CAP_CID_DYN_START	0x0040
2758c2ecf20Sopenharmony_ci#define L2CAP_CID_DYN_END	0xffff
2768c2ecf20Sopenharmony_ci#define L2CAP_CID_LE_DYN_END	0x007f
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci/* connect/create channel results */
2798c2ecf20Sopenharmony_ci#define L2CAP_CR_SUCCESS	0x0000
2808c2ecf20Sopenharmony_ci#define L2CAP_CR_PEND		0x0001
2818c2ecf20Sopenharmony_ci#define L2CAP_CR_BAD_PSM	0x0002
2828c2ecf20Sopenharmony_ci#define L2CAP_CR_SEC_BLOCK	0x0003
2838c2ecf20Sopenharmony_ci#define L2CAP_CR_NO_MEM		0x0004
2848c2ecf20Sopenharmony_ci#define L2CAP_CR_BAD_AMP	0x0005
2858c2ecf20Sopenharmony_ci#define L2CAP_CR_INVALID_SCID	0x0006
2868c2ecf20Sopenharmony_ci#define L2CAP_CR_SCID_IN_USE	0x0007
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci/* credit based connect results */
2898c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_SUCCESS		0x0000
2908c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_BAD_PSM		0x0002
2918c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_NO_MEM		0x0004
2928c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_AUTHENTICATION	0x0005
2938c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_AUTHORIZATION	0x0006
2948c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_BAD_KEY_SIZE	0x0007
2958c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_ENCRYPTION		0x0008
2968c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_INVALID_SCID	0x0009
2978c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_SCID_IN_USE		0X000A
2988c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_UNACCEPT_PARAMS	0X000B
2998c2ecf20Sopenharmony_ci#define L2CAP_CR_LE_INVALID_PARAMS	0X000C
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci/* connect/create channel status */
3028c2ecf20Sopenharmony_ci#define L2CAP_CS_NO_INFO	0x0000
3038c2ecf20Sopenharmony_ci#define L2CAP_CS_AUTHEN_PEND	0x0001
3048c2ecf20Sopenharmony_ci#define L2CAP_CS_AUTHOR_PEND	0x0002
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_cistruct l2cap_conf_req {
3078c2ecf20Sopenharmony_ci	__le16     dcid;
3088c2ecf20Sopenharmony_ci	__le16     flags;
3098c2ecf20Sopenharmony_ci	__u8       data[];
3108c2ecf20Sopenharmony_ci} __packed;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistruct l2cap_conf_rsp {
3138c2ecf20Sopenharmony_ci	__le16     scid;
3148c2ecf20Sopenharmony_ci	__le16     flags;
3158c2ecf20Sopenharmony_ci	__le16     result;
3168c2ecf20Sopenharmony_ci	__u8       data[];
3178c2ecf20Sopenharmony_ci} __packed;
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci#define L2CAP_CONF_SUCCESS	0x0000
3208c2ecf20Sopenharmony_ci#define L2CAP_CONF_UNACCEPT	0x0001
3218c2ecf20Sopenharmony_ci#define L2CAP_CONF_REJECT	0x0002
3228c2ecf20Sopenharmony_ci#define L2CAP_CONF_UNKNOWN	0x0003
3238c2ecf20Sopenharmony_ci#define L2CAP_CONF_PENDING	0x0004
3248c2ecf20Sopenharmony_ci#define L2CAP_CONF_EFS_REJECT	0x0005
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci/* configuration req/rsp continuation flag */
3278c2ecf20Sopenharmony_ci#define L2CAP_CONF_FLAG_CONTINUATION	0x0001
3288c2ecf20Sopenharmony_ci
3298c2ecf20Sopenharmony_cistruct l2cap_conf_opt {
3308c2ecf20Sopenharmony_ci	__u8       type;
3318c2ecf20Sopenharmony_ci	__u8       len;
3328c2ecf20Sopenharmony_ci	__u8       val[];
3338c2ecf20Sopenharmony_ci} __packed;
3348c2ecf20Sopenharmony_ci#define L2CAP_CONF_OPT_SIZE	2
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci#define L2CAP_CONF_HINT		0x80
3378c2ecf20Sopenharmony_ci#define L2CAP_CONF_MASK		0x7f
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci#define L2CAP_CONF_MTU		0x01
3408c2ecf20Sopenharmony_ci#define L2CAP_CONF_FLUSH_TO	0x02
3418c2ecf20Sopenharmony_ci#define L2CAP_CONF_QOS		0x03
3428c2ecf20Sopenharmony_ci#define L2CAP_CONF_RFC		0x04
3438c2ecf20Sopenharmony_ci#define L2CAP_CONF_FCS		0x05
3448c2ecf20Sopenharmony_ci#define L2CAP_CONF_EFS		0x06
3458c2ecf20Sopenharmony_ci#define L2CAP_CONF_EWS		0x07
3468c2ecf20Sopenharmony_ci
3478c2ecf20Sopenharmony_ci#define L2CAP_CONF_MAX_SIZE	22
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_cistruct l2cap_conf_rfc {
3508c2ecf20Sopenharmony_ci	__u8       mode;
3518c2ecf20Sopenharmony_ci	__u8       txwin_size;
3528c2ecf20Sopenharmony_ci	__u8       max_transmit;
3538c2ecf20Sopenharmony_ci	__le16     retrans_timeout;
3548c2ecf20Sopenharmony_ci	__le16     monitor_timeout;
3558c2ecf20Sopenharmony_ci	__le16     max_pdu_size;
3568c2ecf20Sopenharmony_ci} __packed;
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci#define L2CAP_MODE_BASIC	0x00
3598c2ecf20Sopenharmony_ci#define L2CAP_MODE_RETRANS	0x01
3608c2ecf20Sopenharmony_ci#define L2CAP_MODE_FLOWCTL	0x02
3618c2ecf20Sopenharmony_ci#define L2CAP_MODE_ERTM		0x03
3628c2ecf20Sopenharmony_ci#define L2CAP_MODE_STREAMING	0x04
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci/* Unlike the above this one doesn't actually map to anything that would
3658c2ecf20Sopenharmony_ci * ever be sent over the air. Therefore, use a value that's unlikely to
3668c2ecf20Sopenharmony_ci * ever be used in the BR/EDR configuration phase.
3678c2ecf20Sopenharmony_ci */
3688c2ecf20Sopenharmony_ci#define L2CAP_MODE_LE_FLOWCTL	0x80
3698c2ecf20Sopenharmony_ci#define L2CAP_MODE_EXT_FLOWCTL	0x81
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_cistruct l2cap_conf_efs {
3728c2ecf20Sopenharmony_ci	__u8	id;
3738c2ecf20Sopenharmony_ci	__u8	stype;
3748c2ecf20Sopenharmony_ci	__le16	msdu;
3758c2ecf20Sopenharmony_ci	__le32	sdu_itime;
3768c2ecf20Sopenharmony_ci	__le32	acc_lat;
3778c2ecf20Sopenharmony_ci	__le32	flush_to;
3788c2ecf20Sopenharmony_ci} __packed;
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci#define L2CAP_SERV_NOTRAFIC	0x00
3818c2ecf20Sopenharmony_ci#define L2CAP_SERV_BESTEFFORT	0x01
3828c2ecf20Sopenharmony_ci#define L2CAP_SERV_GUARANTEED	0x02
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci#define L2CAP_BESTEFFORT_ID	0x01
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_cistruct l2cap_disconn_req {
3878c2ecf20Sopenharmony_ci	__le16     dcid;
3888c2ecf20Sopenharmony_ci	__le16     scid;
3898c2ecf20Sopenharmony_ci} __packed;
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_cistruct l2cap_disconn_rsp {
3928c2ecf20Sopenharmony_ci	__le16     dcid;
3938c2ecf20Sopenharmony_ci	__le16     scid;
3948c2ecf20Sopenharmony_ci} __packed;
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistruct l2cap_info_req {
3978c2ecf20Sopenharmony_ci	__le16      type;
3988c2ecf20Sopenharmony_ci} __packed;
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_cistruct l2cap_info_rsp {
4018c2ecf20Sopenharmony_ci	__le16      type;
4028c2ecf20Sopenharmony_ci	__le16      result;
4038c2ecf20Sopenharmony_ci	__u8        data[];
4048c2ecf20Sopenharmony_ci} __packed;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_cistruct l2cap_create_chan_req {
4078c2ecf20Sopenharmony_ci	__le16      psm;
4088c2ecf20Sopenharmony_ci	__le16      scid;
4098c2ecf20Sopenharmony_ci	__u8        amp_id;
4108c2ecf20Sopenharmony_ci} __packed;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistruct l2cap_create_chan_rsp {
4138c2ecf20Sopenharmony_ci	__le16      dcid;
4148c2ecf20Sopenharmony_ci	__le16      scid;
4158c2ecf20Sopenharmony_ci	__le16      result;
4168c2ecf20Sopenharmony_ci	__le16      status;
4178c2ecf20Sopenharmony_ci} __packed;
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistruct l2cap_move_chan_req {
4208c2ecf20Sopenharmony_ci	__le16      icid;
4218c2ecf20Sopenharmony_ci	__u8        dest_amp_id;
4228c2ecf20Sopenharmony_ci} __packed;
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_cistruct l2cap_move_chan_rsp {
4258c2ecf20Sopenharmony_ci	__le16      icid;
4268c2ecf20Sopenharmony_ci	__le16      result;
4278c2ecf20Sopenharmony_ci} __packed;
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci#define L2CAP_MR_SUCCESS	0x0000
4308c2ecf20Sopenharmony_ci#define L2CAP_MR_PEND		0x0001
4318c2ecf20Sopenharmony_ci#define L2CAP_MR_BAD_ID		0x0002
4328c2ecf20Sopenharmony_ci#define L2CAP_MR_SAME_ID	0x0003
4338c2ecf20Sopenharmony_ci#define L2CAP_MR_NOT_SUPP	0x0004
4348c2ecf20Sopenharmony_ci#define L2CAP_MR_COLLISION	0x0005
4358c2ecf20Sopenharmony_ci#define L2CAP_MR_NOT_ALLOWED	0x0006
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_cistruct l2cap_move_chan_cfm {
4388c2ecf20Sopenharmony_ci	__le16      icid;
4398c2ecf20Sopenharmony_ci	__le16      result;
4408c2ecf20Sopenharmony_ci} __packed;
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci#define L2CAP_MC_CONFIRMED	0x0000
4438c2ecf20Sopenharmony_ci#define L2CAP_MC_UNCONFIRMED	0x0001
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_cistruct l2cap_move_chan_cfm_rsp {
4468c2ecf20Sopenharmony_ci	__le16      icid;
4478c2ecf20Sopenharmony_ci} __packed;
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci/* info type */
4508c2ecf20Sopenharmony_ci#define L2CAP_IT_CL_MTU		0x0001
4518c2ecf20Sopenharmony_ci#define L2CAP_IT_FEAT_MASK	0x0002
4528c2ecf20Sopenharmony_ci#define L2CAP_IT_FIXED_CHAN	0x0003
4538c2ecf20Sopenharmony_ci
4548c2ecf20Sopenharmony_ci/* info result */
4558c2ecf20Sopenharmony_ci#define L2CAP_IR_SUCCESS	0x0000
4568c2ecf20Sopenharmony_ci#define L2CAP_IR_NOTSUPP	0x0001
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_cistruct l2cap_conn_param_update_req {
4598c2ecf20Sopenharmony_ci	__le16      min;
4608c2ecf20Sopenharmony_ci	__le16      max;
4618c2ecf20Sopenharmony_ci	__le16      latency;
4628c2ecf20Sopenharmony_ci	__le16      to_multiplier;
4638c2ecf20Sopenharmony_ci} __packed;
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistruct l2cap_conn_param_update_rsp {
4668c2ecf20Sopenharmony_ci	__le16      result;
4678c2ecf20Sopenharmony_ci} __packed;
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_ci/* Connection Parameters result */
4708c2ecf20Sopenharmony_ci#define L2CAP_CONN_PARAM_ACCEPTED	0x0000
4718c2ecf20Sopenharmony_ci#define L2CAP_CONN_PARAM_REJECTED	0x0001
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_cistruct l2cap_le_conn_req {
4748c2ecf20Sopenharmony_ci	__le16     psm;
4758c2ecf20Sopenharmony_ci	__le16     scid;
4768c2ecf20Sopenharmony_ci	__le16     mtu;
4778c2ecf20Sopenharmony_ci	__le16     mps;
4788c2ecf20Sopenharmony_ci	__le16     credits;
4798c2ecf20Sopenharmony_ci} __packed;
4808c2ecf20Sopenharmony_ci
4818c2ecf20Sopenharmony_cistruct l2cap_le_conn_rsp {
4828c2ecf20Sopenharmony_ci	__le16     dcid;
4838c2ecf20Sopenharmony_ci	__le16     mtu;
4848c2ecf20Sopenharmony_ci	__le16     mps;
4858c2ecf20Sopenharmony_ci	__le16     credits;
4868c2ecf20Sopenharmony_ci	__le16     result;
4878c2ecf20Sopenharmony_ci} __packed;
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_cistruct l2cap_le_credits {
4908c2ecf20Sopenharmony_ci	__le16     cid;
4918c2ecf20Sopenharmony_ci	__le16     credits;
4928c2ecf20Sopenharmony_ci} __packed;
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci#define L2CAP_ECRED_MIN_MTU		64
4958c2ecf20Sopenharmony_ci#define L2CAP_ECRED_MIN_MPS		64
4968c2ecf20Sopenharmony_ci#define L2CAP_ECRED_MAX_CID		5
4978c2ecf20Sopenharmony_ci
4988c2ecf20Sopenharmony_cistruct l2cap_ecred_conn_req {
4998c2ecf20Sopenharmony_ci	__le16 psm;
5008c2ecf20Sopenharmony_ci	__le16 mtu;
5018c2ecf20Sopenharmony_ci	__le16 mps;
5028c2ecf20Sopenharmony_ci	__le16 credits;
5038c2ecf20Sopenharmony_ci	__le16 scid[];
5048c2ecf20Sopenharmony_ci} __packed;
5058c2ecf20Sopenharmony_ci
5068c2ecf20Sopenharmony_cistruct l2cap_ecred_conn_rsp {
5078c2ecf20Sopenharmony_ci	__le16 mtu;
5088c2ecf20Sopenharmony_ci	__le16 mps;
5098c2ecf20Sopenharmony_ci	__le16 credits;
5108c2ecf20Sopenharmony_ci	__le16 result;
5118c2ecf20Sopenharmony_ci	__le16 dcid[];
5128c2ecf20Sopenharmony_ci};
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_cistruct l2cap_ecred_reconf_req {
5158c2ecf20Sopenharmony_ci	__le16 mtu;
5168c2ecf20Sopenharmony_ci	__le16 mps;
5178c2ecf20Sopenharmony_ci	__le16 scid[];
5188c2ecf20Sopenharmony_ci} __packed;
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ci#define L2CAP_RECONF_SUCCESS		0x0000
5218c2ecf20Sopenharmony_ci#define L2CAP_RECONF_INVALID_MTU	0x0001
5228c2ecf20Sopenharmony_ci#define L2CAP_RECONF_INVALID_MPS	0x0002
5238c2ecf20Sopenharmony_ci
5248c2ecf20Sopenharmony_cistruct l2cap_ecred_reconf_rsp {
5258c2ecf20Sopenharmony_ci	__le16 result;
5268c2ecf20Sopenharmony_ci} __packed;
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci/* ----- L2CAP channels and connections ----- */
5298c2ecf20Sopenharmony_cistruct l2cap_seq_list {
5308c2ecf20Sopenharmony_ci	__u16	head;
5318c2ecf20Sopenharmony_ci	__u16	tail;
5328c2ecf20Sopenharmony_ci	__u16	mask;
5338c2ecf20Sopenharmony_ci	__u16	*list;
5348c2ecf20Sopenharmony_ci};
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci#define L2CAP_SEQ_LIST_CLEAR	0xFFFF
5378c2ecf20Sopenharmony_ci#define L2CAP_SEQ_LIST_TAIL	0x8000
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_cistruct l2cap_chan {
5408c2ecf20Sopenharmony_ci	struct l2cap_conn	*conn;
5418c2ecf20Sopenharmony_ci	struct hci_conn		*hs_hcon;
5428c2ecf20Sopenharmony_ci	struct hci_chan		*hs_hchan;
5438c2ecf20Sopenharmony_ci	struct kref	kref;
5448c2ecf20Sopenharmony_ci	atomic_t	nesting;
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	__u8		state;
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci	bdaddr_t	dst;
5498c2ecf20Sopenharmony_ci	__u8		dst_type;
5508c2ecf20Sopenharmony_ci	bdaddr_t	src;
5518c2ecf20Sopenharmony_ci	__u8		src_type;
5528c2ecf20Sopenharmony_ci	__le16		psm;
5538c2ecf20Sopenharmony_ci	__le16		sport;
5548c2ecf20Sopenharmony_ci	__u16		dcid;
5558c2ecf20Sopenharmony_ci	__u16		scid;
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	__u16		imtu;
5588c2ecf20Sopenharmony_ci	__u16		omtu;
5598c2ecf20Sopenharmony_ci	__u16		flush_to;
5608c2ecf20Sopenharmony_ci	__u8		mode;
5618c2ecf20Sopenharmony_ci	__u8		chan_type;
5628c2ecf20Sopenharmony_ci	__u8		chan_policy;
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci	__u8		sec_level;
5658c2ecf20Sopenharmony_ci
5668c2ecf20Sopenharmony_ci	__u8		ident;
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	__u8		conf_req[64];
5698c2ecf20Sopenharmony_ci	__u8		conf_len;
5708c2ecf20Sopenharmony_ci	__u8		num_conf_req;
5718c2ecf20Sopenharmony_ci	__u8		num_conf_rsp;
5728c2ecf20Sopenharmony_ci
5738c2ecf20Sopenharmony_ci	__u8		fcs;
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci	__u16		tx_win;
5768c2ecf20Sopenharmony_ci	__u16		tx_win_max;
5778c2ecf20Sopenharmony_ci	__u16		ack_win;
5788c2ecf20Sopenharmony_ci	__u8		max_tx;
5798c2ecf20Sopenharmony_ci	__u16		retrans_timeout;
5808c2ecf20Sopenharmony_ci	__u16		monitor_timeout;
5818c2ecf20Sopenharmony_ci	__u16		mps;
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci	__u16		tx_credits;
5848c2ecf20Sopenharmony_ci	__u16		rx_credits;
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	__u8		tx_state;
5878c2ecf20Sopenharmony_ci	__u8		rx_state;
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci	unsigned long	conf_state;
5908c2ecf20Sopenharmony_ci	unsigned long	conn_state;
5918c2ecf20Sopenharmony_ci	unsigned long	flags;
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci	__u8		remote_amp_id;
5948c2ecf20Sopenharmony_ci	__u8		local_amp_id;
5958c2ecf20Sopenharmony_ci	__u8		move_id;
5968c2ecf20Sopenharmony_ci	__u8		move_state;
5978c2ecf20Sopenharmony_ci	__u8		move_role;
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci	__u16		next_tx_seq;
6008c2ecf20Sopenharmony_ci	__u16		expected_ack_seq;
6018c2ecf20Sopenharmony_ci	__u16		expected_tx_seq;
6028c2ecf20Sopenharmony_ci	__u16		buffer_seq;
6038c2ecf20Sopenharmony_ci	__u16		srej_save_reqseq;
6048c2ecf20Sopenharmony_ci	__u16		last_acked_seq;
6058c2ecf20Sopenharmony_ci	__u16		frames_sent;
6068c2ecf20Sopenharmony_ci	__u16		unacked_frames;
6078c2ecf20Sopenharmony_ci	__u8		retry_count;
6088c2ecf20Sopenharmony_ci	__u16		sdu_len;
6098c2ecf20Sopenharmony_ci	struct sk_buff	*sdu;
6108c2ecf20Sopenharmony_ci	struct sk_buff	*sdu_last_frag;
6118c2ecf20Sopenharmony_ci
6128c2ecf20Sopenharmony_ci	__u16		remote_tx_win;
6138c2ecf20Sopenharmony_ci	__u8		remote_max_tx;
6148c2ecf20Sopenharmony_ci	__u16		remote_mps;
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci	__u8		local_id;
6178c2ecf20Sopenharmony_ci	__u8		local_stype;
6188c2ecf20Sopenharmony_ci	__u16		local_msdu;
6198c2ecf20Sopenharmony_ci	__u32		local_sdu_itime;
6208c2ecf20Sopenharmony_ci	__u32		local_acc_lat;
6218c2ecf20Sopenharmony_ci	__u32		local_flush_to;
6228c2ecf20Sopenharmony_ci
6238c2ecf20Sopenharmony_ci	__u8		remote_id;
6248c2ecf20Sopenharmony_ci	__u8		remote_stype;
6258c2ecf20Sopenharmony_ci	__u16		remote_msdu;
6268c2ecf20Sopenharmony_ci	__u32		remote_sdu_itime;
6278c2ecf20Sopenharmony_ci	__u32		remote_acc_lat;
6288c2ecf20Sopenharmony_ci	__u32		remote_flush_to;
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	struct delayed_work	chan_timer;
6318c2ecf20Sopenharmony_ci	struct delayed_work	retrans_timer;
6328c2ecf20Sopenharmony_ci	struct delayed_work	monitor_timer;
6338c2ecf20Sopenharmony_ci	struct delayed_work	ack_timer;
6348c2ecf20Sopenharmony_ci
6358c2ecf20Sopenharmony_ci	struct sk_buff		*tx_send_head;
6368c2ecf20Sopenharmony_ci	struct sk_buff_head	tx_q;
6378c2ecf20Sopenharmony_ci	struct sk_buff_head	srej_q;
6388c2ecf20Sopenharmony_ci	struct l2cap_seq_list	srej_list;
6398c2ecf20Sopenharmony_ci	struct l2cap_seq_list	retrans_list;
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci	struct list_head	list;
6428c2ecf20Sopenharmony_ci	struct list_head	global_l;
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_ci	void			*data;
6458c2ecf20Sopenharmony_ci	const struct l2cap_ops	*ops;
6468c2ecf20Sopenharmony_ci	struct mutex		lock;
6478c2ecf20Sopenharmony_ci};
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_cistruct l2cap_ops {
6508c2ecf20Sopenharmony_ci	char			*name;
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci	struct l2cap_chan	*(*new_connection) (struct l2cap_chan *chan);
6538c2ecf20Sopenharmony_ci	int			(*recv) (struct l2cap_chan * chan,
6548c2ecf20Sopenharmony_ci					 struct sk_buff *skb);
6558c2ecf20Sopenharmony_ci	void			(*teardown) (struct l2cap_chan *chan, int err);
6568c2ecf20Sopenharmony_ci	void			(*close) (struct l2cap_chan *chan);
6578c2ecf20Sopenharmony_ci	void			(*state_change) (struct l2cap_chan *chan,
6588c2ecf20Sopenharmony_ci						 int state, int err);
6598c2ecf20Sopenharmony_ci	void			(*ready) (struct l2cap_chan *chan);
6608c2ecf20Sopenharmony_ci	void			(*defer) (struct l2cap_chan *chan);
6618c2ecf20Sopenharmony_ci	void			(*resume) (struct l2cap_chan *chan);
6628c2ecf20Sopenharmony_ci	void			(*suspend) (struct l2cap_chan *chan);
6638c2ecf20Sopenharmony_ci	void			(*set_shutdown) (struct l2cap_chan *chan);
6648c2ecf20Sopenharmony_ci	long			(*get_sndtimeo) (struct l2cap_chan *chan);
6658c2ecf20Sopenharmony_ci	struct pid		*(*get_peer_pid) (struct l2cap_chan *chan);
6668c2ecf20Sopenharmony_ci	struct sk_buff		*(*alloc_skb) (struct l2cap_chan *chan,
6678c2ecf20Sopenharmony_ci					       unsigned long hdr_len,
6688c2ecf20Sopenharmony_ci					       unsigned long len, int nb);
6698c2ecf20Sopenharmony_ci	int			(*filter) (struct l2cap_chan * chan,
6708c2ecf20Sopenharmony_ci					   struct sk_buff *skb);
6718c2ecf20Sopenharmony_ci};
6728c2ecf20Sopenharmony_ci
6738c2ecf20Sopenharmony_cistruct l2cap_conn {
6748c2ecf20Sopenharmony_ci	struct hci_conn		*hcon;
6758c2ecf20Sopenharmony_ci	struct hci_chan		*hchan;
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci	unsigned int		mtu;
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci	__u32			feat_mask;
6808c2ecf20Sopenharmony_ci	__u8			remote_fixed_chan;
6818c2ecf20Sopenharmony_ci	__u8			local_fixed_chan;
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci	__u8			info_state;
6848c2ecf20Sopenharmony_ci	__u8			info_ident;
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ci	struct delayed_work	info_timer;
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_ci	struct sk_buff		*rx_skb;
6898c2ecf20Sopenharmony_ci	__u32			rx_len;
6908c2ecf20Sopenharmony_ci	__u8			tx_ident;
6918c2ecf20Sopenharmony_ci	struct mutex		ident_lock;
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	struct sk_buff_head	pending_rx;
6948c2ecf20Sopenharmony_ci	struct work_struct	pending_rx_work;
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci	struct work_struct	id_addr_update_work;
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci	__u8			disc_reason;
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci	struct l2cap_chan	*smp;
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci	struct list_head	chan_l;
7038c2ecf20Sopenharmony_ci	struct mutex		chan_lock;
7048c2ecf20Sopenharmony_ci	struct kref		ref;
7058c2ecf20Sopenharmony_ci	struct list_head	users;
7068c2ecf20Sopenharmony_ci};
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_cistruct l2cap_user {
7098c2ecf20Sopenharmony_ci	struct list_head list;
7108c2ecf20Sopenharmony_ci	int (*probe) (struct l2cap_conn *conn, struct l2cap_user *user);
7118c2ecf20Sopenharmony_ci	void (*remove) (struct l2cap_conn *conn, struct l2cap_user *user);
7128c2ecf20Sopenharmony_ci};
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_ci#define L2CAP_INFO_CL_MTU_REQ_SENT	0x01
7158c2ecf20Sopenharmony_ci#define L2CAP_INFO_FEAT_MASK_REQ_SENT	0x04
7168c2ecf20Sopenharmony_ci#define L2CAP_INFO_FEAT_MASK_REQ_DONE	0x08
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ci#define L2CAP_CHAN_RAW			1
7198c2ecf20Sopenharmony_ci#define L2CAP_CHAN_CONN_LESS		2
7208c2ecf20Sopenharmony_ci#define L2CAP_CHAN_CONN_ORIENTED	3
7218c2ecf20Sopenharmony_ci#define L2CAP_CHAN_FIXED		4
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci/* ----- L2CAP socket info ----- */
7248c2ecf20Sopenharmony_ci#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_cistruct l2cap_pinfo {
7278c2ecf20Sopenharmony_ci	struct bt_sock		bt;
7288c2ecf20Sopenharmony_ci	struct l2cap_chan	*chan;
7298c2ecf20Sopenharmony_ci	struct sk_buff		*rx_busy_skb;
7308c2ecf20Sopenharmony_ci};
7318c2ecf20Sopenharmony_ci
7328c2ecf20Sopenharmony_cienum {
7338c2ecf20Sopenharmony_ci	CONF_REQ_SENT,
7348c2ecf20Sopenharmony_ci	CONF_INPUT_DONE,
7358c2ecf20Sopenharmony_ci	CONF_OUTPUT_DONE,
7368c2ecf20Sopenharmony_ci	CONF_MTU_DONE,
7378c2ecf20Sopenharmony_ci	CONF_MODE_DONE,
7388c2ecf20Sopenharmony_ci	CONF_CONNECT_PEND,
7398c2ecf20Sopenharmony_ci	CONF_RECV_NO_FCS,
7408c2ecf20Sopenharmony_ci	CONF_STATE2_DEVICE,
7418c2ecf20Sopenharmony_ci	CONF_EWS_RECV,
7428c2ecf20Sopenharmony_ci	CONF_LOC_CONF_PEND,
7438c2ecf20Sopenharmony_ci	CONF_REM_CONF_PEND,
7448c2ecf20Sopenharmony_ci	CONF_NOT_COMPLETE,
7458c2ecf20Sopenharmony_ci};
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_ci#define L2CAP_CONF_MAX_CONF_REQ 2
7488c2ecf20Sopenharmony_ci#define L2CAP_CONF_MAX_CONF_RSP 2
7498c2ecf20Sopenharmony_ci
7508c2ecf20Sopenharmony_cienum {
7518c2ecf20Sopenharmony_ci	CONN_SREJ_SENT,
7528c2ecf20Sopenharmony_ci	CONN_WAIT_F,
7538c2ecf20Sopenharmony_ci	CONN_SREJ_ACT,
7548c2ecf20Sopenharmony_ci	CONN_SEND_PBIT,
7558c2ecf20Sopenharmony_ci	CONN_REMOTE_BUSY,
7568c2ecf20Sopenharmony_ci	CONN_LOCAL_BUSY,
7578c2ecf20Sopenharmony_ci	CONN_REJ_ACT,
7588c2ecf20Sopenharmony_ci	CONN_SEND_FBIT,
7598c2ecf20Sopenharmony_ci	CONN_RNR_SENT,
7608c2ecf20Sopenharmony_ci};
7618c2ecf20Sopenharmony_ci
7628c2ecf20Sopenharmony_ci/* Definitions for flags in l2cap_chan */
7638c2ecf20Sopenharmony_cienum {
7648c2ecf20Sopenharmony_ci	FLAG_ROLE_SWITCH,
7658c2ecf20Sopenharmony_ci	FLAG_FORCE_ACTIVE,
7668c2ecf20Sopenharmony_ci	FLAG_FORCE_RELIABLE,
7678c2ecf20Sopenharmony_ci	FLAG_FLUSHABLE,
7688c2ecf20Sopenharmony_ci	FLAG_EXT_CTRL,
7698c2ecf20Sopenharmony_ci	FLAG_EFS_ENABLE,
7708c2ecf20Sopenharmony_ci	FLAG_DEFER_SETUP,
7718c2ecf20Sopenharmony_ci	FLAG_LE_CONN_REQ_SENT,
7728c2ecf20Sopenharmony_ci	FLAG_ECRED_CONN_REQ_SENT,
7738c2ecf20Sopenharmony_ci	FLAG_PENDING_SECURITY,
7748c2ecf20Sopenharmony_ci	FLAG_HOLD_HCI_CONN,
7758c2ecf20Sopenharmony_ci};
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci/* Lock nesting levels for L2CAP channels. We need these because lockdep
7788c2ecf20Sopenharmony_ci * otherwise considers all channels equal and will e.g. complain about a
7798c2ecf20Sopenharmony_ci * connection oriented channel triggering SMP procedures or a listening
7808c2ecf20Sopenharmony_ci * channel creating and locking a child channel.
7818c2ecf20Sopenharmony_ci */
7828c2ecf20Sopenharmony_cienum {
7838c2ecf20Sopenharmony_ci	L2CAP_NESTING_SMP,
7848c2ecf20Sopenharmony_ci	L2CAP_NESTING_NORMAL,
7858c2ecf20Sopenharmony_ci	L2CAP_NESTING_PARENT,
7868c2ecf20Sopenharmony_ci};
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_cienum {
7898c2ecf20Sopenharmony_ci	L2CAP_TX_STATE_XMIT,
7908c2ecf20Sopenharmony_ci	L2CAP_TX_STATE_WAIT_F,
7918c2ecf20Sopenharmony_ci};
7928c2ecf20Sopenharmony_ci
7938c2ecf20Sopenharmony_cienum {
7948c2ecf20Sopenharmony_ci	L2CAP_RX_STATE_RECV,
7958c2ecf20Sopenharmony_ci	L2CAP_RX_STATE_SREJ_SENT,
7968c2ecf20Sopenharmony_ci	L2CAP_RX_STATE_MOVE,
7978c2ecf20Sopenharmony_ci	L2CAP_RX_STATE_WAIT_P,
7988c2ecf20Sopenharmony_ci	L2CAP_RX_STATE_WAIT_F,
7998c2ecf20Sopenharmony_ci};
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_cienum {
8028c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_EXPECTED,
8038c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_EXPECTED_SREJ,
8048c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_UNEXPECTED,
8058c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_UNEXPECTED_SREJ,
8068c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_DUPLICATE,
8078c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_DUPLICATE_SREJ,
8088c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_INVALID,
8098c2ecf20Sopenharmony_ci	L2CAP_TXSEQ_INVALID_IGNORE,
8108c2ecf20Sopenharmony_ci};
8118c2ecf20Sopenharmony_ci
8128c2ecf20Sopenharmony_cienum {
8138c2ecf20Sopenharmony_ci	L2CAP_EV_DATA_REQUEST,
8148c2ecf20Sopenharmony_ci	L2CAP_EV_LOCAL_BUSY_DETECTED,
8158c2ecf20Sopenharmony_ci	L2CAP_EV_LOCAL_BUSY_CLEAR,
8168c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_REQSEQ_AND_FBIT,
8178c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_FBIT,
8188c2ecf20Sopenharmony_ci	L2CAP_EV_RETRANS_TO,
8198c2ecf20Sopenharmony_ci	L2CAP_EV_MONITOR_TO,
8208c2ecf20Sopenharmony_ci	L2CAP_EV_EXPLICIT_POLL,
8218c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_IFRAME,
8228c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_RR,
8238c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_REJ,
8248c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_RNR,
8258c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_SREJ,
8268c2ecf20Sopenharmony_ci	L2CAP_EV_RECV_FRAME,
8278c2ecf20Sopenharmony_ci};
8288c2ecf20Sopenharmony_ci
8298c2ecf20Sopenharmony_cienum {
8308c2ecf20Sopenharmony_ci	L2CAP_MOVE_ROLE_NONE,
8318c2ecf20Sopenharmony_ci	L2CAP_MOVE_ROLE_INITIATOR,
8328c2ecf20Sopenharmony_ci	L2CAP_MOVE_ROLE_RESPONDER,
8338c2ecf20Sopenharmony_ci};
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_cienum {
8368c2ecf20Sopenharmony_ci	L2CAP_MOVE_STABLE,
8378c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_REQ,
8388c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_RSP,
8398c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_RSP_SUCCESS,
8408c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_CONFIRM,
8418c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_CONFIRM_RSP,
8428c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_LOGICAL_COMP,
8438c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_LOGICAL_CFM,
8448c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_LOCAL_BUSY,
8458c2ecf20Sopenharmony_ci	L2CAP_MOVE_WAIT_PREPARE,
8468c2ecf20Sopenharmony_ci};
8478c2ecf20Sopenharmony_ci
8488c2ecf20Sopenharmony_civoid l2cap_chan_hold(struct l2cap_chan *c);
8498c2ecf20Sopenharmony_cistruct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c);
8508c2ecf20Sopenharmony_civoid l2cap_chan_put(struct l2cap_chan *c);
8518c2ecf20Sopenharmony_ci
8528c2ecf20Sopenharmony_cistatic inline void l2cap_chan_lock(struct l2cap_chan *chan)
8538c2ecf20Sopenharmony_ci{
8548c2ecf20Sopenharmony_ci	mutex_lock_nested(&chan->lock, atomic_read(&chan->nesting));
8558c2ecf20Sopenharmony_ci}
8568c2ecf20Sopenharmony_ci
8578c2ecf20Sopenharmony_cistatic inline void l2cap_chan_unlock(struct l2cap_chan *chan)
8588c2ecf20Sopenharmony_ci{
8598c2ecf20Sopenharmony_ci	mutex_unlock(&chan->lock);
8608c2ecf20Sopenharmony_ci}
8618c2ecf20Sopenharmony_ci
8628c2ecf20Sopenharmony_cistatic inline void l2cap_set_timer(struct l2cap_chan *chan,
8638c2ecf20Sopenharmony_ci				   struct delayed_work *work, long timeout)
8648c2ecf20Sopenharmony_ci{
8658c2ecf20Sopenharmony_ci	BT_DBG("chan %p state %s timeout %ld", chan,
8668c2ecf20Sopenharmony_ci	       state_to_string(chan->state), timeout);
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ci	/* If delayed work cancelled do not hold(chan)
8698c2ecf20Sopenharmony_ci	   since it is already done with previous set_timer */
8708c2ecf20Sopenharmony_ci	if (!cancel_delayed_work(work))
8718c2ecf20Sopenharmony_ci		l2cap_chan_hold(chan);
8728c2ecf20Sopenharmony_ci
8738c2ecf20Sopenharmony_ci	schedule_delayed_work(work, timeout);
8748c2ecf20Sopenharmony_ci}
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_cistatic inline bool l2cap_clear_timer(struct l2cap_chan *chan,
8778c2ecf20Sopenharmony_ci				     struct delayed_work *work)
8788c2ecf20Sopenharmony_ci{
8798c2ecf20Sopenharmony_ci	bool ret;
8808c2ecf20Sopenharmony_ci
8818c2ecf20Sopenharmony_ci	/* put(chan) if delayed work cancelled otherwise it
8828c2ecf20Sopenharmony_ci	   is done in delayed work function */
8838c2ecf20Sopenharmony_ci	ret = cancel_delayed_work(work);
8848c2ecf20Sopenharmony_ci	if (ret)
8858c2ecf20Sopenharmony_ci		l2cap_chan_put(chan);
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci	return ret;
8888c2ecf20Sopenharmony_ci}
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_ci#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
8918c2ecf20Sopenharmony_ci#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
8928c2ecf20Sopenharmony_ci#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
8938c2ecf20Sopenharmony_ci#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
8948c2ecf20Sopenharmony_ci#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
8958c2ecf20Sopenharmony_ci		msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
8968c2ecf20Sopenharmony_ci#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
8978c2ecf20Sopenharmony_ci
8988c2ecf20Sopenharmony_cistatic inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
8998c2ecf20Sopenharmony_ci{
9008c2ecf20Sopenharmony_ci	if (seq1 >= seq2)
9018c2ecf20Sopenharmony_ci		return seq1 - seq2;
9028c2ecf20Sopenharmony_ci	else
9038c2ecf20Sopenharmony_ci		return chan->tx_win_max + 1 - seq2 + seq1;
9048c2ecf20Sopenharmony_ci}
9058c2ecf20Sopenharmony_ci
9068c2ecf20Sopenharmony_cistatic inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq)
9078c2ecf20Sopenharmony_ci{
9088c2ecf20Sopenharmony_ci	return (seq + 1) % (chan->tx_win_max + 1);
9098c2ecf20Sopenharmony_ci}
9108c2ecf20Sopenharmony_ci
9118c2ecf20Sopenharmony_cistatic inline struct l2cap_chan *l2cap_chan_no_new_connection(struct l2cap_chan *chan)
9128c2ecf20Sopenharmony_ci{
9138c2ecf20Sopenharmony_ci	return NULL;
9148c2ecf20Sopenharmony_ci}
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_cistatic inline int l2cap_chan_no_recv(struct l2cap_chan *chan, struct sk_buff *skb)
9178c2ecf20Sopenharmony_ci{
9188c2ecf20Sopenharmony_ci	return -ENOSYS;
9198c2ecf20Sopenharmony_ci}
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_cistatic inline struct sk_buff *l2cap_chan_no_alloc_skb(struct l2cap_chan *chan,
9228c2ecf20Sopenharmony_ci						      unsigned long hdr_len,
9238c2ecf20Sopenharmony_ci						      unsigned long len, int nb)
9248c2ecf20Sopenharmony_ci{
9258c2ecf20Sopenharmony_ci	return ERR_PTR(-ENOSYS);
9268c2ecf20Sopenharmony_ci}
9278c2ecf20Sopenharmony_ci
9288c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_teardown(struct l2cap_chan *chan, int err)
9298c2ecf20Sopenharmony_ci{
9308c2ecf20Sopenharmony_ci}
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_close(struct l2cap_chan *chan)
9338c2ecf20Sopenharmony_ci{
9348c2ecf20Sopenharmony_ci}
9358c2ecf20Sopenharmony_ci
9368c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_ready(struct l2cap_chan *chan)
9378c2ecf20Sopenharmony_ci{
9388c2ecf20Sopenharmony_ci}
9398c2ecf20Sopenharmony_ci
9408c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_state_change(struct l2cap_chan *chan,
9418c2ecf20Sopenharmony_ci					      int state, int err)
9428c2ecf20Sopenharmony_ci{
9438c2ecf20Sopenharmony_ci}
9448c2ecf20Sopenharmony_ci
9458c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_defer(struct l2cap_chan *chan)
9468c2ecf20Sopenharmony_ci{
9478c2ecf20Sopenharmony_ci}
9488c2ecf20Sopenharmony_ci
9498c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_suspend(struct l2cap_chan *chan)
9508c2ecf20Sopenharmony_ci{
9518c2ecf20Sopenharmony_ci}
9528c2ecf20Sopenharmony_ci
9538c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_resume(struct l2cap_chan *chan)
9548c2ecf20Sopenharmony_ci{
9558c2ecf20Sopenharmony_ci}
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_cistatic inline void l2cap_chan_no_set_shutdown(struct l2cap_chan *chan)
9588c2ecf20Sopenharmony_ci{
9598c2ecf20Sopenharmony_ci}
9608c2ecf20Sopenharmony_ci
9618c2ecf20Sopenharmony_cistatic inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
9628c2ecf20Sopenharmony_ci{
9638c2ecf20Sopenharmony_ci	return 0;
9648c2ecf20Sopenharmony_ci}
9658c2ecf20Sopenharmony_ci
9668c2ecf20Sopenharmony_ciextern bool disable_ertm;
9678c2ecf20Sopenharmony_ciextern bool enable_ecred;
9688c2ecf20Sopenharmony_ci
9698c2ecf20Sopenharmony_ciint l2cap_init_sockets(void);
9708c2ecf20Sopenharmony_civoid l2cap_cleanup_sockets(void);
9718c2ecf20Sopenharmony_cibool l2cap_is_socket(struct socket *sock);
9728c2ecf20Sopenharmony_ci
9738c2ecf20Sopenharmony_civoid __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan);
9748c2ecf20Sopenharmony_civoid __l2cap_ecred_conn_rsp_defer(struct l2cap_chan *chan);
9758c2ecf20Sopenharmony_civoid __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
9768c2ecf20Sopenharmony_ci
9778c2ecf20Sopenharmony_ciint l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
9788c2ecf20Sopenharmony_ciint l2cap_add_scid(struct l2cap_chan *chan,  __u16 scid);
9798c2ecf20Sopenharmony_ci
9808c2ecf20Sopenharmony_cistruct l2cap_chan *l2cap_chan_create(void);
9818c2ecf20Sopenharmony_civoid l2cap_chan_close(struct l2cap_chan *chan, int reason);
9828c2ecf20Sopenharmony_ciint l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
9838c2ecf20Sopenharmony_ci		       bdaddr_t *dst, u8 dst_type);
9848c2ecf20Sopenharmony_ciint l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu);
9858c2ecf20Sopenharmony_ciint l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
9868c2ecf20Sopenharmony_civoid l2cap_chan_busy(struct l2cap_chan *chan, int busy);
9878c2ecf20Sopenharmony_ciint l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);
9888c2ecf20Sopenharmony_civoid l2cap_chan_set_defaults(struct l2cap_chan *chan);
9898c2ecf20Sopenharmony_ciint l2cap_ertm_init(struct l2cap_chan *chan);
9908c2ecf20Sopenharmony_civoid l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
9918c2ecf20Sopenharmony_civoid __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
9928c2ecf20Sopenharmony_citypedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data);
9938c2ecf20Sopenharmony_civoid l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func,
9948c2ecf20Sopenharmony_ci		     void *data);
9958c2ecf20Sopenharmony_civoid l2cap_chan_del(struct l2cap_chan *chan, int err);
9968c2ecf20Sopenharmony_civoid l2cap_send_conn_req(struct l2cap_chan *chan);
9978c2ecf20Sopenharmony_civoid l2cap_move_start(struct l2cap_chan *chan);
9988c2ecf20Sopenharmony_civoid l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
9998c2ecf20Sopenharmony_ci		       u8 status);
10008c2ecf20Sopenharmony_civoid __l2cap_physical_cfm(struct l2cap_chan *chan, int result);
10018c2ecf20Sopenharmony_ci
10028c2ecf20Sopenharmony_cistruct l2cap_conn *l2cap_conn_get(struct l2cap_conn *conn);
10038c2ecf20Sopenharmony_civoid l2cap_conn_put(struct l2cap_conn *conn);
10048c2ecf20Sopenharmony_ci
10058c2ecf20Sopenharmony_ciint l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
10068c2ecf20Sopenharmony_civoid l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user);
10078c2ecf20Sopenharmony_ci
10088c2ecf20Sopenharmony_ci#endif /* __L2CAP_H */
1009