Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2)    BlueZ - Bluetooth protocol stack for Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)    Copyright (C) 2000-2001 Qualcomm Incorporated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)    Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)    Copyright (C) 2010 Google Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)    Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)    This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)    it under the terms of the GNU General Public License version 2 as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)    published by the Free Software Foundation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14)    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15)    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16)    IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17)    CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18)    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19)    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20)    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22)    ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23)    COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24)    SOFTWARE IS DISCLAIMED.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #ifndef __L2CAP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #define __L2CAP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include <asm/unaligned.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) #include <linux/android_kabi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) /* L2CAP defaults */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) #define L2CAP_DEFAULT_MTU		672
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #define L2CAP_DEFAULT_MIN_MTU		48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #define L2CAP_DEFAULT_FLUSH_TO		0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) #define L2CAP_EFS_DEFAULT_FLUSH_TO	0xFFFFFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) #define L2CAP_DEFAULT_TX_WINDOW		63
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) #define L2CAP_DEFAULT_EXT_WINDOW	0x3FFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) #define L2CAP_DEFAULT_MAX_TX		3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #define L2CAP_DEFAULT_RETRANS_TO	2000    /* 2 seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) #define L2CAP_DEFAULT_MONITOR_TO	12000   /* 12 seconds */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) #define L2CAP_DEFAULT_MAX_PDU_SIZE	1492    /* Sized for AMP packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #define L2CAP_DEFAULT_ACK_TO		200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) #define L2CAP_DEFAULT_MAX_SDU_SIZE	0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) #define L2CAP_DEFAULT_SDU_ITIME		0xFFFFFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) #define L2CAP_DEFAULT_ACC_LAT		0xFFFFFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #define L2CAP_BREDR_MAX_PAYLOAD		1019    /* 3-DH5 packet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #define L2CAP_LE_MIN_MTU		23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) #define L2CAP_ECRED_CONN_SCID_MAX	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) #define L2CAP_DISC_TIMEOUT		msecs_to_jiffies(100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) #define L2CAP_DISC_REJ_TIMEOUT		msecs_to_jiffies(5000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #define L2CAP_ENC_TIMEOUT		msecs_to_jiffies(5000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) #define L2CAP_CONN_TIMEOUT		msecs_to_jiffies(40000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #define L2CAP_INFO_TIMEOUT		msecs_to_jiffies(4000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) #define L2CAP_MOVE_TIMEOUT		msecs_to_jiffies(4000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) #define L2CAP_MOVE_ERTX_TIMEOUT		msecs_to_jiffies(60000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) #define L2CAP_WAIT_ACK_POLL_PERIOD	msecs_to_jiffies(200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) #define L2CAP_WAIT_ACK_TIMEOUT		msecs_to_jiffies(10000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) #define L2CAP_A2MP_DEFAULT_MTU		670
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) /* L2CAP socket address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) struct sockaddr_l2 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 	sa_family_t	l2_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 	__le16		l2_psm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 	bdaddr_t	l2_bdaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 	__le16		l2_cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 	__u8		l2_bdaddr_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) /* L2CAP socket options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) #define L2CAP_OPTIONS	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) struct l2cap_options {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 	__u16 omtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 	__u16 imtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 	__u16 flush_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 	__u8  mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	__u8  fcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	__u8  max_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 	__u16 txwin_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #define L2CAP_CONNINFO	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) struct l2cap_conninfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	__u16 hci_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	__u8  dev_class[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) #define L2CAP_LM	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) #define L2CAP_LM_MASTER		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) #define L2CAP_LM_AUTH		0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) #define L2CAP_LM_ENCRYPT	0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) #define L2CAP_LM_TRUSTED	0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) #define L2CAP_LM_RELIABLE	0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) #define L2CAP_LM_SECURE		0x0020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) #define L2CAP_LM_FIPS		0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) /* L2CAP command codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) #define L2CAP_COMMAND_REJ	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) #define L2CAP_CONN_REQ		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) #define L2CAP_CONN_RSP		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) #define L2CAP_CONF_REQ		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) #define L2CAP_CONF_RSP		0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) #define L2CAP_DISCONN_REQ	0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) #define L2CAP_DISCONN_RSP	0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) #define L2CAP_ECHO_REQ		0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) #define L2CAP_ECHO_RSP		0x09
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) #define L2CAP_INFO_REQ		0x0a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) #define L2CAP_INFO_RSP		0x0b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) #define L2CAP_CREATE_CHAN_REQ	0x0c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) #define L2CAP_CREATE_CHAN_RSP	0x0d
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) #define L2CAP_MOVE_CHAN_REQ	0x0e
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) #define L2CAP_MOVE_CHAN_RSP	0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) #define L2CAP_MOVE_CHAN_CFM	0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) #define L2CAP_MOVE_CHAN_CFM_RSP	0x11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) #define L2CAP_CONN_PARAM_UPDATE_REQ	0x12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) #define L2CAP_CONN_PARAM_UPDATE_RSP	0x13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) #define L2CAP_LE_CONN_REQ	0x14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) #define L2CAP_LE_CONN_RSP	0x15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) #define L2CAP_LE_CREDITS	0x16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) #define L2CAP_ECRED_CONN_REQ	0x17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) #define L2CAP_ECRED_CONN_RSP	0x18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) #define L2CAP_ECRED_RECONF_REQ	0x19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) #define L2CAP_ECRED_RECONF_RSP	0x1a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) /* L2CAP extended feature mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) #define L2CAP_FEAT_FLOWCTL	0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) #define L2CAP_FEAT_RETRANS	0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) #define L2CAP_FEAT_BIDIR_QOS	0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) #define L2CAP_FEAT_ERTM		0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) #define L2CAP_FEAT_STREAMING	0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) #define L2CAP_FEAT_FCS		0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) #define L2CAP_FEAT_EXT_FLOW	0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) #define L2CAP_FEAT_FIXED_CHAN	0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) #define L2CAP_FEAT_EXT_WINDOW	0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) #define L2CAP_FEAT_UCD		0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) /* L2CAP checksum option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) #define L2CAP_FCS_NONE		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) #define L2CAP_FCS_CRC16		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) /* L2CAP fixed channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) #define L2CAP_FC_SIG_BREDR	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) #define L2CAP_FC_CONNLESS	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) #define L2CAP_FC_A2MP		0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) #define L2CAP_FC_ATT		0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) #define L2CAP_FC_SIG_LE		0x20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) #define L2CAP_FC_SMP_LE		0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) #define L2CAP_FC_SMP_BREDR	0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) /* L2CAP Control Field bit masks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) #define L2CAP_CTRL_SAR			0xC000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) #define L2CAP_CTRL_REQSEQ		0x3F00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) #define L2CAP_CTRL_TXSEQ		0x007E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) #define L2CAP_CTRL_SUPERVISE		0x000C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) #define L2CAP_CTRL_RETRANS		0x0080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) #define L2CAP_CTRL_FINAL		0x0080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) #define L2CAP_CTRL_POLL			0x0010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) #define L2CAP_CTRL_FRAME_TYPE		0x0001 /* I- or S-Frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) #define L2CAP_CTRL_TXSEQ_SHIFT		1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) #define L2CAP_CTRL_SUPER_SHIFT		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) #define L2CAP_CTRL_POLL_SHIFT		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) #define L2CAP_CTRL_FINAL_SHIFT		7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) #define L2CAP_CTRL_REQSEQ_SHIFT		8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) #define L2CAP_CTRL_SAR_SHIFT		14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) /* L2CAP Extended Control Field bit mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) #define L2CAP_EXT_CTRL_TXSEQ		0xFFFC0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) #define L2CAP_EXT_CTRL_SAR		0x00030000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) #define L2CAP_EXT_CTRL_SUPERVISE	0x00030000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) #define L2CAP_EXT_CTRL_REQSEQ		0x0000FFFC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) #define L2CAP_EXT_CTRL_POLL		0x00040000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) #define L2CAP_EXT_CTRL_FINAL		0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) #define L2CAP_EXT_CTRL_FRAME_TYPE	0x00000001 /* I- or S-Frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) #define L2CAP_EXT_CTRL_FINAL_SHIFT	1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) #define L2CAP_EXT_CTRL_REQSEQ_SHIFT	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) #define L2CAP_EXT_CTRL_SAR_SHIFT	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) #define L2CAP_EXT_CTRL_SUPER_SHIFT	16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) #define L2CAP_EXT_CTRL_POLL_SHIFT	18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) #define L2CAP_EXT_CTRL_TXSEQ_SHIFT	18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) /* L2CAP Supervisory Function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) #define L2CAP_SUPER_RR		0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) #define L2CAP_SUPER_REJ		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) #define L2CAP_SUPER_RNR		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) #define L2CAP_SUPER_SREJ	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) /* L2CAP Segmentation and Reassembly */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) #define L2CAP_SAR_UNSEGMENTED	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) #define L2CAP_SAR_START		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) #define L2CAP_SAR_END		0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) #define L2CAP_SAR_CONTINUE	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) /* L2CAP Command rej. reasons */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) #define L2CAP_REJ_NOT_UNDERSTOOD	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) #define L2CAP_REJ_MTU_EXCEEDED		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) #define L2CAP_REJ_INVALID_CID		0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) /* L2CAP structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) struct l2cap_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	__le16     len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	__le16     cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) #define L2CAP_HDR_SIZE		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) #define L2CAP_ENH_HDR_SIZE	6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) #define L2CAP_EXT_HDR_SIZE	8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) #define L2CAP_FCS_SIZE		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) #define L2CAP_SDULEN_SIZE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) #define L2CAP_PSMLEN_SIZE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) #define L2CAP_ENH_CTRL_SIZE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) #define L2CAP_EXT_CTRL_SIZE	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) struct l2cap_cmd_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	__u8       code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	__u8       ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 	__le16     len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) #define L2CAP_CMD_HDR_SIZE	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) struct l2cap_cmd_rej_unk {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	__le16     reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) struct l2cap_cmd_rej_mtu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) 	__le16     reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	__le16     max_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) struct l2cap_cmd_rej_cid {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) 	__le16     reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	__le16     dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) struct l2cap_conn_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) 	__le16     psm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) struct l2cap_conn_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	__le16     dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 	__le16     result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	__le16     status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) /* protocol/service multiplexer (PSM) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) #define L2CAP_PSM_SDP		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) #define L2CAP_PSM_RFCOMM	0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) #define L2CAP_PSM_3DSP		0x0021
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) #define L2CAP_PSM_IPSP		0x0023 /* 6LoWPAN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) #define L2CAP_PSM_DYN_START	0x1001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) #define L2CAP_PSM_DYN_END	0xffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) #define L2CAP_PSM_AUTO_END	0x10ff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) #define L2CAP_PSM_LE_DYN_START  0x0080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) #define L2CAP_PSM_LE_DYN_END	0x00ff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) /* channel identifier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) #define L2CAP_CID_SIGNALING	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) #define L2CAP_CID_CONN_LESS	0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) #define L2CAP_CID_A2MP		0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) #define L2CAP_CID_ATT		0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) #define L2CAP_CID_LE_SIGNALING	0x0005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) #define L2CAP_CID_SMP		0x0006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) #define L2CAP_CID_SMP_BREDR	0x0007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) #define L2CAP_CID_DYN_START	0x0040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) #define L2CAP_CID_DYN_END	0xffff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) #define L2CAP_CID_LE_DYN_END	0x007f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) /* connect/create channel results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) #define L2CAP_CR_SUCCESS	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) #define L2CAP_CR_PEND		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) #define L2CAP_CR_BAD_PSM	0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) #define L2CAP_CR_SEC_BLOCK	0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) #define L2CAP_CR_NO_MEM		0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) #define L2CAP_CR_BAD_AMP	0x0005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) #define L2CAP_CR_INVALID_SCID	0x0006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) #define L2CAP_CR_SCID_IN_USE	0x0007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) /* credit based connect results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) #define L2CAP_CR_LE_SUCCESS		0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) #define L2CAP_CR_LE_BAD_PSM		0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) #define L2CAP_CR_LE_NO_MEM		0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) #define L2CAP_CR_LE_AUTHENTICATION	0x0005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) #define L2CAP_CR_LE_AUTHORIZATION	0x0006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) #define L2CAP_CR_LE_BAD_KEY_SIZE	0x0007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) #define L2CAP_CR_LE_ENCRYPTION		0x0008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) #define L2CAP_CR_LE_INVALID_SCID	0x0009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) #define L2CAP_CR_LE_SCID_IN_USE		0X000A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) #define L2CAP_CR_LE_UNACCEPT_PARAMS	0X000B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) #define L2CAP_CR_LE_INVALID_PARAMS	0X000C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) /* connect/create channel status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) #define L2CAP_CS_NO_INFO	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) #define L2CAP_CS_AUTHEN_PEND	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) #define L2CAP_CS_AUTHOR_PEND	0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) struct l2cap_conf_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	__le16     dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	__le16     flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	__u8       data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) struct l2cap_conf_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	__le16     flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	__le16     result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	__u8       data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) #define L2CAP_CONF_SUCCESS	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) #define L2CAP_CONF_UNACCEPT	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) #define L2CAP_CONF_REJECT	0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) #define L2CAP_CONF_UNKNOWN	0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) #define L2CAP_CONF_PENDING	0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) #define L2CAP_CONF_EFS_REJECT	0x0005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) /* configuration req/rsp continuation flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) #define L2CAP_CONF_FLAG_CONTINUATION	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) struct l2cap_conf_opt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	__u8       type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	__u8       len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	__u8       val[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) #define L2CAP_CONF_OPT_SIZE	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) #define L2CAP_CONF_HINT		0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) #define L2CAP_CONF_MASK		0x7f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) #define L2CAP_CONF_MTU		0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) #define L2CAP_CONF_FLUSH_TO	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) #define L2CAP_CONF_QOS		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) #define L2CAP_CONF_RFC		0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) #define L2CAP_CONF_FCS		0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) #define L2CAP_CONF_EFS		0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) #define L2CAP_CONF_EWS		0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) #define L2CAP_CONF_MAX_SIZE	22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) struct l2cap_conf_rfc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	__u8       mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	__u8       txwin_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	__u8       max_transmit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	__le16     retrans_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	__le16     monitor_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	__le16     max_pdu_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) #define L2CAP_MODE_BASIC	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) #define L2CAP_MODE_RETRANS	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) #define L2CAP_MODE_FLOWCTL	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) #define L2CAP_MODE_ERTM		0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) #define L2CAP_MODE_STREAMING	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) /* Unlike the above this one doesn't actually map to anything that would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366)  * ever be sent over the air. Therefore, use a value that's unlikely to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367)  * ever be used in the BR/EDR configuration phase.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) #define L2CAP_MODE_LE_FLOWCTL	0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) #define L2CAP_MODE_EXT_FLOWCTL	0x81
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) struct l2cap_conf_efs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 	__u8	id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 	__u8	stype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 	__le16	msdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 	__le32	sdu_itime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 	__le32	acc_lat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 	__le32	flush_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) #define L2CAP_SERV_NOTRAFIC	0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) #define L2CAP_SERV_BESTEFFORT	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) #define L2CAP_SERV_GUARANTEED	0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) #define L2CAP_BESTEFFORT_ID	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) struct l2cap_disconn_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 	__le16     dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) struct l2cap_disconn_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 	__le16     dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) struct l2cap_info_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 	__le16      type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) struct l2cap_info_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 	__le16      type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 	__le16      result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 	__u8        data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) struct l2cap_create_chan_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 	__le16      psm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 	__le16      scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 	__u8        amp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) struct l2cap_create_chan_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 	__le16      dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 	__le16      scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 	__le16      result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 	__le16      status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) struct l2cap_move_chan_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 	__le16      icid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 	__u8        dest_amp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) struct l2cap_move_chan_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 	__le16      icid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 	__le16      result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) #define L2CAP_MR_SUCCESS	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) #define L2CAP_MR_PEND		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) #define L2CAP_MR_BAD_ID		0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) #define L2CAP_MR_SAME_ID	0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) #define L2CAP_MR_NOT_SUPP	0x0004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) #define L2CAP_MR_COLLISION	0x0005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) #define L2CAP_MR_NOT_ALLOWED	0x0006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) struct l2cap_move_chan_cfm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 	__le16      icid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 	__le16      result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) #define L2CAP_MC_CONFIRMED	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) #define L2CAP_MC_UNCONFIRMED	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) struct l2cap_move_chan_cfm_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 	__le16      icid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) /* info type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) #define L2CAP_IT_CL_MTU		0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) #define L2CAP_IT_FEAT_MASK	0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) #define L2CAP_IT_FIXED_CHAN	0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) /* info result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) #define L2CAP_IR_SUCCESS	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) #define L2CAP_IR_NOTSUPP	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) struct l2cap_conn_param_update_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 	__le16      min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	__le16      max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	__le16      latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	__le16      to_multiplier;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) struct l2cap_conn_param_update_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 	__le16      result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) /* Connection Parameters result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) #define L2CAP_CONN_PARAM_ACCEPTED	0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) #define L2CAP_CONN_PARAM_REJECTED	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) struct l2cap_le_conn_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	__le16     psm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	__le16     scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	__le16     mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 	__le16     mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	__le16     credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) struct l2cap_le_conn_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 	__le16     dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 	__le16     mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 	__le16     mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) 	__le16     credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 	__le16     result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) struct l2cap_le_credits {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	__le16     cid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	__le16     credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) #define L2CAP_ECRED_MIN_MTU		64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) #define L2CAP_ECRED_MIN_MPS		64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) struct l2cap_ecred_conn_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	__le16 psm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	__le16 mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	__le16 mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	__le16 credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 	__le16 scid[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) struct l2cap_ecred_conn_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	__le16 mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 	__le16 mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 	__le16 credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	__le16 result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 	__le16 dcid[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) struct l2cap_ecred_reconf_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 	__le16 mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	__le16 mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 	__le16 scid[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) #define L2CAP_RECONF_SUCCESS		0x0000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) #define L2CAP_RECONF_INVALID_MTU	0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) #define L2CAP_RECONF_INVALID_MPS	0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) struct l2cap_ecred_reconf_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	__le16 result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) /* ----- L2CAP channels and connections ----- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) struct l2cap_seq_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 	__u16	head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) 	__u16	tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 	__u16	mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) 	__u16	*list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) #define L2CAP_SEQ_LIST_CLEAR	0xFFFF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) #define L2CAP_SEQ_LIST_TAIL	0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) struct l2cap_chan {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	struct l2cap_conn	*conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	struct hci_conn		*hs_hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	struct hci_chan		*hs_hchan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 	struct kref	kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	atomic_t	nesting;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	__u8		state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	bdaddr_t	dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	__u8		dst_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 	bdaddr_t	src;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	__u8		src_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 	__le16		psm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 	__le16		sport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	__u16		dcid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 	__u16		scid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 	__u16		imtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 	__u16		omtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	__u16		flush_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	__u8		mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 	__u8		chan_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 	__u8		chan_policy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	__u8		sec_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 	__u8		ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	__u8		conf_req[64];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	__u8		conf_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	__u8		num_conf_req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 	__u8		num_conf_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 	__u8		fcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 	__u16		tx_win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 	__u16		tx_win_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 	__u16		ack_win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 	__u8		max_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 	__u16		retrans_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 	__u16		monitor_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	__u16		mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	__u16		tx_credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 	__u16		rx_credits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 	__u8		tx_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 	__u8		rx_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 	unsigned long	conf_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) 	unsigned long	conn_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 	unsigned long	flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 	__u8		remote_amp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 	__u8		local_amp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	__u8		move_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	__u8		move_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	__u8		move_role;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	__u16		next_tx_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	__u16		expected_ack_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 	__u16		expected_tx_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	__u16		buffer_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 	__u16		srej_save_reqseq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 	__u16		last_acked_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 	__u16		frames_sent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 	__u16		unacked_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 	__u8		retry_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	__u16		sdu_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	struct sk_buff	*sdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	struct sk_buff	*sdu_last_frag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	__u16		remote_tx_win;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 	__u8		remote_max_tx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 	__u16		remote_mps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) 	__u8		local_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	__u8		local_stype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) 	__u16		local_msdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	__u32		local_sdu_itime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	__u32		local_acc_lat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	__u32		local_flush_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	__u8		remote_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	__u8		remote_stype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	__u16		remote_msdu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	__u32		remote_sdu_itime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	__u32		remote_acc_lat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	__u32		remote_flush_to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	struct delayed_work	chan_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	struct delayed_work	retrans_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	struct delayed_work	monitor_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	struct delayed_work	ack_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	struct sk_buff		*tx_send_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 	struct sk_buff_head	tx_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	struct sk_buff_head	srej_q;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 	struct l2cap_seq_list	srej_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	struct l2cap_seq_list	retrans_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	struct list_head	global_l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	void			*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	const struct l2cap_ops	*ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	struct mutex		lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	ANDROID_KABI_RESERVE(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) struct l2cap_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	char			*name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 	struct l2cap_chan	*(*new_connection) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	int			(*recv) (struct l2cap_chan * chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 					 struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 	void			(*teardown) (struct l2cap_chan *chan, int err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	void			(*close) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	void			(*state_change) (struct l2cap_chan *chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 						 int state, int err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 	void			(*ready) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	void			(*defer) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 	void			(*resume) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 	void			(*suspend) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	void			(*set_shutdown) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 	long			(*get_sndtimeo) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 	struct pid		*(*get_peer_pid) (struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 	struct sk_buff		*(*alloc_skb) (struct l2cap_chan *chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 					       unsigned long hdr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 					       unsigned long len, int nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 	int			(*filter) (struct l2cap_chan * chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 					   struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 	ANDROID_KABI_RESERVE(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) struct l2cap_conn {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 	struct hci_conn		*hcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	struct hci_chan		*hchan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 	unsigned int		mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 	__u32			feat_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 	__u8			remote_fixed_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	__u8			local_fixed_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	__u8			info_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	__u8			info_ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	struct delayed_work	info_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	struct sk_buff		*rx_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 	__u32			rx_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 	__u8			tx_ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 	struct mutex		ident_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 	struct sk_buff_head	pending_rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 	struct work_struct	pending_rx_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	struct work_struct	id_addr_update_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	__u8			disc_reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	struct l2cap_chan	*smp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	struct list_head	chan_l;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 	struct mutex		chan_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	struct kref		ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 	struct list_head	users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 	ANDROID_KABI_RESERVE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	ANDROID_KABI_RESERVE(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) struct l2cap_user {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 	struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 	int (*probe) (struct l2cap_conn *conn, struct l2cap_user *user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 	void (*remove) (struct l2cap_conn *conn, struct l2cap_user *user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) #define L2CAP_INFO_CL_MTU_REQ_SENT	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) #define L2CAP_INFO_FEAT_MASK_REQ_SENT	0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) #define L2CAP_INFO_FEAT_MASK_REQ_DONE	0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) #define L2CAP_CHAN_RAW			1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) #define L2CAP_CHAN_CONN_LESS		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) #define L2CAP_CHAN_CONN_ORIENTED	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) #define L2CAP_CHAN_FIXED		4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) /* ----- L2CAP socket info ----- */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) struct l2cap_pinfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	struct bt_sock		bt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	struct l2cap_chan	*chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	struct sk_buff		*rx_busy_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	CONF_REQ_SENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	CONF_INPUT_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	CONF_OUTPUT_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	CONF_MTU_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	CONF_MODE_DONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	CONF_CONNECT_PEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 	CONF_RECV_NO_FCS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	CONF_STATE2_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 	CONF_EWS_RECV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	CONF_LOC_CONF_PEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 	CONF_REM_CONF_PEND,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 	CONF_NOT_COMPLETE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) #define L2CAP_CONF_MAX_CONF_REQ 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) #define L2CAP_CONF_MAX_CONF_RSP 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	CONN_SREJ_SENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 	CONN_WAIT_F,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 	CONN_SREJ_ACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	CONN_SEND_PBIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 	CONN_REMOTE_BUSY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 	CONN_LOCAL_BUSY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	CONN_REJ_ACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	CONN_SEND_FBIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	CONN_RNR_SENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) /* Definitions for flags in l2cap_chan */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	FLAG_ROLE_SWITCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	FLAG_FORCE_ACTIVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	FLAG_FORCE_RELIABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	FLAG_FLUSHABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	FLAG_EXT_CTRL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	FLAG_EFS_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	FLAG_DEFER_SETUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	FLAG_LE_CONN_REQ_SENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	FLAG_ECRED_CONN_REQ_SENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	FLAG_PENDING_SECURITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 	FLAG_HOLD_HCI_CONN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) /* Lock nesting levels for L2CAP channels. We need these because lockdep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787)  * otherwise considers all channels equal and will e.g. complain about a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788)  * connection oriented channel triggering SMP procedures or a listening
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789)  * channel creating and locking a child channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 	L2CAP_NESTING_SMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	L2CAP_NESTING_NORMAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	L2CAP_NESTING_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	L2CAP_TX_STATE_XMIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	L2CAP_TX_STATE_WAIT_F,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	L2CAP_RX_STATE_RECV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	L2CAP_RX_STATE_SREJ_SENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	L2CAP_RX_STATE_MOVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 	L2CAP_RX_STATE_WAIT_P,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	L2CAP_RX_STATE_WAIT_F,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	L2CAP_TXSEQ_EXPECTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	L2CAP_TXSEQ_EXPECTED_SREJ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 	L2CAP_TXSEQ_UNEXPECTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	L2CAP_TXSEQ_UNEXPECTED_SREJ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	L2CAP_TXSEQ_DUPLICATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	L2CAP_TXSEQ_DUPLICATE_SREJ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	L2CAP_TXSEQ_INVALID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	L2CAP_TXSEQ_INVALID_IGNORE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	L2CAP_EV_DATA_REQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	L2CAP_EV_LOCAL_BUSY_DETECTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	L2CAP_EV_LOCAL_BUSY_CLEAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	L2CAP_EV_RECV_REQSEQ_AND_FBIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	L2CAP_EV_RECV_FBIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	L2CAP_EV_RETRANS_TO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	L2CAP_EV_MONITOR_TO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	L2CAP_EV_EXPLICIT_POLL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	L2CAP_EV_RECV_IFRAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 	L2CAP_EV_RECV_RR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 	L2CAP_EV_RECV_REJ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 	L2CAP_EV_RECV_RNR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 	L2CAP_EV_RECV_SREJ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	L2CAP_EV_RECV_FRAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	L2CAP_MOVE_ROLE_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	L2CAP_MOVE_ROLE_INITIATOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	L2CAP_MOVE_ROLE_RESPONDER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	L2CAP_MOVE_STABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	L2CAP_MOVE_WAIT_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	L2CAP_MOVE_WAIT_RSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	L2CAP_MOVE_WAIT_RSP_SUCCESS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	L2CAP_MOVE_WAIT_CONFIRM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	L2CAP_MOVE_WAIT_CONFIRM_RSP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	L2CAP_MOVE_WAIT_LOGICAL_COMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	L2CAP_MOVE_WAIT_LOGICAL_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	L2CAP_MOVE_WAIT_LOCAL_BUSY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	L2CAP_MOVE_WAIT_PREPARE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) void l2cap_chan_hold(struct l2cap_chan *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) void l2cap_chan_put(struct l2cap_chan *c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) static inline void l2cap_chan_lock(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 	mutex_lock_nested(&chan->lock, atomic_read(&chan->nesting));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) static inline void l2cap_chan_unlock(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	mutex_unlock(&chan->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) static inline void l2cap_set_timer(struct l2cap_chan *chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 				   struct delayed_work *work, long timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	BT_DBG("chan %p state %s timeout %ld", chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	       state_to_string(chan->state), timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	/* If delayed work cancelled do not hold(chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	   since it is already done with previous set_timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	if (!cancel_delayed_work(work))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 		l2cap_chan_hold(chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	schedule_delayed_work(work, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 				     struct delayed_work *work)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	bool ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	/* put(chan) if delayed work cancelled otherwise it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	   is done in delayed work function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	ret = cancel_delayed_work(work);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 		l2cap_chan_put(chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 		msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	if (seq1 >= seq2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 		return seq1 - seq2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 		return chan->tx_win_max + 1 - seq2 + seq1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	return (seq + 1) % (chan->tx_win_max + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) static inline struct l2cap_chan *l2cap_chan_no_new_connection(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) static inline int l2cap_chan_no_recv(struct l2cap_chan *chan, struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) static inline struct sk_buff *l2cap_chan_no_alloc_skb(struct l2cap_chan *chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 						      unsigned long hdr_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 						      unsigned long len, int nb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	return ERR_PTR(-ENOSYS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) static inline void l2cap_chan_no_teardown(struct l2cap_chan *chan, int err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) static inline void l2cap_chan_no_close(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) static inline void l2cap_chan_no_ready(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) static inline void l2cap_chan_no_state_change(struct l2cap_chan *chan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 					      int state, int err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) static inline void l2cap_chan_no_defer(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) static inline void l2cap_chan_no_suspend(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) static inline void l2cap_chan_no_resume(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) static inline void l2cap_chan_no_set_shutdown(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) extern bool disable_ertm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) extern bool enable_ecred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) int l2cap_init_sockets(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) void l2cap_cleanup_sockets(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) bool l2cap_is_socket(struct socket *sock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) void __l2cap_ecred_conn_rsp_defer(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) int l2cap_add_scid(struct l2cap_chan *chan,  __u16 scid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) struct l2cap_chan *l2cap_chan_create(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) void l2cap_chan_close(struct l2cap_chan *chan, int reason);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 		       bdaddr_t *dst, u8 dst_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) int l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) void l2cap_chan_set_defaults(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) int l2cap_ertm_init(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) typedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 		     void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) void l2cap_chan_del(struct l2cap_chan *chan, int err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) void l2cap_send_conn_req(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) void l2cap_move_start(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		       u8 status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) void __l2cap_physical_cfm(struct l2cap_chan *chan, int result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) struct l2cap_conn *l2cap_conn_get(struct l2cap_conn *conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) void l2cap_conn_put(struct l2cap_conn *conn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) #endif /* __L2CAP_H */