^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) Copyright (c) 2011,2012 Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef __A2MP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define __A2MP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <net/bluetooth/l2cap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) enum amp_mgr_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) READ_LOC_AMP_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) READ_LOC_AMP_ASSOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) READ_LOC_AMP_ASSOC_FINAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) WRITE_REMOTE_AMP_ASSOC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) struct amp_mgr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct l2cap_conn *l2cap_conn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct l2cap_chan *a2mp_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct l2cap_chan *bredr_chan;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct kref kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __u8 ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) __u8 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) unsigned long state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct list_head amp_ctrls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct mutex amp_ctrls_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct a2mp_cmd {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __u8 code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) __u8 ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) __le16 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) __u8 data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* A2MP command codes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define A2MP_COMMAND_REJ 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct a2mp_cmd_rej {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) __le16 reason;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) __u8 data[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define A2MP_DISCOVER_REQ 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct a2mp_discov_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) __le16 mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) __le16 ext_feat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct a2mp_cl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) __u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) __u8 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) __u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define A2MP_DISCOVER_RSP 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct a2mp_discov_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) __le16 mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) __le16 ext_feat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct a2mp_cl cl[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define A2MP_CHANGE_NOTIFY 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define A2MP_CHANGE_RSP 0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define A2MP_GETINFO_REQ 0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct a2mp_info_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) __u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define A2MP_GETINFO_RSP 0x07
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct a2mp_info_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) __u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) __u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) __le32 total_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) __le32 max_bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __le32 min_latency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) __le16 pal_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) __le16 assoc_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define A2MP_GETAMPASSOC_REQ 0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct a2mp_amp_assoc_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) __u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define A2MP_GETAMPASSOC_RSP 0x09
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct a2mp_amp_assoc_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __u8 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) __u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) __u8 amp_assoc[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define A2MP_CREATEPHYSLINK_REQ 0x0A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define A2MP_DISCONNPHYSLINK_REQ 0x0C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct a2mp_physlink_req {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) __u8 local_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) __u8 remote_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) __u8 amp_assoc[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define A2MP_CREATEPHYSLINK_RSP 0x0B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define A2MP_DISCONNPHYSLINK_RSP 0x0D
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct a2mp_physlink_rsp {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) __u8 local_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) __u8 remote_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) __u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /* A2MP response status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define A2MP_STATUS_SUCCESS 0x00
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define A2MP_STATUS_INVALID_CTRL_ID 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #define A2MP_STATUS_COLLISION_OCCURED 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define A2MP_STATUS_SECURITY_VIOLATION 0x06
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #if IS_ENABLED(CONFIG_BT_HS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int amp_mgr_put(struct amp_mgr *mgr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) void a2mp_discover_amp(struct l2cap_chan *chan);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static inline int amp_mgr_put(struct amp_mgr *mgr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static inline struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static inline void a2mp_discover_amp(struct l2cap_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) void a2mp_send_create_phy_link_rsp(struct hci_dev *hdev, u8 status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #endif /* __A2MP_H */