0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __A2MP_H
0009 #define __A2MP_H
0010
0011 #include <net/bluetooth/l2cap.h>
0012
0013 enum amp_mgr_state {
0014 READ_LOC_AMP_INFO,
0015 READ_LOC_AMP_ASSOC,
0016 READ_LOC_AMP_ASSOC_FINAL,
0017 WRITE_REMOTE_AMP_ASSOC,
0018 };
0019
0020 struct amp_mgr {
0021 struct list_head list;
0022 struct l2cap_conn *l2cap_conn;
0023 struct l2cap_chan *a2mp_chan;
0024 struct l2cap_chan *bredr_chan;
0025 struct kref kref;
0026 __u8 ident;
0027 __u8 handle;
0028 unsigned long state;
0029 unsigned long flags;
0030
0031 struct list_head amp_ctrls;
0032 struct mutex amp_ctrls_lock;
0033 };
0034
0035 struct a2mp_cmd {
0036 __u8 code;
0037 __u8 ident;
0038 __le16 len;
0039 __u8 data[];
0040 } __packed;
0041
0042
0043 #define A2MP_COMMAND_REJ 0x01
0044 struct a2mp_cmd_rej {
0045 __le16 reason;
0046 __u8 data[];
0047 } __packed;
0048
0049 #define A2MP_DISCOVER_REQ 0x02
0050 struct a2mp_discov_req {
0051 __le16 mtu;
0052 __le16 ext_feat;
0053 } __packed;
0054
0055 struct a2mp_cl {
0056 __u8 id;
0057 __u8 type;
0058 __u8 status;
0059 } __packed;
0060
0061 #define A2MP_DISCOVER_RSP 0x03
0062 struct a2mp_discov_rsp {
0063 __le16 mtu;
0064 __le16 ext_feat;
0065 struct a2mp_cl cl[];
0066 } __packed;
0067
0068 #define A2MP_CHANGE_NOTIFY 0x04
0069 #define A2MP_CHANGE_RSP 0x05
0070
0071 #define A2MP_GETINFO_REQ 0x06
0072 struct a2mp_info_req {
0073 __u8 id;
0074 } __packed;
0075
0076 #define A2MP_GETINFO_RSP 0x07
0077 struct a2mp_info_rsp {
0078 __u8 id;
0079 __u8 status;
0080 __le32 total_bw;
0081 __le32 max_bw;
0082 __le32 min_latency;
0083 __le16 pal_cap;
0084 __le16 assoc_size;
0085 } __packed;
0086
0087 #define A2MP_GETAMPASSOC_REQ 0x08
0088 struct a2mp_amp_assoc_req {
0089 __u8 id;
0090 } __packed;
0091
0092 #define A2MP_GETAMPASSOC_RSP 0x09
0093 struct a2mp_amp_assoc_rsp {
0094 __u8 id;
0095 __u8 status;
0096 __u8 amp_assoc[];
0097 } __packed;
0098
0099 #define A2MP_CREATEPHYSLINK_REQ 0x0A
0100 #define A2MP_DISCONNPHYSLINK_REQ 0x0C
0101 struct a2mp_physlink_req {
0102 __u8 local_id;
0103 __u8 remote_id;
0104 __u8 amp_assoc[];
0105 } __packed;
0106
0107 #define A2MP_CREATEPHYSLINK_RSP 0x0B
0108 #define A2MP_DISCONNPHYSLINK_RSP 0x0D
0109 struct a2mp_physlink_rsp {
0110 __u8 local_id;
0111 __u8 remote_id;
0112 __u8 status;
0113 } __packed;
0114
0115
0116 #define A2MP_STATUS_SUCCESS 0x00
0117 #define A2MP_STATUS_INVALID_CTRL_ID 0x01
0118 #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02
0119 #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
0120 #define A2MP_STATUS_COLLISION_OCCURED 0x03
0121 #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04
0122 #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
0123 #define A2MP_STATUS_SECURITY_VIOLATION 0x06
0124
0125 struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr);
0126
0127 #if IS_ENABLED(CONFIG_BT_HS)
0128 int amp_mgr_put(struct amp_mgr *mgr);
0129 struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
0130 struct sk_buff *skb);
0131 void a2mp_discover_amp(struct l2cap_chan *chan);
0132 #else
0133 static inline int amp_mgr_put(struct amp_mgr *mgr)
0134 {
0135 return 0;
0136 }
0137
0138 static inline struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
0139 struct sk_buff *skb)
0140 {
0141 return NULL;
0142 }
0143
0144 static inline void a2mp_discover_amp(struct l2cap_chan *chan)
0145 {
0146 }
0147 #endif
0148
0149 void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
0150 void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status);
0151 void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status);
0152 void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status);
0153
0154 #endif